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 tiertemplaterevision for each tiertemplate #1103

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

Conversation

mfrancisc
Copy link
Contributor

@mfrancisc mfrancisc commented Nov 12, 2024

This PR introduces creation of TierTemplateRevision CRs for each TierTemplate, as soon as this is merged we should not see any TTR, we will start seeing those in host namespace only when we populate TierTemplate.Spec.TemplateObjects field.

With the current logic the TTRs are created only when there is a new TierTemplate ( thus one per TierTemplate ) with the TierTemplate.Spec.TemplateObjects field populated. The TTRs are not used yet, thus they will not guide the creation/update/deletion of user namespace content.

In follow up PRs we will introduce comparison between TierTemplate and TierTemplateRevision and usage of TierTemplateRevisions for driving space provisioning.

Jira: https://issues.redhat.com/browse/KUBESAW-146
Paired with: codeready-toolchain/toolchain-e2e#1061

mfrancisc and others added 6 commits January 14, 2025 13:09
Co-authored-by: Matous Jobanek <mjobanek@redhat.com>
Co-authored-by: Matous Jobanek <mjobanek@redhat.com>
Co-authored-by: Matous Jobanek <mjobanek@redhat.com>
Co-authored-by: Matous Jobanek <mjobanek@redhat.com>
Co-authored-by: Matous Jobanek <mjobanek@redhat.com>
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 👍 Thanks a lot for the extra changes
just consider dropping the check for the conflict as mentioned in my last comment #1103 (comment)
I see that you just did that :-)

test/nstemplatetier/assertion.go Outdated Show resolved Hide resolved
Copy link

openshift-ci bot commented Jan 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fbm3307, 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,fbm3307,mfrancisc]

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

@MatousJobanek
Copy link
Contributor

from the TTR resource:

ObjectMeta: (v1.ObjectMeta) &ObjectMeta{Name:ttr,GenerateName:,Namespace:toolchain-host-15114753,SelfLink:,UID:c11220e5-e326-4ac2-a5a9-9aaea92cbe50,ResourceVersion:62162,Generation:1,CreationTimestamp:2025-01-15 12:03:13 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{producer: toolchain-e2e,},Annotations:map[string]string{},OwnerReferences:[]OwnerReference{},Finalizers:[],ManagedFields:[]ManagedFieldsEntry{ManagedFieldsEntry{Manager:Go-http-client,Operation:Update,APIVersion:toolchain.dev.openshift.com/v1alpha1,Time:2025-01-15 12:03:13 +0000 UTC,FieldsType:FieldsV1,FieldsV1:{"f:metadata":{"f:labels":{".":{},"f:producer":{}}},"f:spec":{".":{},"f:clusterResources":{".":{},"f:templateRef":{}},"f:namespaces":{},"f:parameters":{".":{},"k:{\"name\":\"DEPLOYMENT_QUOTA\"}":{".":{},"f:name":{},"f:value":{}}},"f:spaceRoles":{}}},Subresource:,},},},

it doesn't look like the delete would be actually called for this DeletionTimestamp:<nil>

@mfrancisc
Copy link
Contributor Author

it doesn't look like the delete would be actually called for this DeletionTimestamp:

@MatousJobanek thanks for pointing this out. I'm looking at it, seems like the cleanup is buggy ? But most of the time works 🤔

@mfrancisc
Copy link
Contributor Author

it doesn't look like the delete would be actually called for this DeletionTimestamp:

It's strange because that is actually the custom NSTemplateTier I create here with cleanup https://github.com/codeready-toolchain/toolchain-e2e/pull/1061/files#diff-d1f261f3430b9095a3c1639d087ee7fdb0c4a33756c21552ed0a53095c7d9326R412

and the deletion should be triggered here https://github.com/codeready-toolchain/toolchain-e2e/pull/1061/files#diff-9f3717e8440a5df617b514735733d446cd593f05131365e355488105d9f0aa91R115

