Merge pull request #49285 from mfojtik/fix-statefull-mutation

Automatic merge from submit-queue (batch tested with PRs 49328, 49285, 49307, 49127, 49163)

fix mutation in statefulset sync

Original issue: https://github.com/openshift/origin/issues/15324

Seems like something inside `UpdateStatefulSet` mutates the StatefulSet. We might need to dig deeper to find the exact location where the non-copy mutation happens.
This commit is contained in:
Kubernetes Submit Queue 2017-07-21 03:00:16 -07:00 committed by GitHub
commit 29cc1aab05
2 changed files with 8 additions and 1 deletions

View File

@ -19,6 +19,7 @@ go_library(
],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/v1/pod:go_default_library",
"//pkg/client/retry:go_default_library",
"//pkg/controller:go_default_library",

View File

@ -39,6 +39,7 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/history"
@ -450,7 +451,12 @@ func (ssc *StatefulSetController) sync(key string) error {
// syncStatefulSet syncs a tuple of (statefulset, []*v1.Pod).
func (ssc *StatefulSetController) syncStatefulSet(set *apps.StatefulSet, pods []*v1.Pod) error {
glog.V(4).Infof("Syncing StatefulSet %v/%v with %d pods", set.Namespace, set.Name, len(pods))
if err := ssc.control.UpdateStatefulSet(set, pods); err != nil {
// TODO: investigate where we mutate the set during the update as it is not obvious.
setCopy, err := api.Scheme.DeepCopy(set)
if err != nil {
return err
}
if err := ssc.control.UpdateStatefulSet(setCopy.(*apps.StatefulSet), pods); err != nil {
return err
}
glog.V(4).Infof("Successfully synced StatefulSet %s/%s successful", set.Namespace, set.Name)