Skip to content

Commit

Permalink
Merge pull request openshift#634 from dinhxuanvu/annotations-fix
Browse files Browse the repository at this point in the history
OCPBUGS-25339: [CARRY] Fix panic issue when annotations map is nil
  • Loading branch information
openshift-merge-bot[bot] authored Dec 14, 2023
2 parents d74f6fe + 8c7611d commit 748ebaa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2907,19 +2907,29 @@ func (a *Operator) EnsureSecretOwnershipAnnotations() error {
if err != nil {
return err
}

for _, secret := range secrets {
if secret.Annotations[install.OpenShiftComponent] == "" {
secret.Annotations[install.OpenShiftComponent] = install.OLMOwnershipAnnotation
logger := a.logger.WithFields(logrus.Fields{
"name": secret.GetName(),
"namespace": secret.GetNamespace(),
"self": secret.GetSelfLink(),
})
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
logger := a.logger.WithFields(logrus.Fields{
"name": secret.GetName(),
"namespace": secret.GetNamespace(),
"self": secret.GetSelfLink(),
})
logger.Debug("ensuring ownership annotations existed in the secret")

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
}
}
return nil
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 748ebaa

Please sign in to comment.