Merge pull request #109694 from RyanAoh/fix-108837
Be sure to update the status of StatefulSet even if the new replica creation fails
This commit is contained in:
@@ -29,12 +29,14 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apiserver/pkg/admission"
|
||||
"k8s.io/client-go/informers"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1"
|
||||
typedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/util/retry"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
|
||||
//svc "k8s.io/kubernetes/pkg/api/v1/service"
|
||||
"k8s.io/kubernetes/pkg/controller/statefulset"
|
||||
@@ -309,3 +311,26 @@ func scaleSTS(t *testing.T, c clientset.Interface, sts *appsv1.StatefulSet, repl
|
||||
}
|
||||
waitSTSStable(t, c, sts)
|
||||
}
|
||||
|
||||
var _ admission.ValidationInterface = &fakePodFailAdmission{}
|
||||
|
||||
type fakePodFailAdmission struct {
|
||||
limitedPodNumber int
|
||||
succeedPodsCount int
|
||||
}
|
||||
|
||||
func (f *fakePodFailAdmission) Handles(operation admission.Operation) bool {
|
||||
return operation == admission.Create
|
||||
}
|
||||
|
||||
func (f *fakePodFailAdmission) Validate(ctx context.Context, attr admission.Attributes, o admission.ObjectInterfaces) (err error) {
|
||||
if attr.GetKind().GroupKind() != api.Kind("Pod") {
|
||||
return nil
|
||||
}
|
||||
|
||||
if f.succeedPodsCount >= f.limitedPodNumber {
|
||||
return fmt.Errorf("fakePodFailAdmission error")
|
||||
}
|
||||
f.succeedPodsCount++
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user