Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic layers to tigera infra layer in SG EV-3506 #2639

Merged
merged 2 commits into from
May 23, 2023

Conversation

vara2504
Copy link
Contributor

@vara2504 vara2504 commented May 15, 2023

Description

Issue: https://tigera.atlassian.net/browse/EV-3506

Changes:

Service graph Layer should display any all the namespace created by the product.

Added a changes to dynamically populate namespace that applicable for cluster type
Standalone cluster/Management cluster:

  • Additional layers : tigera-manager, tigera-dex, tigera-amazon-cloud-integration based on CR.

Managed cluster:

  • Additional layers : tigera-guardian, tigera-amazon-cloud-integration based on CR.

Testing:

Management cluster: with dex enabled
image

Managed cluster:
image

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@vara2504 vara2504 marked this pull request as ready for review May 17, 2023 17:22
@vara2504 vara2504 requested a review from a team as a code owner May 17, 2023 17:22
@@ -331,16 +331,25 @@ func (r *ReconcileConnection) Reconcile(ctx context.Context, request reconcile.R
}
}

optionaUILayerNamespaces := []string{render.GuardianNamespace}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a comment explaining why these are optional and what a UI layer is at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment and updated the variable name as sgLayerTigeraNameSpaces

@@ -942,25 +944,27 @@ func managerUserSpecificSettingsGroup() *v3.UISettingsGroup {
// all of the tigera namespaces.
//
// Calico Enterprise only
func managerClusterWideTigeraLayer() *v3.UISettings {
func managerClusterWideTigeraLayer(namespace []string) *v3.UISettings {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "namespace" is singular, but it's a slice of multiple elements.

This should be called something like additionalNamespaces or something like that.

Alternatively, remove namespaces from this function altogether and callers just need to pass the full list of namespaces they need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Passing the full list from the calling controllers.

"tigera-operator",
"tigera-packetcapture",
"tigera-policy-recommendation",
"tigera-prometheus",
"tigera-system",
"calico-system",
}

for _, ns := range namespace {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the behavior if there are duplicates in this slice?

Copy link
Contributor Author

@vara2504 vara2504 May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the slice with map[string]bool to avoid duplicates

@vara2504 vara2504 changed the title Add dynamic layers to tigera infra layer in SG Add dynamic layers to tigera infra layer in SG EV-3506 May 18, 2023
@@ -331,16 +331,29 @@ 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] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need for the if statement and we can simply set it to true or am I missing something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this applies to all of these if-statements in the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
amz, err := utils.GetAmazonCloudIntegration(ctx, r.Client)
if err != nil {
log.Error(err, "Failed to fetch GetAmazonCloudIntegration info")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2 spaces "to fetch"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

sgLayerTigeraNameSpaces[render.GuardianNamespace] = true
}
amz, err := utils.GetAmazonCloudIntegration(ctx, r.Client)
if err != nil {
Copy link
Member

@rene-dekker rene-dekker May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no AmazonCloudIntegration in the cluster, then err will not be nil. I think you want to filter out the NotFound error. If NotFound then we do nothing. If it is another error, we need to SetDegraded()

If there is no error, then AmazonCloudIntegration is in the cluster and we can set sgLayerTigeraNameSpaces[render.AmazonCloudIntegrationNamespace] = true. No need for an if-statement to see if it is already in the map.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@vara2504
Copy link
Contributor Author

@rene-dekker Addressed the review comments.

@@ -359,6 +359,10 @@ func (r *ReconcileManager) Reconcile(ctx context.Context, request reconcile.Requ
trustedSecretNames = append(trustedSecretNames, render.ComplianceServerCertSecret)
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realize that compliance is an optional namespace as well. The CR is already fetched in this controller.

Copy link
Member

@rene-dekker rene-dekker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rene-dekker rene-dekker merged commit c35cce6 into tigera:release-v1.30 May 23, 2023
rene-dekker pushed a commit that referenced this pull request May 23, 2023
…506 (#2649)

* Add dynamic layers to tigera infra layer in SG

* Return reconcile on error for getamazoncloud integration config
vara2504 added a commit to vara2504/operator that referenced this pull request May 25, 2023
vara2504 added a commit to vara2504/operator that referenced this pull request May 25, 2023
vara2504 added a commit to vara2504/operator that referenced this pull request May 26, 2023
vara2504 added a commit to vara2504/operator that referenced this pull request May 26, 2023
marvin-tigera added a commit that referenced this pull request May 26, 2023
Revert "Cherry-pick #2639 Add dynamic layers to tigera infra layer in SG EV-3506"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants