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 dabf313
Show file tree
Hide file tree
Showing 4 changed files with 27 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
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 dabf313

Please sign in to comment.