Skip to content

Commit

Permalink
Add ObservedGeneration to the sub Resources
Browse files Browse the repository at this point in the history
This patch does a few things:

- it adds a Status.OservedGeneration to the sub custom resources
  (API, Sched and Share)
- it proposes to bump the observedGeneration at the beginning of the
  reconciliation loop, after we init the conditions
- it checks, at the top level, if the ObservedGeneration matches with
  the metadata.generation assigned to the subCR(s)
- it propagates the full chain to the StatefulSet, to make sure we are
  able to mark DeploymentReadyCondition as True only when we know it's
  looking at the last Generation for the StatefulSet as well

Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Apr 8, 2024
1 parent 74e2f3c commit 0e2a0d4
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 79 deletions.
3 changes: 3 additions & 0 deletions api/bases/manila.openstack.org_manilaapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ spec:
type: string
type: array
type: object
observedGeneration:
format: int64
type: integer
readyCount:
format: int32
type: integer
Expand Down
3 changes: 3 additions & 0 deletions api/bases/manila.openstack.org_manilaschedulers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@ spec:
type: string
type: array
type: object
observedGeneration:
format: int64
type: integer
readyCount:
format: int32
type: integer
Expand Down
3 changes: 3 additions & 0 deletions api/bases/manila.openstack.org_manilashares.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@ spec:
type: string
type: array
type: object
observedGeneration:
format: int64
type: integer
readyCount:
format: int32
type: integer
Expand Down
16 changes: 8 additions & 8 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/openstack-k8s-operators/manila-operator/api
go 1.20

require (
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240326081751-56015b1ae3f6
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240408095526-357d8fffa034
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240325131352-06e67bf6100d
k8s.io/api v0.28.7
k8s.io/apimachinery v0.28.7
k8s.io/api v0.28.8
k8s.io/apimachinery v0.28.8
sigs.k8s.io/controller-runtime v0.16.5
)

Expand All @@ -24,7 +24,7 @@ require (
github.com/go-openapi/swag v0.22.9 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand Down Expand Up @@ -52,13 +52,13 @@ require (
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.28.7 // indirect
k8s.io/client-go v0.28.7 // indirect
k8s.io/component-base v0.28.7 // indirect
k8s.io/apiextensions-apiserver v0.28.8 // indirect
k8s.io/client-go v0.28.8 // indirect
k8s.io/component-base v0.28.8 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect
Expand Down
36 changes: 18 additions & 18 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand Down Expand Up @@ -62,10 +62,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM=
github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240326081751-56015b1ae3f6 h1:4Z7LjnjEF82XiusXJTI/4TqgwnJas3cdvg/qEgkrW8Q=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240326081751-56015b1ae3f6/go.mod h1:DL+Ts0k+fzgZmx0XxWArIeAmdKuTkPa1I5DThdybfmE=
github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8=
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240408095526-357d8fffa034 h1:HLI/aUA7KnBK5oLPIWXMasz7zqjal4GhNn1P/fdLI20=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240408095526-357d8fffa034/go.mod h1:gqByVGUdKQB/NkhKV4eD+8NWYkHq961nC96rTCB3ywE=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240325131352-06e67bf6100d h1:gqoKVZnmnyvukQ0EvrhzR7JBtP779eyRgsRwbGLvzV4=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240325131352-06e67bf6100d/go.mod h1:O5Cc9+++JnKewv8VWtTQeH5r2gPLy0lhdECfmjy7mF0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -153,8 +153,8 @@ google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAs
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
Expand All @@ -164,16 +164,16 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.28.7 h1:YKIhBxjXKaxuxWJnwohV0aGjRA5l4IU0Eywf/q19AVI=
k8s.io/api v0.28.7/go.mod h1:y4RbcjCCMff1930SG/TcP3AUKNfaJUgIeUp58e/2vyY=
k8s.io/apiextensions-apiserver v0.28.7 h1:NQlzP/vmvIO9Qt7wQTdMe9sGWGkozQZMPk9suehAvR8=
k8s.io/apiextensions-apiserver v0.28.7/go.mod h1:ST+ZOppyy+Z0mIxezSOK8qwIXctNwdFLNpGkQp8bw4M=
k8s.io/apimachinery v0.28.7 h1:2Z38/XRAOcpb+PonxmBEmjG7hBfmmr41xnr0XvpTnB4=
k8s.io/apimachinery v0.28.7/go.mod h1:QFNX/kCl/EMT2WTSz8k4WLCv2XnkOLMaL8GAVRMdpsA=
k8s.io/client-go v0.28.7 h1:3L6402+tjmOl8twX3fjUQ/wsYAkw6UlVNDVP+rF6YGA=
k8s.io/client-go v0.28.7/go.mod h1:xIoEaDewZ+EwWOo1/F1t0IOKMPe1rwBZhLu9Es6y0tE=
k8s.io/component-base v0.28.7 h1:Cq5aQ52N0CTaOMiary4rXzR4RoTP77Z3ll4qSg4qH7s=
k8s.io/component-base v0.28.7/go.mod h1:RrtNBKrSuckksSQ3fV9PhwBSHO/ZbwJXM2Z0OPx+UJk=
k8s.io/api v0.28.8 h1:G0/G7yX1puRAcon/+XPLsKXZ9A5L7Ds6oKbDIe027xw=
k8s.io/api v0.28.8/go.mod h1:rU8f1t9CNUAXlk/1j/wMJ7XnaxkR1g1AlZGQAOOL+sw=
k8s.io/apiextensions-apiserver v0.28.8 h1:JucS9tcaMMlfFrJ09cgh1Maeb8X2wlnxcfNpplyGHXs=
k8s.io/apiextensions-apiserver v0.28.8/go.mod h1:IKpLiKmvEYq/ti8sNtB1sM3A3vVV7fILIsvdmZswhoQ=
k8s.io/apimachinery v0.28.8 h1:hi/nrxHwk4QLV+W/SHve1bypTE59HCDorLY1stBIxKQ=
k8s.io/apimachinery v0.28.8/go.mod h1:cBnwIM3fXoRo28SqbV/Ihxf/iviw85KyXOrzxvZQ83U=
k8s.io/client-go v0.28.8 h1:TE59Tjd87WKvS2FPBTfIKLFX0nQJ4SSHsnDo5IHjgOw=
k8s.io/client-go v0.28.8/go.mod h1:uDVQ/rPzWpWIy40c6lZ4mUwaEvRWGnpoqSO4FM65P3o=
k8s.io/component-base v0.28.8 h1:N/c5L6Ty5rcrFyhsMYsqRFUOVGrqGQsLfjB0yj6npqM=
k8s.io/component-base v0.28.8/go.mod h1:9PjQ4nM1Hth6WGe/O+wgLF32eSwf4oPOoN5elmFznJM=
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
Expand Down
2 changes: 0 additions & 2 deletions api/v1beta1/manila_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,9 @@ type ManilaExtraVolMounts struct {
func (c *ManilaExtraVolMounts) Propagate(svc []storage.PropagationType) []storage.VolMounts {

var vl []storage.VolMounts

for _, gv := range c.VolMounts {
vl = append(vl, gv.Propagate(svc)...)
}

return vl
}

Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/manilaapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ type ManilaAPIStatus struct {

// NetworkAttachments status of the deployment pods
NetworkAttachments map[string][]string `json:"networkAttachments,omitempty"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/manilascheduler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ type ManilaSchedulerStatus struct {

// NetworkAttachments status of the deployment pods
NetworkAttachments map[string][]string `json:"networkAttachments,omitempty"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/manilashare_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ type ManilaShareStatus struct {

// NetworkAttachments status of the deployment pods
NetworkAttachments map[string][]string `json:"networkAttachments,omitempty"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/manila.openstack.org_manilaapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ spec:
type: string
type: array
type: object
observedGeneration:
format: int64
type: integer
readyCount:
format: int32
type: integer
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/manila.openstack.org_manilaschedulers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@ spec:
type: string
type: array
type: object
observedGeneration:
format: int64
type: integer
readyCount:
format: int32
type: integer
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/manila.openstack.org_manilashares.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@ spec:
type: string
type: array
type: object
observedGeneration:
format: int64
type: integer
readyCount:
format: int32
type: integer
Expand Down
110 changes: 102 additions & 8 deletions controllers/manila_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (r *ManilaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
condition.UnknownCondition(condition.CronJobReadyCondition, condition.InitReason, condition.CronJobReadyInitMessage),
)
instance.Status.Conditions.Init(&cl)
instance.Status.ObservedGeneration = instance.Generation

// If we're not deleting this and the service object doesn't have our finalizer, add it.
if (instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer())) || isNewInstance {
Expand Down Expand Up @@ -655,7 +656,25 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila
err.Error()))
return ctrl.Result{}, err
}
if op != controllerutil.OperationResultNone {
apiObsGen, err := r.checkManilaSubCRGeneration(instance, &manilav1beta1.ManilaAPIList{})
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
manilav1beta1.ManilaAPIReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
manilav1beta1.ManilaAPIReadyErrorMessage,
err.Error()))
return ctrlResult, nil
}
if !apiObsGen {
instance.Status.Conditions.Set(condition.UnknownCondition(
manilav1beta1.ManilaAPIReadyCondition,
condition.InitReason,
manilav1beta1.ManilaAPIReadyInitMessage,
),
)
}
if op != controllerutil.OperationResultNone && apiObsGen {
r.Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
}

Expand All @@ -676,8 +695,7 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila
instance.Status.Conditions.Set(c)
}

// TODO: These will not work without rabbit yet
// deploy manila-scheduler
// Deploy ManilaScheduler
manilaScheduler, op, err := r.schedulerDeploymentCreateOrUpdate(ctx, instance)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
Expand All @@ -688,7 +706,25 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila
err.Error()))
return ctrl.Result{}, err
}
if op != controllerutil.OperationResultNone {
schedObsGen, err := r.checkManilaSubCRGeneration(instance, &manilav1beta1.ManilaSchedulerList{})
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
manilav1beta1.ManilaSchedulerReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
manilav1beta1.ManilaSchedulerReadyErrorMessage,
err.Error()))
return ctrlResult, nil
}
if !schedObsGen {
instance.Status.Conditions.Set(condition.UnknownCondition(
manilav1beta1.ManilaSchedulerReadyCondition,
condition.InitReason,
manilav1beta1.ManilaSchedulerReadyInitMessage,
),
)
}
if op != controllerutil.OperationResultNone && schedObsGen {
r.Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
}

Expand All @@ -701,8 +737,7 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila
instance.Status.Conditions.Set(c)
}

// TODO: This requires some sort of backend and rabbit, and will not work without them
// deploy manila-share
// Deploy ManilaShare
var shareCondition *condition.Condition
for name, share := range instance.Spec.ManilaShares {
manilaShare, op, err := r.shareDeploymentCreateOrUpdate(ctx, instance, name, share)
Expand All @@ -715,7 +750,25 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila
err.Error()))
return ctrl.Result{}, err
}
if op != controllerutil.OperationResultNone {
shareObsGen, err := r.checkManilaSubCRGeneration(instance, &manilav1beta1.ManilaShareList{})
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
manilav1beta1.ManilaShareReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
manilav1beta1.ManilaShareReadyErrorMessage,
err.Error()))
return ctrlResult, nil
}
if !shareObsGen {
instance.Status.Conditions.Set(condition.UnknownCondition(
manilav1beta1.ManilaShareReadyCondition,
condition.InitReason,
manilav1beta1.ManilaShareReadyInitMessage,
),
)
}
if op != controllerutil.OperationResultNone && shareObsGen {
r.Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
}

Expand Down Expand Up @@ -769,7 +822,6 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila

r.Log.Info(fmt.Sprintf("Reconciled Service '%s' successfully", instance.Name))
// update the overall status condition if service is ready
instance.Status.ObservedGeneration = instance.Generation
if instance.IsReady() {
instance.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage)
}
Expand Down Expand Up @@ -1126,3 +1178,45 @@ func (r *ManilaReconciler) ensureDB(
instance.Status.Conditions.MarkTrue(condition.DBReadyCondition, condition.DBReadyMessage)
return db, ctrlResult, nil
}

// checkManilaSubCRGeneration -
func (r *ManilaReconciler) checkManilaSubCRGeneration(
instance *manilav1beta1.Manila,
subCR interface{},
) (bool, error) {
listOpts := []client.ListOption{
client.InNamespace(instance.Namespace),
}
if api, ok := subCR.(*manilav1beta1.ManilaAPIList); ok {
if err := r.Client.List(context.Background(), api, listOpts...); err != nil {
r.Log.Error(err, "Unable to retrieve Manila SubCR %w")
return false, err
}
for _, item := range api.Items {
if item.Generation != item.Status.ObservedGeneration {
return false, nil
}
}
} else if sched, ok := subCR.(*manilav1beta1.ManilaSchedulerList); ok {
if err := r.Client.List(context.Background(), sched, listOpts...); err != nil {
r.Log.Error(err, "Unable to retrieve Manila SubCR %w")
return false, err
}
for _, item := range sched.Items {
if item.Generation != item.Status.ObservedGeneration {
return false, nil
}
}
} else {
if err := r.Client.List(context.Background(), subCR.(*manilav1beta1.ManilaShareList), listOpts...); err != nil {
r.Log.Error(err, "Unable to retrieve Manila SubCR %w")
return false, err
}
for _, item := range subCR.(*manilav1beta1.ManilaShareList).Items {
if item.Generation != item.Status.ObservedGeneration {
return false, nil
}
}
}
return true, nil
}
Loading

0 comments on commit 0e2a0d4

Please sign in to comment.