-
Notifications
You must be signed in to change notification settings - Fork 204
OTA-1531: [3/x] cvo: read version from release metadata on startup #1188
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -189,6 +189,31 @@ func (o *Options) Run(ctx context.Context) error { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
payloadRoot := payload.DefaultRootPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if o.PayloadOverride != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
payloadRoot = payload.RootPath(o.PayloadOverride) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cvoOcpVersion := "0.0.1-snapshot" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Peek at the local release metadata to determine the version of OCP this CVO belongs to. This assumes the CVO is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// executing in a container from the payload image. Full payload content is only read later once leader lease is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// acquired, and here we should only read as little data as possible to determine the version so we can establish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// enabled feature gate checker for all following code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// We cannot refuse to start CVO if for some reason we cannot determine the OCP version on startup from the local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// release metadata. The only consequence is we fail to determine enabled/disabled feature gates and will have to use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// some defaults. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
releaseMetadata, err := payloadRoot.LoadReleaseMetadata() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
switch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
case err != nil: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
klog.Warningf("Failed to read release metadata to determine OCP version for this CVO (will use placeholder version %q): %v", cvoOcpVersion, err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
case releaseMetadata.Version == "": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
klog.Warningf("Version missing from release metadata, cannot determine OCP version for this CVO (will use placeholder version %q): %v", cvoOcpVersion, err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. Would
Suggested change
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. Good point, will address |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cvoOcpVersion = releaseMetadata.Version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
klog.Infof("Determined OCP version for this CVO: %q", cvoOcpVersion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+213
to
+214
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. NIT:
Suggested change
(Definitely just a matter of choice) I would use "0.0.1-snapshot" in the other 2 places as well (and we could remove klog.Warningf("Failed to read release metadata to determine OCP version for this CVO (will use placeholder '0.0.1-snapshot'): %v", err) I feel it would be easier a bit to read the code that way and without having to think if 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.
Not the Check out the followups: The "determine OCP version" code will be made into a method: cluster-version-operator/pkg/start/start.go Lines 217 to 243 in 280e27f
And the determined version will be used to determine enable CVO feature gates: cluster-version-operator/pkg/start/start.go Lines 253 to 254 in 280e27f
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// initialize the controllers and attempt to load the payload information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
controllerCtx, err := o.NewControllerContext(cb) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != 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.
This move only addresses a review comment from an earlier PR: #1185 (comment)
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.
It is interesting that github chose to interpret the change as stanza from 311 (the
release
part) is moved down to 318, instead of stanza 318 (thearch
part) is moved up.Github did not read our conversation carefully enough. 😄