Skip to content

Commit c4a56ef

Browse files
Merge pull request #455 from mauricioharley/fix_osp_secret
Update reconcileNormal to use VerifySecret
2 parents 1c577c9 + 9207ab9 commit c4a56ef

File tree

6 files changed

+35
-25
lines changed

6 files changed

+35
-25
lines changed

api/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/google/uuid v1.6.0
88
github.com/gophercloud/gophercloud v1.14.0
99
github.com/onsi/gomega v1.34.1
10-
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240730142703-7fd3da600c9d
10+
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240807151544-984575ef0806
1111
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20240730142703-7fd3da600c9d
1212
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20240730142703-7fd3da600c9d
1313
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
@@ -41,7 +41,6 @@ require (
4141
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4242
github.com/modern-go/reflect2 v1.0.2 // indirect
4343
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
44-
github.com/onsi/ginkgo/v2 v2.19.1 // indirect
4544
github.com/openshift/api v3.9.0+incompatible // indirect
4645
github.com/pkg/errors v0.9.1 // indirect
4746
github.com/prometheus/client_golang v1.18.0 // indirect

api/go.sum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
6767
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
6868
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
6969
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
70+
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
7071
github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0=
71-
github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA=
7272
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
7373
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
7474
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxCMwNRnMjhhIDOWHJowi6q8G6koI=
7575
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
76-
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240730142703-7fd3da600c9d h1:WfEUkOxDpMnnYo+mQTJc9juoY85me/V6ubNAsOHdjnc=
77-
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240730142703-7fd3da600c9d/go.mod h1:YlNmaOTuZNZvwlOfosPI94od/V2Itektn9KWThRzylI=
76+
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240807151544-984575ef0806 h1:BI8NzO9gLa3aqERToxLyAg5vpzwfsYmQMkQLyK0AGqM=
77+
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240807151544-984575ef0806/go.mod h1:hCT/Ba8kRkRB23d07YEsCzELsYcJGpD/Uw4NDh+LD6w=
7878
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20240730142703-7fd3da600c9d h1:SRB1rCIVpaVhKxJPkSXE9CNN+xHSrdgXzrRV9ed/hIc=
7979
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20240730142703-7fd3da600c9d/go.mod h1:TyZh5+Uwxb1vcyY44H5GJVulvlQxU05TTAPQ4tSmbzY=
8080
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20240730142703-7fd3da600c9d h1:P5tF3/shBcQf0HkPHWcr5Ri+jsRStMPbGOPQw4qRHRI=

controllers/keystoneapi_controller.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,27 +711,28 @@ func (r *KeystoneAPIReconciler) reconcileNormal(
711711

712712
//
713713
// check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map
714+
// NOTE: VerifySecret handles the "not found" error and returns RequeueAfter ctrl.Result if so, so we don't
715+
// need to check the error type here
714716
//
715-
ospSecret, hash, err := oko_secret.GetSecret(ctx, helper, instance.Spec.Secret, instance.Namespace)
717+
hash, result, err := oko_secret.VerifySecret(ctx, types.NamespacedName{Name: instance.Spec.Secret, Namespace: instance.Namespace}, []string{"AdminPassword"}, helper.GetClient(), time.Second*10)
716718
if err != nil {
717-
if k8s_errors.IsNotFound(err) {
718-
Log.Info(fmt.Sprintf("OpenStack secret %s not found", instance.Spec.Secret))
719-
instance.Status.Conditions.Set(condition.FalseCondition(
720-
condition.InputReadyCondition,
721-
condition.RequestedReason,
722-
condition.SeverityInfo,
723-
condition.InputReadyWaitingMessage))
724-
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
725-
}
726719
instance.Status.Conditions.Set(condition.FalseCondition(
727720
condition.InputReadyCondition,
728721
condition.ErrorReason,
729722
condition.SeverityWarning,
730723
condition.InputReadyErrorMessage,
731724
err.Error()))
732725
return ctrl.Result{}, err
726+
} else if (result != ctrl.Result{}) {
727+
// This case is "secret not found". VerifySecret already logs a message for it
728+
instance.Status.Conditions.Set(condition.FalseCondition(
729+
condition.InputReadyCondition,
730+
condition.RequestedReason,
731+
condition.SeverityInfo,
732+
condition.InputReadyWaitingMessage))
733+
return result, nil
733734
}
734-
configMapVars[ospSecret.Name] = env.SetValue(hash)
735+
configMapVars[instance.Spec.Secret] = env.SetValue(hash)
735736

736737
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)
737738

@@ -889,6 +890,11 @@ func (r *KeystoneAPIReconciler) reconcileNormal(
889890
err.Error()))
890891
return ctrlResult, err
891892
} else if (ctrlResult != ctrl.Result{}) {
893+
instance.Status.Conditions.Set(condition.FalseCondition(
894+
condition.TLSInputReadyCondition,
895+
condition.RequestedReason,
896+
condition.SeverityInfo,
897+
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName)))
892898
return ctrlResult, nil
893899
}
894900

