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

KUBESAW-147: Space controller updates tier-hash label based on the NSTemplateTier.Status.Revisions field #1135

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

fbm3307
Copy link
Contributor

@fbm3307 fbm3307 commented Feb 5, 2025

This PR is to update the space controller to compute the tier-hash label value using the NSTemplateTier.Status.Revisions field so that it can match outdated spaces using the new revisions mechanism.

Jira-Link - KUBESAW-147

Related PR

Paired PR

…TemplateTier.Status.Revisions field

Signed-off-by: Feny Mehta <[email protected]>
Copy link

openshift-ci bot commented Feb 5, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fbm3307

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Comment on lines +36 to +42
Status: toolchainv1alpha1.NSTemplateTierStatus{
Revisions: map[string]string{
"base1ns-code-123456old": "base1ns-code-123456old",
"base1ns-dev-123456old": "base1ns-dev-123456old",
"base1ns-stage-123456old": "base1ns-stage-123456old",
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like that this test whole test file doesn't actually verify the OutdatedTierSelector function, it looks more like a duplication of the tests that are in toolchain-common. I know that you didn't write the test, but could you please rewrite it? I can imagine that it could be a simple test calling the OutdatedTierSelector and using the selector to list Spaces (with multiple variations of the label), it doesn't have to be anything advanced.

Comment on lines -425 to +433
TemplateRef: tmplTier.Spec.ClusterResources.TemplateRef,
TemplateRef: tmplTier.Status.Revisions[tmplTier.Spec.ClusterResources.TemplateRef],
}
}
if len(tmplTier.Spec.Namespaces) > 0 {
s.Namespaces = make([]toolchainv1alpha1.NSTemplateSetNamespace, len(tmplTier.Spec.Namespaces))
for i, ns := range tmplTier.Spec.Namespaces {
s.Namespaces[i] = toolchainv1alpha1.NSTemplateSetNamespace(ns)
s.Namespaces[i] = toolchainv1alpha1.NSTemplateSetNamespace{
TemplateRef: tmplTier.Status.Revisions[ns.TemplateRef],
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we should make sure that we start using the refs from the revisions map only when the map contains references for all TierTemplates from the Spec.
There can be still some small time gap when the NSTemplateTier.Spec is updated, but the status part doesn't contain the refs for all TierTemplates - in these cases, the refs in Namespaces would contain an empty string, which could trigger the deletion of the already existing namespace.
Let's add a simple "validate" function which validates that the revisions map contains refs for all TierTemplates, if not, then the controller should return an error

Comment on lines 903 to +909
base1nsTier := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates)
base1nsTier.Status.Revisions = tiertest.Base1nsRevision
// get an older base1ns tier (with outdated references)
olderbase1nsTier := tiertest.Base1nsTier(t, tiertest.PreviousBase1nsTemplates)
olderbase1nsTier.Status.Revisions = tiertest.OldTierRevision
otherTier := tiertest.OtherTier()
otherTier.Status.Revisions = tiertest.OtherTierRevision
Copy link
Contributor

Choose a reason for hiding this comment

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

why setting the revisions separately, and not as part of the functions that create the tiers?

Comment on lines +164 to +170
CurrentBase1nsTemplates.Namespaces[0].TemplateRef: CurrentBase1nsTemplates.Namespaces[0].TemplateRef,
CurrentBase1nsTemplates.Namespaces[1].TemplateRef: CurrentBase1nsTemplates.Namespaces[1].TemplateRef,
CurrentBase1nsTemplates.Namespaces[2].TemplateRef: CurrentBase1nsTemplates.Namespaces[2].TemplateRef,
CurrentBase1nsTemplates.ClusterResources.TemplateRef: CurrentBase1nsTemplates.ClusterResources.TemplateRef,
CurrentBase1nsTemplates.SpaceRoles["admin"].TemplateRef: CurrentBase1nsTemplates.SpaceRoles["admin"].TemplateRef,
CurrentBase1nsTemplates.SpaceRoles["edit"].TemplateRef: CurrentBase1nsTemplates.SpaceRoles["edit"].TemplateRef,
CurrentBase1nsTemplates.SpaceRoles["viewer"].TemplateRef: CurrentBase1nsTemplates.SpaceRoles["viewer"].TemplateRef,
Copy link
Contributor

Choose a reason for hiding this comment

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

would be nice to have different values for the key and value to simulate the end-goal where the values will contain names of the TTR CRs

Copy link

openshift-ci bot commented Feb 10, 2025

@fbm3307: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e 6ad3f95 link true /test e2e

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants