mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #985 from brendandburns/kubecfg
Make rolling update be blocking.
This commit is contained in:
commit
42685ad8f1
@ -29,6 +29,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||
"github.com/golang/glog"
|
||||
"gopkg.in/v1/yaml"
|
||||
@ -93,6 +94,10 @@ func Update(name string, client client.Interface, updatePeriod time.Duration) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
expected := len(podList.Items)
|
||||
if expected == 0 {
|
||||
return nil
|
||||
}
|
||||
for _, pod := range podList.Items {
|
||||
// We delete the pod here, the controller will recreate it. This will result in pulling
|
||||
// a new Docker image. This isn't a full "update" but it's what we support for now.
|
||||
@ -102,7 +107,13 @@ func Update(name string, client client.Interface, updatePeriod time.Duration) er
|
||||
}
|
||||
time.Sleep(updatePeriod)
|
||||
}
|
||||
return nil
|
||||
return wait.Poll(time.Second*5, 60 /* timeout after 300 seconds */, func() (bool, error) {
|
||||
podList, err := client.ListPods(s)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return len(podList.Items) == expected, nil
|
||||
})
|
||||
}
|
||||
|
||||
// StopController stops a controller named 'name' by setting replicas to zero
|
||||
|
@ -44,7 +44,7 @@ func TestUpdateWithPods(t *testing.T) {
|
||||
},
|
||||
}
|
||||
Update("foo", &fakeClient, 0)
|
||||
if len(fakeClient.Actions) != 4 {
|
||||
if len(fakeClient.Actions) != 5 {
|
||||
t.Errorf("Unexpected action list %#v", fakeClient.Actions)
|
||||
}
|
||||
validateAction(client.FakeAction{Action: "get-controller", Value: "foo"}, fakeClient.Actions[0], t)
|
||||
@ -52,6 +52,7 @@ func TestUpdateWithPods(t *testing.T) {
|
||||
// Update deletes the pods, it relies on the replication controller to replace them.
|
||||
validateAction(client.FakeAction{Action: "delete-pod", Value: "pod-1"}, fakeClient.Actions[2], t)
|
||||
validateAction(client.FakeAction{Action: "delete-pod", Value: "pod-2"}, fakeClient.Actions[3], t)
|
||||
validateAction(client.FakeAction{Action: "list-pods"}, fakeClient.Actions[4], t)
|
||||
}
|
||||
|
||||
func TestUpdateNoPods(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user