@@ -908,6 +914,11 @@ func (r *KeystoneAPIReconciler) reconcileNormal(
908914
err.Error()))
909915
return ctrlResult, err
910916
} else if (ctrlResult != ctrl.Result{}) {
917+
instance.Status.Conditions.Set(condition.FalseCondition(
918+
condition.TLSInputReadyCondition,
919+
condition.RequestedReason,
920+
condition.SeverityInfo,
921+
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, "one or more cert secrets")))
911922
return ctrlResult, nil
912923
}
913924
configMapVars[tls.TLSHashName] = env.SetValue(certsHash)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/onsi/gomega v1.34.1
1111
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240730162859-91b64b2d2de7
1212
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240213125925-e40975f3db7e
13-
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240730142703-7fd3da600c9d
13+
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240807151544-984575ef0806
1414
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20240730142703-7fd3da600c9d
1515
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20240730142703-7fd3da600c9d
1616
github.com/openstack-k8s-operators/mariadb-operator/api v0.4.1-0.20240730222151-2d771bf1a024

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC
7676
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
7777
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240730162859-91b64b2d2de7 h1:GMZKkNeJGxPk+HazY2q4kc7NHDPX7InMxdMrZ8MDsDc=
7878
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240730162859-91b64b2d2de7/go.mod h1:OamtaW9c7aCtfUmxc/r+/XJS7XRI7s5iR//SZ8ilSwk=
79-
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240730142703-7fd3da600c9d h1:WfEUkOxDpMnnYo+mQTJc9juoY85me/V6ubNAsOHdjnc=
80-
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240730142703-7fd3da600c9d/go.mod h1:YlNmaOTuZNZvwlOfosPI94od/V2Itektn9KWThRzylI=
79+
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240807151544-984575ef0806 h1:BI8NzO9gLa3aqERToxLyAg5vpzwfsYmQMkQLyK0AGqM=
80+
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240807151544-984575ef0806/go.mod h1:hCT/Ba8kRkRB23d07YEsCzELsYcJGpD/Uw4NDh+LD6w=
8181
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20240730142703-7fd3da600c9d h1:SRB1rCIVpaVhKxJPkSXE9CNN+xHSrdgXzrRV9ed/hIc=
8282
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20240730142703-7fd3da600c9d/go.mod h1:TyZh5+Uwxb1vcyY44H5GJVulvlQxU05TTAPQ4tSmbzY=
8383
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20240730142703-7fd3da600c9d h1:P5tF3/shBcQf0HkPHWcr5Ri+jsRStMPbGOPQw4qRHRI=

tests/functional/keystoneapi_controller_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,8 @@ var _ = Describe("Keystone controller", func() {
859859
ConditionGetterFunc(KeystoneConditionGetter),
860860
condition.TLSInputReadyCondition,
861861
corev1.ConditionFalse,
862-
condition.ErrorReason,
863-
fmt.Sprintf("TLSInput error occured in TLS sources Secret %s/combined-ca-bundle not found", namespace),
862+
condition.RequestedReason,
863+
fmt.Sprintf("TLSInput is missing: %s", CABundleSecretName),
864864
)
865865
th.ExpectCondition(
866866
keystoneAPIName,
@@ -877,8 +877,8 @@ var _ = Describe("Keystone controller", func() {
877877
ConditionGetterFunc(KeystoneConditionGetter),
878878
condition.TLSInputReadyCondition,
879879
corev1.ConditionFalse,
880-
condition.ErrorReason,
881-
fmt.Sprintf("TLSInput error occured in TLS sources Secret %s/internal-tls-certs not found", namespace),
880+
condition.RequestedReason,
881+
"TLSInput is missing: one or more cert secrets",
882882
)
883883
th.ExpectCondition(
884884
keystoneAPIName,
@@ -896,8 +896,8 @@ var _ = Describe("Keystone controller", func() {
896896
ConditionGetterFunc(KeystoneConditionGetter),
897897
condition.TLSInputReadyCondition,
898898
corev1.ConditionFalse,
899-
condition.ErrorReason,
900-
fmt.Sprintf("TLSInput error occured in TLS sources Secret %s/public-tls-certs not found", namespace),
899+
condition.RequestedReason,
900+
"TLSInput is missing: one or more cert secrets",
901901
)
902902
th.ExpectCondition(
903903
keystoneAPIName,

0 commit comments

Comments
 (0)