mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
PR feedback
This commit is contained in:
parent
e6a90aa48a
commit
3cf636b22e
@ -22,7 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
apps "k8s.io/api/apps/v1"
|
apps "k8s.io/api/apps/v1"
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
errorutils "k8s.io/apimachinery/pkg/util/errors"
|
errorutils "k8s.io/apimachinery/pkg/util/errors"
|
||||||
@ -114,7 +114,7 @@ func (om *realStatefulPodControlObjectManager) UpdateClaim(claim *v1.PersistentV
|
|||||||
|
|
||||||
func (spc *StatefulPodControl) CreateStatefulPod(ctx context.Context, set *apps.StatefulSet, pod *v1.Pod) error {
|
func (spc *StatefulPodControl) CreateStatefulPod(ctx context.Context, set *apps.StatefulSet, pod *v1.Pod) error {
|
||||||
// Create the Pod's PVCs prior to creating the Pod
|
// Create the Pod's PVCs prior to creating the Pod
|
||||||
if err := spc.CreatePersistentVolumeClaims(set, pod); err != nil {
|
if err := spc.createPersistentVolumeClaims(set, pod); err != nil {
|
||||||
spc.recordPodEvent("create", set, pod, err)
|
spc.recordPodEvent("create", set, pod, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ func (spc *StatefulPodControl) UpdateStatefulPod(set *apps.StatefulSet, pod *v1.
|
|||||||
if !storageMatches(set, pod) {
|
if !storageMatches(set, pod) {
|
||||||
updateStorage(set, pod)
|
updateStorage(set, pod)
|
||||||
consistent = false
|
consistent = false
|
||||||
if err := spc.CreatePersistentVolumeClaims(set, pod); err != nil {
|
if err := spc.createPersistentVolumeClaims(set, pod); err != nil {
|
||||||
spc.recordPodEvent("update", set, pod, err)
|
spc.recordPodEvent("update", set, pod, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -315,11 +315,11 @@ func (spc *StatefulPodControl) recordClaimEvent(verb string, set *apps.StatefulS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatePersistentVolumeClaims creates all of the required PersistentVolumeClaims for pod, which must be a member of
|
// 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
|
// 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
|
// may be called again until no error is returned, indicating the PersistentVolumeClaims for pod are consistent with
|
||||||
// set's Spec.
|
// set's Spec.
|
||||||
func (spc *StatefulPodControl) CreatePersistentVolumeClaims(set *apps.StatefulSet, pod *v1.Pod) error {
|
func (spc *StatefulPodControl) createPersistentVolumeClaims(set *apps.StatefulSet, pod *v1.Pod) error {
|
||||||
var errs []error
|
var errs []error
|
||||||
for _, claim := range getPersistentVolumeClaims(set, pod) {
|
for _, claim := range getPersistentVolumeClaims(set, pod) {
|
||||||
pvc, err := spc.objectMgr.GetClaim(claim.Namespace, claim.Name)
|
pvc, err := spc.objectMgr.GetClaim(claim.Namespace, claim.Name)
|
||||||
|
@ -453,9 +453,16 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
|||||||
set.Namespace,
|
set.Namespace,
|
||||||
set.Name,
|
set.Name,
|
||||||
replicas[i].Name)
|
replicas[i].Name)
|
||||||
if err := ssc.podControl.CreatePersistentVolumeClaims(set, replicas[i]); err != nil {
|
if err := ssc.podControl.createPersistentVolumeClaims(set, replicas[i]); err != nil {
|
||||||
return &status, err
|
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
|
// If we find a Pod that is currently terminating, we must wait until graceful deletion
|
||||||
// completes before we continue to make progress.
|
// completes before we continue to make progress.
|
||||||
|
@ -2441,7 +2441,7 @@ func (om *fakeObjectManager) DeletePod(pod *v1.Pod) error {
|
|||||||
return nil // Not found, no error in deleting.
|
return nil // Not found, no error in deleting.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (om *fakeObjectManager) CreatePersistentVolumeClaims(set *apps.StatefulSet, pod *v1.Pod) error {
|
func (om *fakeObjectManager) createPersistentVolumeClaims(set *apps.StatefulSet, pod *v1.Pod) error {
|
||||||
for _, claim := range getPersistentVolumeClaims(set, pod) {
|
for _, claim := range getPersistentVolumeClaims(set, pod) {
|
||||||
om.claimsIndexer.Update(&claim)
|
om.claimsIndexer.Update(&claim)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user