Skip to content

Commit

Permalink
Add get amzon config err checks and setdegraded
Browse files Browse the repository at this point in the history
  • Loading branch information
vara2504 committed May 18, 2023
1 parent d0c911f commit b5a8ce5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,11 @@ func (r *ReconcileConnection) Reconcile(ctx context.Context, request reconcile.R

// Populate a list of namespaces to be displayed in the service graph Tigera infrastructure layer.
sgLayerTigeraNameSpaces := render.DefaultSGLayerTigeraNamespaces()
if !sgLayerTigeraNameSpaces[render.GuardianNamespace] {
sgLayerTigeraNameSpaces[render.GuardianNamespace] = true
}
sgLayerTigeraNameSpaces[render.GuardianNamespace] = true

amz, err := utils.GetAmazonCloudIntegration(ctx, r.Client)
if err != nil {
log.Error(err, "Failed to fetch GetAmazonCloudIntegration info")
if err != nil && !k8serrors.IsNotFound(err) {
r.status.SetDegraded(operatorv1.ResourceReadError, "Failed to get the GetAmazonCloudIntegration configuration", err, reqLogger)
} else if amz != nil && !sgLayerTigeraNameSpaces[render.AmazonCloudIntegrationNamespace] {
sgLayerTigeraNameSpaces[render.AmazonCloudIntegrationNamespace] = true
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/controller/manager/manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,7 @@ func (r *ReconcileManager) Reconcile(ctx context.Context, request reconcile.Requ

// Populate a list of namespaces to be displayed in the service graph Tigera infrastructure layer.
sgLayerTigeraNameSpaces := render.DefaultSGLayerTigeraNamespaces()
if !sgLayerTigeraNameSpaces[render.ManagerNamespace] {
sgLayerTigeraNameSpaces[render.ManagerNamespace] = true
}
sgLayerTigeraNameSpaces[render.ManagerNamespace] = true

// Fetch the Authentication spec. If present, we use to configure user authentication.
authenticationCR, err := utils.GetAuthentication(ctx, r.client)
Expand Down Expand Up @@ -531,8 +529,8 @@ func (r *ReconcileManager) Reconcile(ctx context.Context, request reconcile.Requ
}

amz, err := utils.GetAmazonCloudIntegration(ctx, r.client)
if err != nil {
log.Error(err, "Failed to fetch GetAmazonCloudIntegration info")
if err != nil && !errors.IsNotFound(err) {
r.status.SetDegraded(operatorv1.ResourceReadError, "Failed to get the GetAmazonCloudIntegration configuration", err, reqLogger)
} else if amz != nil && !sgLayerTigeraNameSpaces[render.AmazonCloudIntegrationNamespace] {
sgLayerTigeraNameSpaces[render.AmazonCloudIntegrationNamespace] = true
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/render/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,8 @@ func managerClusterWideDefaultView() *v3.UISettings {
}
}

// DefaultSGLayerTigeraNamespaces returns the default list of namespaces to be displayed in Service graph
// map is used to avoid duplication of namespaces.
func DefaultSGLayerTigeraNamespaces() map[string]bool {
return map[string]bool{
"tigera-compliance": true,
Expand Down

0 comments on commit b5a8ce5

Please sign in to comment.