Skip to content

Commit

Permalink
Remove KeystoneApi check and Improve InstanceHa Conditions messages
Browse files Browse the repository at this point in the history
This commit removes the dependencing on keystonev1 api, so to avoid
any circular dependency between infra-operator and keystone-operator.

It also improves the conditions messages so to make the status
more explicit, for example returning a status like:

[zuul@controller-0 ~]$ oc get instanceha
NAME           STATUS   MESSAGE
instanceha-0   False    Instance HA waiting for Fencing secret

when the Fencing Secret has not been provided or created yet.
  • Loading branch information
lmiccini committed Oct 14, 2024
1 parent 129bf9e commit 9842699
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 67 deletions.
17 changes: 10 additions & 7 deletions apis/instanceha/v1beta1/instanceha_conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ const ()
// Common Messages used by API objects.
const (
// InstanceHaReadyInitMessage
InstanceHaReadyInitMessage = "Instance HA not started, waiting on keystone API"
InstanceHaReadyInitMessage = "Instance HA not started, waiting on Keystone API"

// InstanceHaKeystoneWaitingMessage
InstanceHaKeystoneWaitingMessage = "Instance HA keystone API not yet ready"
// InstanceHaOpenStackConfigMapWaitingMessage
InstanceHaOpenStackConfigMapWaitingMessage = "Instance HA waiting for OpenStack ConfigMap"

// InstanceHaConfigMapWaitingMessage
InstanceHaConfigMapWaitingMessage = "Instance HA waiting for configmap"
// InstanceHaOpenStackConfigSecretWaitingMessage
InstanceHaOpenStackConfigSecretWaitingMessage = "Instance HA waiting for OpenStack Config Secret"

// InstanceHaSecretWaitingMessage
InstanceHaSecretWaitingMessage = "Instance HA waiting for secret"
// InstanceHaConfigMapWaitingMessage)
InstanceHaConfigMapWaitingMessage = "Instance HA waiting for InstanceHA ConfigMap"

// InstanceHaFencingSecretWaitingMessage
InstanceHaFencingSecretWaitingMessage = "Instance HA waiting for Fencing secret"

// InstanceHaInputReady
InstanceHaInputReady = "Instance HA input ready"
Expand Down
8 changes: 0 additions & 8 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ rules:
- get
- patch
- update
- apiGroups:
- keystone.openstack.org
resources:
- keystoneapis
verbs:
- get
- list
- watch
- apiGroups:
- memcached.openstack.org
resources:
Expand Down
40 changes: 3 additions & 37 deletions controllers/instanceha/instanceha_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
labels "github.com/openstack-k8s-operators/lib-common/modules/common/labels"
nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment"

keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
"github.com/openstack-k8s-operators/lib-common/modules/common"
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/configmap"
Expand Down Expand Up @@ -76,7 +75,6 @@ func (r *Reconciler) GetLogger(ctx context.Context) logr.Logger {
// +kubebuilder:rbac:groups=instanceha.openstack.org,resources=instancehas,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=instanceha.openstack.org,resources=instancehas/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=instanceha.openstack.org,resources=instancehas/finalizers,verbs=update;patch
// +kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneapis,verbs=get;list;watch
// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;
// service account, role, rolebinding
Expand Down Expand Up @@ -184,38 +182,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct
return rbacResult, nil
}

//
// Validate that keystoneAPI is up
//
keystoneAPI, err := keystonev1.GetKeystoneAPI(ctx, helper, instance.Namespace, map[string]string{})
if err != nil {
if k8s_errors.IsNotFound(err) {
instance.Status.Conditions.Set(condition.FalseCondition(
instancehav1.InstanceHaReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
instancehav1.InstanceHaKeystoneWaitingMessage))
Log.Info("KeystoneAPI not found!")
return ctrl.Result{RequeueAfter: time.Duration(5) * time.Second}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
instancehav1.InstanceHaReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
instancehav1.InstanceHaReadyErrorMessage,
err.Error()))
return ctrl.Result{}, err
}
if !keystoneAPI.IsReady() {
instance.Status.Conditions.Set(condition.FalseCondition(
instancehav1.InstanceHaReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
instancehav1.InstanceHaKeystoneWaitingMessage))
Log.Info("KeystoneAPI not yet ready")
return ctrl.Result{RequeueAfter: time.Duration(5) * time.Second}, nil
}

