Skip to content

Commit 80ba00b

Browse files
author
lamai93
committed
Create rotate member plan when pvc have a file system resize pending.
1 parent 82376fd commit 80ba00b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

pkg/deployment/reconcile/plan_builder_storage.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ func createRotateServerStoragePlan(log zerolog.Logger, apiObject k8sutil.APIObje
5757
}
5858
groupSpec := spec.GetServerGroupSpec(group)
5959
storageClassName := groupSpec.GetStorageClassName()
60-
if storageClassName == "" {
61-
// Using default storage class name
62-
continue
63-
}
6460
// Load PVC
6561
pvc, err := getPVC(m.PersistentVolumeClaimName)
6662
if err != nil {
@@ -71,10 +67,17 @@ func createRotateServerStoragePlan(log zerolog.Logger, apiObject k8sutil.APIObje
7167
continue
7268
}
7369
replacementNeeded := false
74-
if util.StringOrDefault(pvc.Spec.StorageClassName) != storageClassName {
70+
if util.StringOrDefault(pvc.Spec.StorageClassName) != storageClassName && storageClassName != "" {
7571
// Storageclass has changed
72+
log.Debug().Str("pod-name", m.PodName).
73+
Str("pvc-storage-class", util.StringOrDefault(pvc.Spec.StorageClassName)).
74+
Str("group-storage-class", storageClassName).Msg("Storage class has changed - pod needs replacement")
7675
replacementNeeded = true
7776
}
77+
rotationNeeded := false
78+
if k8sutil.IsPersistentVolumeClaimFileSystemResizePending(pvc) {
79+
rotationNeeded = true
80+
}
7881
if replacementNeeded {
7982
if group != api.ServerGroupAgents && group != api.ServerGroupDBServers {
8083
// Only agents & dbservers are allowed to change their storage class.
@@ -107,6 +110,8 @@ func createRotateServerStoragePlan(log zerolog.Logger, apiObject k8sutil.APIObje
107110
)
108111
}
109112
}
113+
} else if rotationNeeded {
114+
plan = createRotateMemberPlan(log, m, group, "Filesystem resize pending")
110115
}
111116
}
112117
return nil

pkg/util/k8sutil/pvc.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,21 @@ type PersistentVolumeClaimInterface interface {
3737
Get(name string, options metav1.GetOptions) (*v1.PersistentVolumeClaim, error)
3838
}
3939

40-
// IsPersistentVolumeClaimMarkedForDeletion returns true if the pod has been marked for deletion.
40+
// IsPersistentVolumeClaimMarkedForDeletion returns true if the pvc has been marked for deletion.
4141
func IsPersistentVolumeClaimMarkedForDeletion(pvc *v1.PersistentVolumeClaim) bool {
4242
return pvc.DeletionTimestamp != nil
4343
}
4444

45+
// IsPersistentVolumeClaimFileSystemResizePending returns true if the pvc has FileSystemResizePending set to true
46+
func IsPersistentVolumeClaimFileSystemResizePending(pvc *v1.PersistentVolumeClaim) bool {
47+
for _, c := range pvc.Status.Conditions {
48+
if c.Type == v1.PersistentVolumeClaimFileSystemResizePending && c.Status == v1.ConditionTrue {
49+
return true
50+
}
51+
}
52+
return false
53+
}
54+
4555
// CreatePersistentVolumeClaimName returns the name of the persistent volume claim for a member with
4656
// a given id in a deployment with a given name.
4757
func CreatePersistentVolumeClaimName(deploymentName, role, id string) string {

0 commit comments

Comments
 (0)