New function for creating missing pvcs

This commit is contained in:
Rahul Rangith 2023-01-06 17:22:26 -05:00
parent 8924b58e2c
commit 2f0eb543c7
2 changed files with 17 additions and 8 deletions

View File

@ -315,6 +315,22 @@ func (spc *StatefulPodControl) recordClaimEvent(verb string, set *apps.StatefulS
}
}
// createMissingPersistentVolumeClaims creates all of the required PersistentVolumeClaims for pod, and updates its retention policy
func (spc *StatefulPodControl) createMissingPersistentVolumeClaims(set *apps.StatefulSet, pod *v1.Pod) error {
if err := spc.createPersistentVolumeClaims(set, pod); err != nil {
return err
}
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetAutoDeletePVC) {
// Set PVC policy as much as is possible at this point.
if err := spc.UpdatePodClaimForRetentionPolicy(set, pod); err != nil {
spc.recordPodEvent("update", set, pod, err)
return err
}
}
return nil
}
// createPersistentVolumeClaims creates all of the required PersistentVolumeClaims for pod, which must be a member of
// set. If all of the claims for Pod are successfully created, the returned error is nil. If creation fails, this method
// may be called again until no error is returned, indicating the PersistentVolumeClaims for pod are consistent with

View File

@ -453,16 +453,9 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
set.Namespace,
set.Name,
replicas[i].Name)
if err := ssc.podControl.createPersistentVolumeClaims(set, replicas[i]); err != nil {
if err := ssc.podControl.createMissingPersistentVolumeClaims(set, replicas[i]); err != nil {
return &status, err
}
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetAutoDeletePVC) {
// Set PVC policy as much as is possible at this point.
if err := ssc.podControl.UpdatePodClaimForRetentionPolicy(set, replicas[i]); err != nil {
ssc.podControl.recordPodEvent("update", set, replicas[i], err)
return &status, err
}
}
}
// If we find a Pod that is currently terminating, we must wait until graceful deletion
// completes before we continue to make progress.