@mfrancisc
Copy link
Contributor Author

mfrancisc commented Jan 16, 2025

this one looks more like infra/rgsvc glitch :

  signup_request.go:352: 
        	Error Trace:	/tmp/toolchain-e2e/testsupport/signup_request.go:352
        	            				/tmp/toolchain-e2e/testsupport/signup_request.go:244
        	            				/tmp/toolchain-e2e/testsupport/user_setup.go:43
        	            				/tmp/toolchain-e2e/testsupport/user_setup.go:50
        	            				/tmp/toolchain-e2e/test/e2e/parallel/e2e_test.go:70
        	Error:      	Not equal: 
        	            	expected: 202
        	            	actual  : 502
        	Test:       	TestE2EFlow
        	Messages:   	unexpected response status with body: <html><body><h1>502 Bad Gateway</h1>
        	            	The server returned an invalid or incomplete response.

/retest

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.

some additional comments.

controllers/nstemplatetier/nstemplatetier_controller.go Outdated Show resolved Hide resolved
tierTemplatesRefs := []string{
"base1ns-admin-123456new", "base1ns-clusterresources-123456new", "base1ns-code-123456new", "base1ns-dev-123456new", "base1ns-edit-123456new", "base1ns-stage-123456new", "base1ns-viewer-123456new",
}
tiertest.AssertThatNSTemplateTier(t, "base1ns", cl).
Copy link
Contributor

Choose a reason for hiding this comment

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

This assertion is repeated in every subtest here. Is that necessary? If that's part of a setup that is common to all the subtests then it should probably be separated out into its own function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This assertion is repeated in every subtest here. Is that necessary?

Yes, the whole point of the "revisions management" management is to that that the NSTemplateTier.Status.Revisons field is populated as expected, and this is the assertion that does that. After each reconcile it verifies that the field contains the expected values.

If that's part of a setup that is common to all the subtests then it should probably be separated out into its own function.

It is not a setup, it's part of the //then of each test. But maybe I'm not understanding exactly what do you mean with: it should probably be separated out into its own function.

Copy link
Contributor

@metlos metlos Jan 17, 2025

Choose a reason for hiding this comment

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

My point here is that the the setup, i.e. tierTemplates := initTierTemplates(t, nil, base1nsTier.Name) is very similar in many tests, as is the prepareReconcile call, the actual call to Reconcile and the subsequent "sanity checks" up until this assertion.

So I wonder if there is an opportuntity to a) test all of that just once (maybe the slight changes in the "circumstances" in the different test cases don't warrant that) and/or b) to put all that code into a function that would be called from the testcases to make them shorter and hopefully more readable.

test/tiertemplaterevision/assertion.go Outdated Show resolved Hide resolved
@mfrancisc mfrancisc requested a review from metlos January 17, 2025 07:20
@mfrancisc
Copy link
Contributor Author

/retest

infra

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 91.59292% with 19 lines in your changes missing coverage. Please review.

Project coverage is 79.70%. Comparing base (561d8a7) to head (c6b8f7b).

Files with missing lines Patch % Lines
...ollers/nstemplatetier/nstemplatetier_controller.go 84.55% 14 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1103      +/-   ##
==========================================
+ Coverage   79.16%   79.70%   +0.54%     
==========================================
  Files          78       79       +1     
  Lines        7814     8027     +213     
==========================================
+ Hits         6186     6398     +212     
+ Misses       1449     1445       -4     
- Partials      179      184       +5     
Files with missing lines Coverage Δ
test/nstemplatetier/assertion.go 100.00% <100.00%> (ø)
test/nstemplatetier/nstemplatetier.go 74.49% <100.00%> (+11.76%) ⬆️
test/tiertemplaterevision/assertion.go 100.00% <100.00%> (ø)
...ollers/nstemplatetier/nstemplatetier_controller.go 83.09% <84.55%> (+25.95%) ⬆️

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.

5 participants