Labels := map[string]string{
common.AppSelector: "instanceha",
}
Expand All @@ -229,7 +195,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct
instancehav1.InstanceHaReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
instancehav1.InstanceHaConfigMapWaitingMessage))
instancehav1.InstanceHaOpenStackConfigMapWaitingMessage))
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand All @@ -249,7 +215,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct
instancehav1.InstanceHaReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
instancehav1.InstanceHaSecretWaitingMessage))
instancehav1.InstanceHaOpenStackConfigSecretWaitingMessage))
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand All @@ -269,7 +235,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct
instancehav1.InstanceHaReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
instancehav1.InstanceHaSecretWaitingMessage))
instancehav1.InstanceHaFencingSecretWaitingMessage))
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/onsi/ginkgo/v2 v2.20.1
github.com/onsi/gomega v1.34.1
github.com/openstack-k8s-operators/infra-operator/apis v0.3.0
github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20241012151742-8030171def4e
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20241007071524-66e6544525a3
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20241007071524-66e6544525a3
github.com/rabbitmq/cluster-operator/v2 v2.9.0
Expand Down Expand Up @@ -40,7 +39,6 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
github.com/gophercloud/gophercloud v1.14.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -50,7 +48,6 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openshift/api v3.9.0+incompatible // indirect
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20241007071524-66e6544525a3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQu
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gophercloud/gophercloud v1.14.1 h1:DTCNaTVGl8/cFu58O1JwWgis9gtISAFONqpMKNg/Vpw=
github.com/gophercloud/gophercloud v1.14.1/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand Down Expand Up @@ -77,12 +75,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E=
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20241012151742-8030171def4e h1:F6FyNPO/uCQYMHfPWGCTtcXg6TTrIXzNX+Ij4lSgvIU=
github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20241012151742-8030171def4e/go.mod h1:E8azRt+pUzZCAxq2YRWwILorodLbojKBlniPP5qkcQc=
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20241007071524-66e6544525a3 h1:uPyxfs2VRWpaaDfPZJfGZbUci1EYfTjiQF4krjrE88A=
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20241007071524-66e6544525a3/go.mod h1:EKfyFMU2brJYqR4M2Hwfo5ZLBQxAJXAYfHjpdqX6N5g=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20241007071524-66e6544525a3 h1:xvu7XQzVFA6C89SFmgEj84MPrmCekyQZh2uSDRgQL4I=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20241007071524-66e6544525a3/go.mod h1:djfljx3jfHqywhY3oDvPg/GLKwiFVkds6v7P7/Yg+8g=
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20241007071524-66e6544525a3 h1:0kaIceX1QJzMDuJjtJVcdXXa/3X43cNJBMd16672YAQ=
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20241007071524-66e6544525a3/go.mod h1:LV0jo5etIsGyINpmB37i4oWR8zU6ApIuh7fsqGGA41o=
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20240719064129-c0201810c8f5 h1:xlj///B7XOfz5RoJvvUnY/MA+mNWhDph9xwSY3bERx8=
Expand Down Expand Up @@ -120,7 +114,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
Expand All @@ -133,7 +126,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
Expand All @@ -147,7 +139,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -159,7 +150,6 @@ golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
Expand Down
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import (
networkcontrollers "github.com/openstack-k8s-operators/infra-operator/controllers/network"
rabbitmqcontrollers "github.com/openstack-k8s-operators/infra-operator/controllers/rabbitmq"
rediscontrollers "github.com/openstack-k8s-operators/infra-operator/controllers/redis"
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
//+kubebuilder:scaffold:imports
)

Expand All @@ -67,7 +66,6 @@ func init() {
utilruntime.Must(rabbitmqclusterv2.AddToScheme(scheme))
utilruntime.Must(memcachedv1.AddToScheme(scheme))
utilruntime.Must(instancehav1.AddToScheme(scheme))
utilruntime.Must(keystonev1.AddToScheme(scheme))
utilruntime.Must(redisv1.AddToScheme(scheme))
utilruntime.Must(networkv1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
Expand Down

0 comments on commit 9842699

Please sign in to comment.