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 #1109

Merged
merged 25 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
25aef47
KUBESAW-147: Space controller updates tier-hash label based on the NS…
fbm3307 Feb 5, 2025
4732551
updating the tc dependency using replace
fbm3307 Feb 5, 2025
80c31e9
updating the tc
fbm3307 Feb 6, 2025
b6446ed
extra set of status revision field removed
fbm3307 Feb 6, 2025
bfbe92b
removing the extra changes
fbm3307 Feb 7, 2025
3e443a6
Updating changes of tc
fbm3307 Feb 10, 2025
1acdf4e
Merge branch 'master' into ks147updatehash
mfrancisc Feb 10, 2025
ece9891
Merge branch 'master' into ks147updatehash
MatousJobanek Feb 12, 2025
000091b
ifix for e2e failure
fbm3307 Feb 13, 2025
246e1c0
Merge branch 'master' into ks147updatehash
fbm3307 Feb 13, 2025
c38bb35
a fix for failure
fbm3307 Feb 13, 2025
d2fd66d
updating tc dep
fbm3307 Feb 13, 2025
1f074c4
Merge branch 'master' into ks147updatehash
mfrancisc Feb 13, 2025
5357717
name change for e2e parallel test
fbm3307 Feb 13, 2025
1f94428
changes to wait for revisions
fbm3307 Feb 14, 2025
af21a3d
Merge branch 'master' into ks147updatehash
fbm3307 Feb 18, 2025
9eb6b0f
changes to tc and review comments
fbm3307 Feb 18, 2025
bec47c9
Merge branch 'master' into ks147updatehash
fbm3307 Feb 19, 2025
5d3b444
error fix for e2e
fbm3307 Feb 19, 2025
dd81b87
removing extra
fbm3307 Feb 19, 2025
954a876
Merge branch 'master' into ks147updatehash
fbm3307 Feb 19, 2025
d79a6d3
updating the tc dependency after change
fbm3307 Feb 20, 2025
d99f7ed
Merge branch 'master' into ks147updatehash
fbm3307 Feb 20, 2025
20f279f
Merge branch 'master' into ks147updatehash
fbm3307 Feb 25, 2025
28754b8
removing the replace and updating tc with master
fbm3307 Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ require (
)

go 1.21

replace github.com/codeready-toolchain/toolchain-common => github.com/fbm3307/toolchain-common v0.0.0-20250220120644-6801b14609a1
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/codeready-toolchain/api v0.0.0-20250131222557-beba5463f429 h1:I7xzHRmstvzucH9NqF54xvsM/yYuWOp/G5+BUr5j4tY=
github.com/codeready-toolchain/api v0.0.0-20250131222557-beba5463f429/go.mod h1:gPwicZPTmRm1PF75ysEYXaYKdXoFgwgCggTJd1oYmOs=
github.com/codeready-toolchain/toolchain-common v0.0.0-20250131223755-a9c24d874b32 h1:mX8aMYw9yPCSZuRNeZwShOPQDl0aTKV9FcEfb1Sdhiw=
github.com/codeready-toolchain/toolchain-common v0.0.0-20250131223755-a9c24d874b32/go.mod h1:/PeschEEyTZIAsXQxIf83Fl8kOpSOHDfR5yyanz+bSA=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down Expand Up @@ -177,6 +175,8 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fbm3307/toolchain-common v0.0.0-20250220120644-6801b14609a1 h1:GKf+ilZj/yuzerN92EXYv0CY2Pm4t2Ny4lBvCX2BVMU=
github.com/fbm3307/toolchain-common v0.0.0-20250220120644-6801b14609a1/go.mod h1:/PeschEEyTZIAsXQxIf83Fl8kOpSOHDfR5yyanz+bSA=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/parallel/nstemplatetier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestUpdateNSTemplateTier(t *testing.T) {
verifyResourceUpdatesForSpaces(t, hostAwait, memberAwait, spaces, chocolateTier)

t.Log("updating tiers")
// when updating the "cheesecakeTier" tier with the "advanced" template refs for namespace resources
// when updating the "cheesecakeTier" tier with the "advanced" template refs for namespace resources and spaceroles
cheesecakeTier = tiers.UpdateCustomNSTemplateTier(t, hostAwait, cheesecakeTier, tiers.WithNamespaceResources(t, advancedTier), tiers.WithSpaceRoles(t, advancedTier))
// and when updating the "cookie" tier with the "baseextendedidling" template refs for both namespace resources and cluster-wide resources
cookieTier = tiers.UpdateCustomNSTemplateTier(t, hostAwait, cookieTier, tiers.WithNamespaceResources(t, baseextendedidlingTier), tiers.WithClusterResources(t, baseextendedidlingTier))
Expand Down Expand Up @@ -290,7 +290,6 @@ func TestFeatureToggles(t *testing.T) {
tiers.WithSpaceRoles(t, base1nsTier))
_, err := hostAwait.WaitForNSTemplateTier(t, tier.Name)
require.NoError(t, err)

// when

// Now let's create a Space
Expand Down Expand Up @@ -497,6 +496,7 @@ func TestTierTemplateRevision(t *testing.T) {
wait.HasStatusTierTemplateRevisions(tiers.GetTemplateRefs(t, hostAwait, "updatingtier").Flatten()))
require.NoError(t, err)
updatingTier.NSTemplateTier = tier
revisionsBeforeUpdate := updatingTier.Status.Revisions
// and we update the tier with the "advanced" template refs for namespace and space role resources
tiers.UpdateCustomNSTemplateTier(t, hostAwait, updatingTier, tiers.WithNamespaceResources(t, advancedTier), tiers.WithSpaceRoles(t, advancedTier))

Expand All @@ -515,7 +515,7 @@ func TestTierTemplateRevision(t *testing.T) {
wait.HasStatusTierTemplateRevisions(expectedRefs))
require.NoError(t, err)
// revisions values should be different compared to the previous ones
assert.NotEqual(t, updatingTier.Status.Revisions, updatedTier.Status.Revisions)
assert.NotEqual(t, revisionsBeforeUpdate, updatedTier.Status.Revisions)
})

}
Expand Down
5 changes: 2 additions & 3 deletions testsupport/space/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import (
"testing"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/codeready-toolchain/toolchain-common/pkg/hash"
testspace "github.com/codeready-toolchain/toolchain-common/pkg/test/space"
testtier "github.com/codeready-toolchain/toolchain-common/pkg/test/tier"
"github.com/codeready-toolchain/toolchain-e2e/testsupport"
testsupportsb "github.com/codeready-toolchain/toolchain-e2e/testsupport/spacebinding"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/tiers"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/util"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"

"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -123,7 +122,7 @@ func VerifyResourcesProvisionedForSpaceWithCustomTier(t *testing.T, hostAwait *w
}

func verifyResourcesProvisionedForSpace(t *testing.T, hostAwait *wait.HostAwaitility, targetCluster *wait.MemberAwaitility, spaceName string, tier *toolchainv1alpha1.NSTemplateTier, checks tiers.TierChecks) (*toolchainv1alpha1.Space, *toolchainv1alpha1.NSTemplateSet) {
hash, err := testtier.ComputeTemplateRefsHash(tier) // we can assume the JSON marshalling will always work
hash, err := hash.ComputeHashForNSTemplateTier(tier)
require.NoError(t, err)

// wait for space to be fully provisioned
Expand Down
8 changes: 8 additions & 0 deletions testsupport/tiers/tier_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func CreateCustomNSTemplateTier(t *testing.T, hostAwait *wait.HostAwaitility, na
}
err := hostAwait.CreateWithCleanup(t, tier.NSTemplateTier)
require.NoError(t, err)
newTTier, err := hostAwait.WaitForNSTemplateTier(t, tier.Name,
wait.HasStatusTierTemplateRevisions(GetTemplateRefs(t, hostAwait, tier.Name).Flatten()))
require.NoError(t, err)
tier.NSTemplateTier = newTTier
return tier
}

Expand All @@ -157,6 +161,10 @@ func UpdateCustomNSTemplateTier(t *testing.T, hostAwait *wait.HostAwaitility, ti
nstt.Spec = tier.NSTemplateTier.Spec
})
require.NoError(t, err)
newTTier, err := hostAwait.WaitForNSTemplateTier(t, tier.Name,
wait.HasStatusTierTemplateRevisions(GetTemplateRefs(t, hostAwait, tier.Name).Flatten()))
require.NoError(t, err)
tier.NSTemplateTier = newTTier
return tier
}

Expand Down
4 changes: 2 additions & 2 deletions testsupport/user_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
corev1 "k8s.io/api/core/v1"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/codeready-toolchain/toolchain-common/pkg/hash"
identitypkg "github.com/codeready-toolchain/toolchain-common/pkg/identity"
testtier "github.com/codeready-toolchain/toolchain-common/pkg/test/tier"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/tiers"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"

Expand Down Expand Up @@ -237,7 +237,7 @@ func VerifySpaceRelatedResources(t *testing.T, awaitilities wait.Awaitilities, u

tier, err := hostAwait.WaitForNSTemplateTier(t, spaceTierName)
require.NoError(t, err)
hash, err := testtier.ComputeTemplateRefsHash(tier) // we can assume the JSON marshalling will always work
hash, err := hash.ComputeHashForNSTemplateTier(tier) // we can assume the JSON marshalling will always work
require.NoError(t, err)

space, err := hostAwait.WaitForSpace(t, userSignup.Status.CompliantUsername,
Expand Down
Loading