Skip to content

Commit

Permalink
pkg/operator/credentialsrequest: Safer resource version dereference
Browse files Browse the repository at this point in the history
This should always be set for actual in-cluster resources, but isn't
set in some unit tests.  By using a local variable with safer
dereferencing, we avoid panics in
TestCredentialsRequestAzureReconcile/new_credential [1].

[1]: https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/openshift_cloud-credential-operator/812/pull-ci-openshift-cloud-credential-operator-master-unit/1872474465263161344#1:build-log.txt%3A65-85
  • Loading branch information
wking committed Jan 2, 2025
1 parent 5d83037 commit 7d7c50a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,16 @@ func (r *ReconcileCredentialsRequest) Reconcile(ctx context.Context, request rec
cr.Status.LastSyncInfrastructureResourceVersion = infra.ResourceVersion
}

resourceVersion := "unset"
if infra != nil && infra.ResourceVersion != nil {
resourceVersion = *infra.ResourceVersion
}

log.WithFields(log.Fields{
"NOT cloudCredsSecretUpdated": cloudCredsSecretUpdated,
"NOT isStale": isStale,
"NOT isInfrastructureUpdated": isInfrastructureUpdated,
"infraResourceVersion": infra.ResourceVersion,
"infraResourceVersion": resourceVersion,
"infraResourceVersionSynced": cr.Status.LastSyncInfrastructureResourceVersion,
"name": cr.Name,
"hasRecentlySynced": hasRecentlySynced,
Expand Down

0 comments on commit 7d7c50a

Please sign in to comment.