Skip to content

Commit

Permalink
Ceph(fix): Updates on StorageClass won't work.
Browse files Browse the repository at this point in the history
This PR fixes the issue, where the updates given on StorageClass were not working.Now,the cluster will delete the existing sc and create a new one when requested for updation.

Signed-off-by: RAJAT SINGH <rajasing@redhat.com>
  • Loading branch information
RAJAT SINGH committed Jun 29, 2020
1 parent 00570bf commit 5623795
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion hack/latest-csv-checksum.md5
@@ -1 +1 @@
88dfa9ce39fe3b7a5e82518f66a86717
013302e894cd54a7fe31a31050f9a73a
24 changes: 12 additions & 12 deletions pkg/controller/storagecluster/initialization_reconciler.go
Expand Up @@ -65,22 +65,22 @@ func (r *ReconcileStorageCluster) createStorageClasses(scs []*storagev1.StorageC
existing := storagev1.StorageClass{}
err := r.client.Get(context.TODO(), types.NamespacedName{Name: sc.Name, Namespace: sc.Namespace}, &existing)

switch {
case err == nil:
if existing.DeletionTimestamp != nil {
reqLogger.Info(fmt.Sprintf("Unable to restore init object because %s is marked for deletion", existing.Name))
return fmt.Errorf("failed to restore initialization object %s because it is marked for deletion", existing.Name)
if err == nil || errors.IsNotFound(err) {
if err == nil {
if existing.DeletionTimestamp != nil {
reqLogger.Info(fmt.Sprintf("Unable to restore init object because %s is marked for deletion", existing.Name))
return fmt.Errorf("failed to restore initialization object %s because it is marked for deletion", existing.Name)
}
reqLogger.Info("Deleteing StorageClass %s", existing.Name)
err = r.client.Delete(context.TODO(), &existing)
if err != nil {
reqLogger.Error(err, "unable to delete StorageClass")
return err
}
}

reqLogger.Info(fmt.Sprintf("Restoring original StorageClass %s", sc.Name))
existing.ObjectMeta.OwnerReferences = sc.ObjectMeta.OwnerReferences
sc.ObjectMeta = existing.ObjectMeta

err = r.client.Update(context.TODO(), sc)
if err != nil {
return err
}
case errors.IsNotFound(err):
reqLogger.Info(fmt.Sprintf("Creating StorageClass %s", sc.Name))
err = r.client.Create(context.TODO(), sc)
if err != nil {
Expand Down

0 comments on commit 5623795

Please sign in to comment.