Skip to content

Commit ee81522

Browse files
committed
openstack: Set annotation even when credentials mode is unset
Signed-off-by: Stephen Finucane <[email protected]>
1 parent 92e68ab commit ee81522

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

pkg/operator/secretannotator/openstack/reconciler.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,22 @@ func (r *ReconcileCloudCredSecret) Reconcile(ctx context.Context, request reconc
199199
return reconcile.Result{}, err
200200
}
201201

202-
if mode != operatorv1.CloudCredentialsModeDefault {
203-
annotation, err := utils.ModeToAnnotation(mode)
204-
if err != nil {
205-
r.Logger.WithError(err).Error("failed to convert operator mode to annotation")
206-
return reconcile.Result{}, err
207-
}
208-
err = r.updateSecretAnnotations(secret, annotation)
209-
if err != nil {
210-
r.Logger.WithError(err).Error("errored while annotating secret")
211-
}
202+
// default mode is passthrough; annotate accordingly
203+
if mode == operatorv1.CloudCredentialsModeDefault {
204+
mode = operatorv1.CloudCredentialsModePassthrough
205+
}
206+
207+
annotation, err := utils.ModeToAnnotation(mode)
208+
if err != nil {
209+
r.Logger.WithError(err).Error("failed to convert operator mode to annotation")
212210
return reconcile.Result{}, err
213211
}
214212

213+
err = r.updateSecretAnnotations(secret, annotation)
214+
if err != nil {
215+
r.Logger.WithError(err).Error("errored while annotating secret")
216+
return reconcile.Result{}, err
217+
}
215218
return reconcile.Result{}, nil
216219
}
217220

pkg/operator/secretannotator/openstack/reconciler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestReconcileCloudCredSecret_Reconcile(t *testing.T) {
153153
name: "empty string",
154154
mode: "",
155155
existing: nil,
156-
wantAnnotation: "",
156+
wantAnnotation: "passthrough",
157157
wantErr: false,
158158
},
159159
{

pkg/operator/utils/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ func GetLegacyConfigMap(kubeClient client.Client) (*corev1.ConfigMap, error) {
205205
func GetOperatorConfiguration(kubeClient client.Client, logger log.FieldLogger) (
206206
effectiveOperatorMode operatorv1.CloudCredentialsMode,
207207
configurationConflict bool,
208-
err error) {
208+
err error,
209+
) {
209210
var operatorMode operatorv1.CloudCredentialsMode
210211
operatorMode, err = getOperatorMode(kubeClient, logger)
211212
if err != nil {

0 commit comments

Comments
 (0)