Commit 0a062c5b authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #11942 from ironcladlou/rolling-update-availability

Auto commit by PR queue bot
parents fa9339d9 da5e4d7b
......@@ -680,12 +680,6 @@ __EOF__
kubectl delete pod valid-pod "${kube_flags[@]}"
kubectl delete service frontend{,-2,-3,-4,-5} "${kube_flags[@]}"
### Perform a rolling update with --image
# Command
kubectl rolling-update frontend --image=kubernetes/pause --update-period=10ns --poll-interval=10ms "${kube_flags[@]}"
# Post-condition: current image IS kubernetes/pause
kube::test::get_object_assert 'rc frontend' '{{range \$c:=$rc_container_image_field}} {{\$c.image}} {{end}}' ' +kubernetes/pause +'
### Delete replication controller with id
# Pre-condition: frontend replication controller is running
kube::test::get_object_assert rc "{{range.items}}{{$id_field}}:{{end}}" 'frontend:'
......
......@@ -44,8 +44,13 @@ func (c *FakePods) List(label labels.Selector, field fields.Selector) (*api.PodL
if obj == nil {
return nil, err
}
return obj.(*api.PodList), err
list := &api.PodList{}
for _, pod := range obj.(*api.PodList).Items {
if label.Matches(labels.Set(pod.Labels)) {
list.Items = append(list.Items, pod)
}
}
return list, err
}
func (c *FakePods) Create(pod *api.Pod) (*api.Pod, error) {
......
......@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/util"
)
// RollingUpdateOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
......@@ -148,8 +149,6 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
return err
}
updaterClient := kubectl.NewRollingUpdaterClient(client)
var newRc *api.ReplicationController
// fetch rc
oldRc, err := client.ReplicationControllers(cmdNamespace).Get(oldName)
......@@ -158,11 +157,11 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
return err
}
// We're in the middle of a rename, look for an RC with a source annotation of oldName
newRc, err := kubectl.FindSourceController(updaterClient, cmdNamespace, oldName)
newRc, err := kubectl.FindSourceController(client, cmdNamespace, oldName)
if err != nil {
return err
}
return kubectl.Rename(kubectl.NewRollingUpdaterClient(client), newRc, oldName)
return kubectl.Rename(client, newRc, oldName)
}
var keepOldName bool
......@@ -242,7 +241,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
filename, oldName)
}
updater := kubectl.NewRollingUpdater(newRc.Namespace, updaterClient)
updater := kubectl.NewRollingUpdater(newRc.Namespace, client)
// To successfully pull off a rolling update the new and old rc have to differ
// by at least one selector. Every new pod should have the selector and every
......@@ -286,7 +285,8 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
Interval: interval,
Timeout: timeout,
CleanupPolicy: updateCleanupPolicy,
UpdateAcceptor: kubectl.DefaultUpdateAcceptor,
MaxUnavailable: util.NewIntOrStringFromInt(0),
MaxSurge: util.NewIntOrStringFromInt(1),
}
if cmdutil.GetFlagBool(cmd, "rollback") {
kubectl.AbortRollingUpdate(config)
......
......@@ -90,7 +90,6 @@ var _ = Describe("Kubectl client", func() {
nautilusPath = filepath.Join(updateDemoRoot, "nautilus-rc.yaml")
kittenPath = filepath.Join(updateDemoRoot, "kitten-rc.yaml")
})
It("should create and stop a replication controller", func() {
defer cleanup(nautilusPath, ns, updateDemoSelector)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment