-
Notifications
You must be signed in to change notification settings - Fork 216
pkg/payload: Log manifest exclusion #712
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
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
wking:log-manifest-exclusion
Feb 9, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,19 +179,21 @@ func LoadUpdate(dir, releaseImage, excludeIdentifier string, includeTechPreview | |
| errs = append(errs, fmt.Errorf("parse %s: %w", file.Name(), err)) | ||
| continue | ||
| } | ||
| originalFilename := filepath.Base(file.Name()) | ||
| for i := range ms { | ||
| ms[i].OriginalFilename = originalFilename | ||
| } | ||
|
|
||
| // Filter out manifests that should be excluded based on annotation | ||
| filteredMs := []manifest.Manifest{} | ||
| for _, manifest := range ms { | ||
| if shouldExclude(excludeIdentifier, includeTechPreview, profile, &manifest) { | ||
| if err := include(excludeIdentifier, includeTechPreview, profile, &manifest); err != nil { | ||
| klog.V(5).Infof("excluding %s group=%s kind=%s namespace=%s name=%s: %v\n", manifest.OriginalFilename, manifest.GVK.Group, manifest.GVK.Kind, manifest.Obj.GetNamespace(), manifest.Obj.GetName(), err) | ||
| continue | ||
| } | ||
| filteredMs = append(filteredMs, manifest) | ||
| } | ||
| ms = filteredMs | ||
| for i := range ms { | ||
| ms[i].OriginalFilename = filepath.Base(file.Name()) | ||
| } | ||
| manifests = append(manifests, ms...) | ||
| manifests = append(manifests, filteredMs...) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -213,31 +215,34 @@ func LoadUpdate(dir, releaseImage, excludeIdentifier string, includeTechPreview | |
| return payload, nil | ||
| } | ||
|
|
||
| func shouldExclude(excludeIdentifier string, includeTechPreview bool, profile string, manifest *manifest.Manifest) bool { | ||
| func include(excludeIdentifier string, includeTechPreview bool, profile string, manifest *manifest.Manifest) error { | ||
| annotations := manifest.Obj.GetAnnotations() | ||
| if annotations == nil { | ||
| return true | ||
| return errors.New("no annotations") | ||
| } | ||
|
|
||
| excludeAnnotation := fmt.Sprintf("exclude.release.openshift.io/%s", excludeIdentifier) | ||
| if annotations[excludeAnnotation] == "true" { | ||
| return true | ||
| if v := annotations[excludeAnnotation]; v == "true" { | ||
| return fmt.Errorf("%s=%s", excludeAnnotation, v) | ||
| } | ||
|
|
||
| featureGateAnnotationValue, featureGateAnnotationExists := annotations["release.openshift.io/feature-gate"] | ||
| featureGateAnnotation := "release.openshift.io/feature-gate" | ||
| featureGateAnnotationValue, featureGateAnnotationExists := annotations[featureGateAnnotation] | ||
| if featureGateAnnotationValue == "TechPreviewNoUpgrade" && !includeTechPreview { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same - lets define it as a |
||
| return true | ||
| return fmt.Errorf("tech-preview excluded, and %s=%s", featureGateAnnotation, featureGateAnnotationValue) | ||
| } | ||
| // never include the manifest if the feature-gate annotation is outside of allowed values (only TechPreviewNoUpgrade is currently allowed) | ||
| if featureGateAnnotationExists && featureGateAnnotationValue != "TechPreviewNoUpgrade" { | ||
| return true | ||
| return fmt.Errorf("unrecognized value %s=%s", featureGateAnnotation, featureGateAnnotationValue) | ||
| } | ||
|
|
||
| profileAnnotation := fmt.Sprintf("include.release.openshift.io/%s", profile) | ||
| if val, ok := annotations[profileAnnotation]; ok && val == "true" { | ||
| return false | ||
| return nil | ||
| } else if ok { | ||
| return fmt.Errorf("unrecognized value %s=%s", profileAnnotation, val) | ||
| } | ||
| return true | ||
| return fmt.Errorf("%s unset", profileAnnotation) | ||
| } | ||
|
|
||
| // ValidateDirectory checks if a directory can be a candidate update by | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Move it to
const?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 is our one occurrence of this string outside of comments and tests. Did you want the tests to consume the constant, once we have it? They are hard-coding
TechPreviewNoUpgradetoday too:and there's already an openshift/api constant for that, so I expected the test-suite to prefer string literals to catch thing like "we typo'ed the constant value". And if we expect external consumers, I'd rather create the constant in openshift/api, or openshift/library-go instead of asking external consumers to import the CVO's pkg/payload. Thoughts?