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

feat: create new ttr for tiertemplate updates #1130

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

Conversation

mfrancisc
Copy link
Contributor

@mfrancisc mfrancisc commented Jan 24, 2025

This PR triggers a TTR creation when the tiertemlpate content changes or there is a change in the NSTemplateTier parameters field.

follow up from #1103

Paired with: codeready-toolchain/toolchain-e2e#1102

Jira: https://issues.redhat.com/browse/KUBESAW-257

mfrancisc and others added 27 commits December 7, 2023 12:21
@mfrancisc
Copy link
Contributor Author

/retest

updated e2e

Copy link
Contributor

@metlos metlos left a comment

Choose a reason for hiding this comment

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

I only have 2 slight readability improvement suggestions, otherwise looks great!

@mfrancisc mfrancisc requested a review from metlos January 30, 2025 15:40
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 66.10169% with 20 lines in your changes missing coverage. Please review.

Project coverage is 79.41%. Comparing base (fa50881) to head (e8b1d8e).

Files with missing lines Patch % Lines
controllers/nstemplatetier/mapper.go 63.33% 8 Missing and 3 partials ⚠️
...ollers/nstemplatetier/nstemplatetier_controller.go 64.00% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1130      +/-   ##
==========================================
- Coverage   79.52%   79.41%   -0.11%     
==========================================
  Files          80       81       +1     
  Lines        8087     8129      +42     
==========================================
+ Hits         6431     6456      +25     
- Misses       1471     1484      +13     
- Partials      185      189       +4     
Files with missing lines Coverage Δ
test/nstemplatetier/assertion.go 100.00% <100.00%> (ø)
...ollers/nstemplatetier/nstemplatetier_controller.go 81.16% <64.00%> (-2.28%) ⬇️
controllers/nstemplatetier/mapper.go 63.33% <63.33%> (ø)

... and 1 file with indirect coverage changes

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

Looks great 👍

Comment on lines +38 to +49
_, inUse := item.Status.Revisions[obj.GetName()]
if !inUse {
// this tier doesn't use the template
continue
}
// the tier uses this template
req = append(req, reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: item.Namespace,
Name: item.Name,
},
})
Copy link
Contributor

Choose a reason for hiding this comment

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

could be simplified to

Suggested change
_, inUse := item.Status.Revisions[obj.GetName()]
if !inUse {
// this tier doesn't use the template
continue
}
// the tier uses this template
req = append(req, reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: item.Namespace,
Name: item.Name,
},
})
if _, inUse := item.Status.Revisions[obj.GetName()]; inUse {
// the tier uses this template
req = append(req, reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: item.Namespace,
Name: item.Name,
},
})
}

// given
// both tiers are without revisions
base1nsTier := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates)
otherTier := tiertest.AppStudioEnvTier(t, tiertest.AppStudioEnvTemplates)
Copy link
Contributor

Choose a reason for hiding this comment

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

btw, the tests don't verify when the NSTemplateTier has revisions, but not the specific TierTemplate:

Suggested change
otherTier := tiertest.AppStudioEnvTier(t, tiertest.AppStudioEnvTemplates)
otherTier := tiertest.AppStudioEnvTier(t, tiertest.AppStudioEnvTemplates)
prepareTierWithRevisions(otherTier)
delete(otherTier.Status.Revisions, "base1ns-clusterresources-123456new")

@@ -338,6 +316,119 @@ func TestReconcile(t *testing.T) {

}

func TestUpdateNSTemplateTier(t *testing.T) {
logf.SetLogger(zap.New(zap.UseDevMode(true)))
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity - why do we need to configure the logger in the unit test?

Copy link

openshift-ci bot commented Feb 5, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MatousJobanek, mfrancisc

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:
  • OWNERS [MatousJobanek,mfrancisc]

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

Copy link

sonarqubecloud bot commented Feb 5, 2025

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