-
Notifications
You must be signed in to change notification settings - Fork 413
NO-JIRA: Include the target version in the logging #2050
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
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -349,6 +349,28 @@ func (o *ExtractOptions) Run(ctx context.Context) error { | |
} | ||
} | ||
|
||
// versionInImageConfig stores the version from the label of the image | ||
// At the moment it is used later only for the logging purpose and thus is not blocking if failures occur upon getting its value | ||
var versionInImageConfig string | ||
opts.ImageConfigCallback = func(imageConfig *dockerv1client.DockerImageConfig) { | ||
if imageConfig == nil { | ||
// This should never happen | ||
klog.Error("Cannot retrieve the version because no image configuration is provided in the image to extract") | ||
return | ||
} | ||
if imageConfig.Config == nil { | ||
klog.Error("Cannot retrieve the version from image configuration in the image to extract because it has no configuration") | ||
return | ||
} | ||
v, ok := imageConfig.Config.Labels["io.openshift.release"] | ||
if !ok { | ||
klog.Error("Cannot retrieve the version from image configuration in the image to extract because it does not have the required label 'io.openshift.release'") | ||
return | ||
} | ||
klog.V(2).Infof("Retrieved the version from image configuration in the image to extract: %s", v) | ||
versionInImageConfig = v | ||
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. We assume we never reach this place twice here (= we assume the callback is never called multiple time in a way that reaches this assignment) otherwise the old value is overwritten. That assumption may be fine but I'd either add a comment here about it or logged if we reach here while |
||
} | ||
|
||
var manifestErrs []error | ||
// o.ExtractManifests implies o.File == "" | ||
if o.ExtractManifests { | ||
|
@@ -359,9 +381,9 @@ func (o *ExtractOptions) Run(ctx context.Context) error { | |
context := "connected cluster" | ||
inclusionConfig := manifestInclusionConfiguration{} | ||
if o.InstallConfig == "" { | ||
inclusionConfig, err = findClusterIncludeConfig(ctx, o.RESTConfig) | ||
inclusionConfig, err = findClusterIncludeConfig(ctx, o.RESTConfig, versionInImageConfig) | ||
} else { | ||
inclusionConfig, err = findClusterIncludeConfigFromInstallConfig(ctx, o.InstallConfig) | ||
inclusionConfig, err = findClusterIncludeConfigFromInstallConfig(ctx, o.InstallConfig, versionInImageConfig) | ||
Comment on lines
+384
to
+386
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. Maybe I am missing something but I don't understand when is
How is 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. This is reiterated #1958 (comment) but I do not understand the answer. |
||
context = o.InstallConfig | ||
} | ||
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.
If the errors are not blocking then maybe they should be logged as warnings, not errors?