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
Remove workload, flavor, os labels from templates which have older version #50
Conversation
84f61b8
to
b6637cc
Compare
} | ||
} | ||
|
||
return common.ResourceStatus{}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akrejcir, @vatsalparekh what should be returned in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other resources, this return value signals if the resource is still being updated, or if it is in the desired state. If any resource is still updating, the operator will not be in phase deployed
.
In this case however, the operator does not own any of the old templates, so I think they should not block the operator from being in deployed
state. The return value can be left as is now.
for _, template := range oldTemplates.Items { | ||
for key := range template.Labels { | ||
if strings.HasPrefix(key, "os.template.kubevirt.io/") || strings.HasPrefix(key, "flavor.template.kubevirt.io/") || strings.HasPrefix(key, "workload.template.kubevirt.io/") { | ||
delete(template.Labels, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know go allows removing elements from map while iterating over it. Good to know it does, in other languages it is usually not a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be safe operation.
See https://golang.org/ref/spec#For_statements
The iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next. If a map entry that has not yet been reached is removed during iteration, the corresponding iteration value will not be produced. If a map entry is created during iteration, that entry may be produced during the iteration or may be skipped. The choice may vary for each entry created and from one iteration to the next. If the map is nil, the number of iterations is 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is safe. I just didn't know that before reading this code. I always learn something new.
b6637cc
to
b00edaf
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Looks good. Do you think this needs a functional test? |
Yes, but there is already one https://github.com/kubevirt/ssp-operator/blob/master/tests/e2e-test-csv-generator.sh |
That file only tests CSV generator, not old templates. |
ah you are right, sorry I posted wrong link |
b00edaf
to
68d7164
Compare
68d7164
to
b0acf10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few minor comments.
…rsion With labels removed, old templates will no longer be visible in UI. Signed-off-by: Karel Simon <ksimon@redhat.com>
b0acf10
to
2e70ea2
Compare
@ksimon1: The following tests failed, say
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/test-infra repository. I understand the commands that are listed here. |
@@ -122,4 +127,66 @@ var _ = Describe("Common templates", func() { | |||
table.Entry("[test_id:4770]golden image NS", &goldenImageNS), | |||
) | |||
}) | |||
|
|||
FContext("update old templates", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to unfocus the test. The CI will fail if any tests are focused.
@ksimon1: PR needs rebase. 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/test-infra repository. |
Cloned this PR to #71 |
@vatsalparekh: Closed this PR. In response to this:
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/test-infra repository. |
What this PR does / why we need it:
remove workload, flavor, os labels from templates which have older version
With labels removed, old templates will no longer be visible in UI.
Which issue(s) this PR fixes:
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1859235
Release note: