Skip to content

Commit

Permalink
feat(HMS-1674): Verify Azure source availability
Browse files Browse the repository at this point in the history
Implement Azure availability check.
We are only checking that we can login to the given subscritpion and fetch metadata.
We currently fetch the tenant ID.
  • Loading branch information
ezr-ondrej committed Nov 21, 2023
1 parent ada8a82 commit 0564821
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 225 deletions.
19 changes: 17 additions & 2 deletions cmd/pbackend/statuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,23 @@ func checkSourceAvailabilityAzure(cancelCtx context.Context) {
ResourceID: s.SourceApplicationID,
ResourceType: "Application",
}
sr.UserError = "Could not log into Azure account"
sr.Status = kafka.StatusAvailable
azureClient, err := clients.GetAzureClient(ctx, &s.Authentication)
if err != nil {
sr.Status = kafka.StatusUnavailable
sr.Err = err
sr.UserError = "We could not log into this Azure account"
logger.Warn().Err(err).Msg("Failed to create Azure client")
} else {
_, verifyErr := azureClient.TenantId(ctx)
if verifyErr != nil {
sr.Status = kafka.StatusUnavailable
sr.Err = err
sr.UserError = "Red Hat HCC provisioning service account can not connect to your subscription"
logger.Info().Err(err).Str("source_id", sr.ResourceID).Msg("Failed to fetch subscription's tenant from Azure")
} else {
sr.Status = kafka.StatusAvailable
}
}
chSend <- sr
metrics.IncTotalSentAvailabilityCheckReqs(models.ProviderTypeAzure.String(), sr.Status.String(), nil)

Expand Down
2 changes: 2 additions & 0 deletions config/api.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
# arbitrary delay between sources availability checks (time interval syntax) (default "1s")
# AZURE_AVAILABILITY_RATE float32
# probability rate for availability checks (0.0 = all skipped, 1.0 = nothing skipped) (default "1.0")
# AZURE_CLIENT_APP_OBJECT_ID string
# Azure object id of the service application (default "")
# AZURE_CLIENT_ID string
# Azure service account client id (default "")
# AZURE_CLIENT_PRINCIPAL_ID string
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
cloud.google.com/go/compute v1.23.3
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization v1.0.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1
Expand Down
Loading

0 comments on commit 0564821

Please sign in to comment.