From 8274aa2426b7c4200efb62cefaa899e3fb13631d Mon Sep 17 00:00:00 2001 From: Ashish Ranjan Date: Mon, 25 Nov 2019 19:53:31 +0530 Subject: [PATCH] enhance(ceph): Adds status field for ceph related CRs This commit adds status field for ceph related CRs which will be useful for knowing the ceph component status without checking the logs. Signed-off-by: Ashish Ranjan --- PendingReleaseNotes.md | 1 + pkg/apis/ceph.rook.io/v1/types.go | 10 ++++- .../ceph.rook.io/v1/zz_generated.deepcopy.go | 41 +++++++++++++++++++ pkg/operator/ceph/file/controller.go | 26 ++++++++++++ pkg/operator/ceph/nfs/controller.go | 31 +++++++++++++- pkg/operator/ceph/object/controller.go | 29 ++++++++++++- pkg/operator/ceph/object/user/controller.go | 23 +++++++++++ pkg/operator/ceph/pool/controller.go | 32 ++++++++++++++- pkg/operator/k8sutil/status.go | 26 ++++++++++++ 9 files changed, 214 insertions(+), 5 deletions(-) create mode 100644 pkg/operator/k8sutil/status.go diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index e9009b326..5e146b3e1 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -25,6 +25,7 @@ - nfs: [samples](Documentation/ceph-nfs-crd.md#samples) - When the operator is upgraded, the mgr and OSDs (not running on PVC) won't be restarted if the Rook binary version changes - Rook is now able to create and manage Ceph clients [client crd](Documentation/ceph-client-crd.html). +- The `Status.Phase` property has been introduced for Rook-Ceph CRDs. The current possible values of status are `Processing`, `Ready` and `Failed`. If the operator is performing any task regarding a Ceph related CR, its status will be reflected as `Processing`. The Status will be changed to `Failed` if the operator fails at some task related to the CR and will change to `Ready` once the Rook-Ceph operator finishes all the tasks related to the CR. - OSDs: - Rook will no longer automatically remove OSDs if nodes are removed from the cluster CR to avoid the risk of destroying OSDs unintentionally. To remove OSDs manually, see the new doc on [OSD Management](Documentation/ceph-osd-mgmt.md) diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index cc13c817a..ca1be5848 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -201,10 +201,10 @@ type CephBlockPool struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` Spec PoolSpec `json:"spec"` + Status *Status `json:"status"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - type CephBlockPoolList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` @@ -229,6 +229,10 @@ type PoolSpec struct { ErasureCoded ErasureCodedSpec `json:"erasureCoded"` } +type Status struct { + Phase string `json:"phase,omitempty"` +} + // ReplicationSpec represents the spec for replication in a pool type ReplicatedSpec struct { // Number of copies per object in a replicated storage pool, including the object itself (required for replicated pool type) @@ -255,6 +259,7 @@ type CephFilesystem struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` Spec FilesystemSpec `json:"spec"` + Status *Status `json:"status"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -309,6 +314,7 @@ type CephObjectStore struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` Spec ObjectStoreSpec `json:"spec"` + Status *Status `json:"status"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -342,6 +348,7 @@ type CephObjectStoreUser struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` Spec ObjectStoreUserSpec `json:"spec"` + Status *Status `json:"status"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -397,6 +404,7 @@ type CephNFS struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` Spec NFSGaneshaSpec `json:"spec"` + Status *Status `json:"status"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go index 94a2ff745..0fbcccbc2 100644 --- a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go @@ -32,6 +32,11 @@ func (in *CephBlockPool) DeepCopyInto(out *CephBlockPool) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(Status) + **out = **in + } return } @@ -213,6 +218,11 @@ func (in *CephFilesystem) DeepCopyInto(out *CephFilesystem) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(Status) + **out = **in + } return } @@ -289,6 +299,11 @@ func (in *CephNFS) DeepCopyInto(out *CephNFS) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(Status) + **out = **in + } return } @@ -349,6 +364,11 @@ func (in *CephObjectStore) DeepCopyInto(out *CephObjectStore) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(Status) + **out = **in + } return } @@ -409,6 +429,11 @@ func (in *CephObjectStoreUser) DeepCopyInto(out *CephObjectStoreUser) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(Status) + **out = **in + } return } @@ -981,3 +1006,19 @@ func (in *ReplicatedSpec) DeepCopy() *ReplicatedSpec { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Status) DeepCopyInto(out *Status) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Status. +func (in *Status) DeepCopy() *Status { + if in == nil { + return nil + } + out := new(Status) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/operator/ceph/file/controller.go b/pkg/operator/ceph/file/controller.go index 8884c5e9d..2a904fe1c 100644 --- a/pkg/operator/ceph/file/controller.go +++ b/pkg/operator/ceph/file/controller.go @@ -29,6 +29,7 @@ import ( "github.com/rook/rook/pkg/clusterd" cephconfig "github.com/rook/rook/pkg/daemon/ceph/config" cephspec "github.com/rook/rook/pkg/operator/ceph/spec" + "github.com/rook/rook/pkg/operator/k8sutil" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" @@ -122,11 +123,14 @@ func (c *FilesystemController) onAdd(obj interface{}) { return } } + updateCephFilesystemStatus(filesystem.GetName(), filesystem.GetNamespace(), k8sutil.ProcessingStatus, c.context) err = createFilesystem(c.clusterInfo, c.context, *filesystem, c.rookVersion, c.clusterSpec, c.filesystemOwner(filesystem), c.clusterSpec.DataDirHostPath, c.isUpgrade) if err != nil { logger.Errorf("failed to create filesystem %q. %v", filesystem.Name, err) + updateCephFilesystemStatus(filesystem.GetName(), filesystem.GetNamespace(), k8sutil.FailedStatus, c.context) } + updateCephFilesystemStatus(filesystem.GetName(), filesystem.GetNamespace(), k8sutil.ReadyStatus, c.context) } func (c *FilesystemController) onUpdate(oldObj, newObj interface{}) { @@ -156,10 +160,13 @@ func (c *FilesystemController) onUpdate(oldObj, newObj interface{}) { // if the filesystem is modified, allow the filesystem to be created if it wasn't already logger.Infof("updating filesystem %s", newFS.Name) + updateCephFilesystemStatus(newFS.GetName(), newFS.GetNamespace(), k8sutil.ProcessingStatus, c.context) err = createFilesystem(c.clusterInfo, c.context, *newFS, c.rookVersion, c.clusterSpec, c.filesystemOwner(newFS), c.clusterSpec.DataDirHostPath, c.isUpgrade) if err != nil { logger.Errorf("failed to create (modify) filesystem %q. %v", newFS.Name, err) + updateCephFilesystemStatus(newFS.GetName(), newFS.GetNamespace(), k8sutil.FailedStatus, c.context) } + updateCephFilesystemStatus(newFS.GetName(), newFS.GetNamespace(), k8sutil.ReadyStatus, c.context) } // ParentClusterChanged determines wether or not a CR update has been sent @@ -270,3 +277,22 @@ func (c *FilesystemController) releaseOrchestrationLock() { c.orchestrationMutex.Unlock() logger.Debugf("Released lock for filesystem orchestration") } + +func updateCephFilesystemStatus(name, namespace, status string, context *clusterd.Context) { + updatedCephFilesystem, err := context.RookClientset.CephV1().CephFilesystems(namespace).Get(name, metav1.GetOptions{}) + if err != nil { + logger.Errorf("Unable to update the cephObjectStore %s status %v", updatedCephFilesystem.GetName(), err) + return + } + if updatedCephFilesystem.Status == nil { + updatedCephFilesystem.Status = &cephv1.Status{} + } else if updatedCephFilesystem.Status.Phase == status { + return + } + updatedCephFilesystem.Status.Phase = status + _, err = context.RookClientset.CephV1().CephFilesystems(updatedCephFilesystem.Namespace).Update(updatedCephFilesystem) + if err != nil { + logger.Errorf("Unable to update the cephObjectStore %s status %v", updatedCephFilesystem.GetName(), err) + return + } +} diff --git a/pkg/operator/ceph/nfs/controller.go b/pkg/operator/ceph/nfs/controller.go index 020f820c5..6300c8c93 100644 --- a/pkg/operator/ceph/nfs/controller.go +++ b/pkg/operator/ceph/nfs/controller.go @@ -26,6 +26,7 @@ import ( cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" "github.com/rook/rook/pkg/clusterd" cephconfig "github.com/rook/rook/pkg/daemon/ceph/config" + "github.com/rook/rook/pkg/operator/k8sutil" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" @@ -98,10 +99,14 @@ func (c *CephNFSController) onAdd(obj interface{}) { c.acquireOrchestrationLock() defer c.releaseOrchestrationLock() + updateCephNFSStatus(nfs.GetName(), nfs.GetNamespace(), k8sutil.ProcessingStatus, c.context) + err := c.upCephNFS(*nfs, 0) if err != nil { logger.Errorf("failed to create NFS Ganesha %q. %v", nfs.Name, err) + updateCephNFSStatus(nfs.GetName(), nfs.GetNamespace(), k8sutil.FailedStatus, c.context) } + updateCephNFSStatus(nfs.GetName(), nfs.GetNamespace(), k8sutil.ReadyStatus, c.context) } func (c *CephNFSController) onUpdate(oldObj, newObj interface{}) { @@ -126,18 +131,23 @@ func (c *CephNFSController) onUpdate(oldObj, newObj interface{}) { defer c.releaseOrchestrationLock() logger.Infof("Updating the ganesha server from %d to %d active count", oldNFS.Spec.Server.Active, newNFS.Spec.Server.Active) + + updateCephNFSStatus(newNFS.GetName(), newNFS.GetNamespace(), k8sutil.ProcessingStatus, c.context) + if oldNFS.Spec.Server.Active < newNFS.Spec.Server.Active { err := c.upCephNFS(*newNFS, oldNFS.Spec.Server.Active) if err != nil { logger.Errorf("Failed to start daemons for CephNFS %q. %v", newNFS.Name, err) + updateCephNFSStatus(newNFS.GetName(), newNFS.GetNamespace(), k8sutil.FailedStatus, c.context) } } else { err := c.downCephNFS(*oldNFS, newNFS.Spec.Server.Active) if err != nil { logger.Errorf("Failed to stop daemons for CephNFS %q. %v", newNFS.Name, err) + updateCephNFSStatus(newNFS.GetName(), newNFS.GetNamespace(), k8sutil.FailedStatus, c.context) } } - + updateCephNFSStatus(newNFS.GetName(), newNFS.GetNamespace(), k8sutil.ReadyStatus, c.context) } func (c *CephNFSController) onDelete(obj interface{}) { @@ -221,3 +231,22 @@ func ownerRefs(nfs cephv1.CephNFS) []metav1.OwnerReference { UID: nfs.UID, }} } + +func updateCephNFSStatus(name, namespace, status string, context *clusterd.Context) { + updatedCephNFS, err := context.RookClientset.CephV1().CephNFSes(namespace).Get(name, metav1.GetOptions{}) + if err != nil { + logger.Errorf("Unable to update the cephNFS %s status %v", updatedCephNFS.GetName(), err) + return + } + if updatedCephNFS.Status == nil { + updatedCephNFS.Status = &cephv1.Status{} + } else if updatedCephNFS.Status.Phase == status { + return + } + updatedCephNFS.Status.Phase = status + _, err = context.RookClientset.CephV1().CephNFSes(updatedCephNFS.Namespace).Update(updatedCephNFS) + if err != nil { + logger.Errorf("Unable to update the cephNFS %s status %v", updatedCephNFS.GetName(), err) + return + } +} diff --git a/pkg/operator/ceph/object/controller.go b/pkg/operator/ceph/object/controller.go index 5986eeabb..f0b4cb7f3 100644 --- a/pkg/operator/ceph/object/controller.go +++ b/pkg/operator/ceph/object/controller.go @@ -29,6 +29,7 @@ import ( daemonconfig "github.com/rook/rook/pkg/daemon/ceph/config" cephconfig "github.com/rook/rook/pkg/operator/ceph/config" cephspec "github.com/rook/rook/pkg/operator/ceph/spec" + "github.com/rook/rook/pkg/operator/k8sutil" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" @@ -102,7 +103,7 @@ func (c *ObjectStoreController) onAdd(obj interface{}) { return } - objectstore, err := getObjectStoreObject(obj) + objectStore, err := getObjectStoreObject(obj) if err != nil { logger.Errorf("failed to get objectstore object. %v", err) return @@ -110,6 +111,7 @@ func (c *ObjectStoreController) onAdd(obj interface{}) { c.acquireOrchestrationLock() defer c.releaseOrchestrationLock() + updateCephObjectStoreStatus(objectStore.GetName(), objectStore.GetNamespace(), k8sutil.ProcessingStatus, c.context) if c.clusterSpec.External.Enable { _, err := cephspec.ValidateCephVersionsBetweenLocalAndExternalClusters(c.context, c.namespace, c.clusterInfo.CephVersion) @@ -117,10 +119,12 @@ func (c *ObjectStoreController) onAdd(obj interface{}) { // This handles the case where the operator is running, the external cluster has been upgraded and a CR creation is called // If that's a major version upgrade we fail, if it's a minor version, we continue, it's not ideal but not critical logger.Errorf("refusing to run new crd. %v", err) + updateCephObjectStoreStatus(objectStore.GetName(), objectStore.GetNamespace(), k8sutil.FailedStatus, c.context) return } } - c.createOrUpdateStore(objectstore) + c.createOrUpdateStore(objectStore) + updateCephObjectStoreStatus(objectStore.GetName(), objectStore.GetNamespace(), k8sutil.ReadyStatus, c.context) } func (c *ObjectStoreController) onUpdate(oldObj, newObj interface{}) { @@ -149,7 +153,9 @@ func (c *ObjectStoreController) onUpdate(oldObj, newObj interface{}) { c.acquireOrchestrationLock() defer c.releaseOrchestrationLock() + updateCephObjectStoreStatus(newStore.GetName(), newStore.GetNamespace(), k8sutil.ProcessingStatus, c.context) c.createOrUpdateStore(newStore) + updateCephObjectStoreStatus(newStore.GetName(), newStore.GetNamespace(), k8sutil.ReadyStatus, c.context) } func (c *ObjectStoreController) createOrUpdateStore(objectstore *cephv1.CephObjectStore) { @@ -284,3 +290,22 @@ func (c *ObjectStoreController) releaseOrchestrationLock() { c.orchestrationMutex.Unlock() logger.Debugf("Released lock for object store orchestration") } + +func updateCephObjectStoreStatus(name, namespace, status string, context *clusterd.Context) { + updatedCephObjectStore, err := context.RookClientset.CephV1().CephObjectStores(namespace).Get(name, metav1.GetOptions{}) + if err != nil { + logger.Errorf("Unable to update the cephObjectStore %s status %v", updatedCephObjectStore.GetName(), err) + return + } + if updatedCephObjectStore.Status == nil { + updatedCephObjectStore.Status = &cephv1.Status{} + } else if updatedCephObjectStore.Status.Phase == status { + return + } + updatedCephObjectStore.Status.Phase = status + _, err = context.RookClientset.CephV1().CephObjectStores(updatedCephObjectStore.Namespace).Update(updatedCephObjectStore) + if err != nil { + logger.Errorf("Unable to update the cephObjectStore %s status %v", updatedCephObjectStore.GetName(), err) + return + } +} diff --git a/pkg/operator/ceph/object/user/controller.go b/pkg/operator/ceph/object/user/controller.go index 2da828372..c1a5878ff 100644 --- a/pkg/operator/ceph/object/user/controller.go +++ b/pkg/operator/ceph/object/user/controller.go @@ -100,10 +100,14 @@ func (c *ObjectStoreUserController) onAdd(obj interface{}) { logger.Errorf("failed to get objectstoreuser object. %v", err) return } + updateCephObjectStoreUserStatus(user.GetName(), user.GetNamespace(), k8sutil.ProcessingStatus, c.context) if err = c.createUser(c.context, user); err != nil { logger.Errorf("failed to create object store user %q. %v", user.Name, err) + updateCephObjectStoreUserStatus(user.GetName(), user.GetNamespace(), k8sutil.FailedStatus, c.context) + } + updateCephObjectStoreUserStatus(user.GetName(), user.GetNamespace(), k8sutil.ReadyStatus, c.context) } func (c *ObjectStoreUserController) onUpdate(oldObj, newObj interface{}) { @@ -303,3 +307,22 @@ func ValidateUser(context *clusterd.Context, u *cephv1.CephObjectStoreUser) erro } return nil } + +func updateCephObjectStoreUserStatus(name, namespace, status string, context *clusterd.Context) { + updatedCephObjectStoreUser, err := context.RookClientset.CephV1().CephObjectStoreUsers(namespace).Get(name, metav1.GetOptions{}) + if err != nil { + logger.Errorf("Unable to update the cephObjectStoreUser %s status %v", updatedCephObjectStoreUser.GetName(), err) + return + } + if updatedCephObjectStoreUser.Status == nil { + updatedCephObjectStoreUser.Status = &cephv1.Status{} + } else if updatedCephObjectStoreUser.Status.Phase == status { + return + } + updatedCephObjectStoreUser.Status.Phase = status + _, err = context.RookClientset.CephV1().CephObjectStoreUsers(updatedCephObjectStoreUser.Namespace).Update(updatedCephObjectStoreUser) + if err != nil { + logger.Errorf("Unable to update the cephObjectStoreUser %s status %v", updatedCephObjectStoreUser.GetName(), err) + return + } +} diff --git a/pkg/operator/ceph/pool/controller.go b/pkg/operator/ceph/pool/controller.go index d4b808c27..e180565e1 100644 --- a/pkg/operator/ceph/pool/controller.go +++ b/pkg/operator/ceph/pool/controller.go @@ -28,7 +28,9 @@ import ( ceph "github.com/rook/rook/pkg/daemon/ceph/client" cephconfig "github.com/rook/rook/pkg/daemon/ceph/config" "github.com/rook/rook/pkg/daemon/ceph/model" + "github.com/rook/rook/pkg/operator/k8sutil" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" ) @@ -90,11 +92,14 @@ func (c *PoolController) onAdd(obj interface{}) { logger.Errorf("failed to get pool object. %v", err) return } - + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.ProcessingStatus, c.context) err = createPool(c.context, pool) if err != nil { logger.Errorf("failed to create pool %q. %v", pool.ObjectMeta.Name, err) + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.FailedStatus, c.context) + return } + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.ReadyStatus, c.context) } func (c *PoolController) onUpdate(oldObj, newObj interface{}) { @@ -116,22 +121,28 @@ func (c *PoolController) onUpdate(oldObj, newObj interface{}) { if oldPool.Name != pool.Name { logger.Errorf("failed to update pool %q. name update not allowed", pool.Name) + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.FailedStatus, c.context) return } if pool.Spec.ErasureCoded.CodingChunks != 0 && pool.Spec.ErasureCoded.DataChunks != 0 { logger.Errorf("failed to update pool %q. erasurecoded update not allowed", pool.Name) + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.FailedStatus, c.context) return } if !poolChanged(oldPool.Spec, pool.Spec) { logger.Debugf("pool %q not changed", pool.Name) return } + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.ProcessingStatus, c.context) // if the pool is modified, allow the pool to be created if it wasn't already logger.Infof("updating pool %q", pool.Name) if err := createPool(c.context, pool); err != nil { logger.Errorf("failed to create (modify) pool %q. %v", pool.ObjectMeta.Name, err) + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.FailedStatus, c.context) + return } + updateCephBlockPoolStatus(pool.GetName(), pool.GetNamespace(), k8sutil.ReadyStatus, c.context) } // ParentClusterChanged determines wether or not a CR update has been sent @@ -285,3 +296,22 @@ func getPoolObject(obj interface{}) (pool *cephv1.CephBlockPool, err error) { return nil, errors.Errorf("not a known pool object %+v", obj) } + +func updateCephBlockPoolStatus(name, namespace, status string, context *clusterd.Context) { + updatedCephBlockPool, err := context.RookClientset.CephV1().CephBlockPools(namespace).Get(name, metav1.GetOptions{}) + if err != nil { + logger.Errorf("Unable to update the cephBlockPool %s status %v", updatedCephBlockPool.GetName(), err) + return + } + if updatedCephBlockPool.Status == nil { + updatedCephBlockPool.Status = &cephv1.Status{} + } else if updatedCephBlockPool.Status.Phase == status { + return + } + updatedCephBlockPool.Status.Phase = status + _, err = context.RookClientset.CephV1().CephBlockPools(updatedCephBlockPool.Namespace).Update(updatedCephBlockPool) + if err != nil { + logger.Errorf("Unable to update the cephBlockPool %s status %v", updatedCephBlockPool.GetName(), err) + return + } +} diff --git a/pkg/operator/k8sutil/status.go b/pkg/operator/k8sutil/status.go new file mode 100644 index 000000000..fa94bde90 --- /dev/null +++ b/pkg/operator/k8sutil/status.go @@ -0,0 +1,26 @@ +/* +Copyright 2019 The Rook Authors. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package k8sutil + +const ( + // ReadyStatus reflects the completeness of tasks for ceph related CRs + ReadyStatus = "Ready" + // ProcessingStatus reflects that the tasks are in progress for ceph related CRs + ProcessingStatus = "Processing" + // FailedStatus reflects that some task failed for ceph related CRs + FailedStatus = "Failed" +)