Skip to content

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

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

dinhxuanvu
Copy link
Member

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.

@dinhxuanvu dinhxuanvu changed the title [carry] Fix panic issue when annotations map is nil OCPBUGS-25339: [carry] Fix panic issue when annotations map is nil Dec 13, 2023
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Dec 13, 2023
@openshift-ci-robot
Copy link

@dinhxuanvu: This pull request references Jira Issue OCPBUGS-25339, which is invalid:

  • expected the bug to target either version "4.16." or "openshift-4.16.", but it targets "4.15.0" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

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.

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
Copy link
Member Author

/jira refresh

@openshift-ci-robot
Copy link

@dinhxuanvu: This pull request references Jira Issue OCPBUGS-25339, which is invalid:

  • expected the bug to target either version "4.16." or "openshift-4.16.", but it targets "4.15.z" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/jira refresh

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.

Copy link
Contributor

openshift-ci bot commented Dec 13, 2023

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 13, 2023
@dinhxuanvu
Copy link
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Dec 13, 2023
@openshift-ci-robot
Copy link

@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
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @jianzhangbjz

In response to this:

/jira refresh

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.

@openshift-ci openshift-ci bot requested a review from jianzhangbjz December 13, 2023 14:59
@dinhxuanvu
Copy link
Member Author

@tmshort PTAL. Thanks

@dinhxuanvu dinhxuanvu force-pushed the annotations-fix branch 2 times, most recently from fe70a70 to 75ae6c2 Compare December 13, 2023 15:17
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]>
@dinhxuanvu dinhxuanvu changed the title OCPBUGS-25339: [carry] Fix panic issue when annotations map is nil OCPBUGS-25339: [CARRY] Fix panic issue when annotations map is nil Dec 13, 2023
@dinhxuanvu
Copy link
Member Author

/cherry-pick release-4.15

@openshift-cherrypick-robot

@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:

/cherry-pick release-4.15

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
Copy link
Member Author

/retest

Copy link
Contributor

openshift-ci bot commented Dec 13, 2023

@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.

@jianzhangbjz
Copy link
Contributor

LGTM, test details see: https://issues.redhat.com/browse/OCPBUGS-25339
/label qe-approved
/lgtm

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Dec 14, 2023
@openshift-ci-robot
Copy link

@dinhxuanvu: This pull request references Jira Issue OCPBUGS-25339, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @jianzhangbjz

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

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.

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.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 14, 2023
@openshift-merge-bot openshift-merge-bot bot merged commit 748ebaa into openshift:master Dec 14, 2023
@openshift-ci-robot
Copy link

@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:

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.

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.

@openshift-cherrypick-robot

@dinhxuanvu: new pull request created: #635

In response to this:

/cherry-pick release-4.15

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.

@openshift-bot
Copy link
Contributor

[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.
All builds following this will include this PR.

@openshift-bot
Copy link
Contributor

[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.
All builds following this will include this PR.

Comment on lines +2919 to +2932
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Member Author

@dinhxuanvu dinhxuanvu Dec 14, 2023

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.

@tmshort
Copy link
Contributor

tmshort commented Dec 18, 2023

@tmshort PTAL. Thanks

Sorry, was on vacation.

@dinhxuanvu
Copy link
Member Author

@tmshort PTAL. Thanks

Sorry, was on vacation.

All good. Everything was taken off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants