-
Notifications
You must be signed in to change notification settings - Fork 71
OCPBUGS-25339: [CARRY] Fix panic issue when annotations map is nil #634
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
OCPBUGS-25339: [CARRY] Fix panic issue when annotations map is nil #634
Conversation
@dinhxuanvu: This pull request references Jira Issue OCPBUGS-25339, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. 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. |
/jira refresh |
@dinhxuanvu: This pull request references Jira Issue OCPBUGS-25339, which is invalid:
Comment 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. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dinhxuanvu 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:
Approvers can indicate their approval by writing |
/jira refresh |
@dinhxuanvu: This pull request references Jira Issue OCPBUGS-25339, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: 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. |
@tmshort PTAL. Thanks |
fe70a70
to
75ae6c2
Compare
In some cases, secrets do not have any annotations and the annotations map are nil. The annotations map needs to be initialized to avoid panic error. Signed-off-by: Vu Dinh <[email protected]>
75ae6c2
to
8c7611d
Compare
/cherry-pick release-4.15 |
@dinhxuanvu: once the present PR merges, I will cherry-pick it on top of release-4.15 in a new PR and assign it to you. 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. |
/retest |
@dinhxuanvu: all tests passed! 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. |
LGTM, test details see: https://issues.redhat.com/browse/OCPBUGS-25339 |
@dinhxuanvu: This pull request references Jira Issue OCPBUGS-25339, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: The bug has been updated to refer to the pull request using the external bug tracker. 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. |
@dinhxuanvu: Jira Issue OCPBUGS-25339: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-25339 has been moved to the MODIFIED state. 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. |
@dinhxuanvu: new pull request created: #635 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. |
[ART PR BUILD NOTIFIER] This PR has been included in build operator-registry-container-v4.16.0-202312140252.p0.g748ebaa.assembly.stream for distgit operator-registry. |
[ART PR BUILD NOTIFIER] This PR has been included in build operator-lifecycle-manager-container-v4.16.0-202312140252.p0.g748ebaa.assembly.stream for distgit operator-lifecycle-manager. |
if secret.Annotations != nil { | ||
if secret.Annotations[install.OpenShiftComponent] == "" { | ||
secret.Annotations[install.OpenShiftComponent] = install.OLMOwnershipAnnotation | ||
} else { | ||
continue | ||
} | ||
} else { | ||
secret.Annotations = map[string]string{} | ||
secret.Annotations[install.OpenShiftComponent] = install.OLMOwnershipAnnotation | ||
} | ||
logger.Debug("injecting ownership annotations to existing secret") | ||
if _, updateErr := a.opClient.UpdateSecret(secret); updateErr != nil { | ||
logger.WithError(err).Warn("error adding ownership annotations to existing secret") | ||
return err |
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 secret.Annotations != nil { | |
if secret.Annotations[install.OpenShiftComponent] == "" { | |
secret.Annotations[install.OpenShiftComponent] = install.OLMOwnershipAnnotation | |
} else { | |
continue | |
} | |
} else { | |
secret.Annotations = map[string]string{} | |
secret.Annotations[install.OpenShiftComponent] = install.OLMOwnershipAnnotation | |
} | |
logger.Debug("injecting ownership annotations to existing secret") | |
if _, updateErr := a.opClient.UpdateSecret(secret); updateErr != nil { | |
logger.WithError(err).Warn("error adding ownership annotations to existing secret") | |
return err | |
if secret.Annotations == nil { | |
secret.Annotations = map[string]string{} | |
} | |
if secret.Annotations[install.OpenShiftComponent] == "" { | |
secret.Annotations[install.OpenShiftComponent] = install.OLMOwnershipAnnotation | |
} | |
logger.Debug("injecting ownership annotations to existing secret") | |
if _, updateErr := a.opClient.UpdateSecret(secret); updateErr != nil { | |
logger.WithError(err).Warn("error adding ownership annotations to existing secret") | |
return err |
why not as ^^ ?
(with apologies for the whitespace)
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.
A bit too late but this is a good suggestion. Would have been cleaner. Will correct this if I need to make some further changes on cert ownership area in the future.
Sorry, was on vacation. |
All good. Everything was taken off. |
In some cases, secrets do not have any annotations and the annotations map are nil. The annotations map needs to be initialized to avoid panic error.