mirror of https://github.com/k3s-io/k3s
resize: Use Resize method
parent
2e3c40b5c2
commit
69a96f3ea1
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
|
||||
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -105,15 +104,11 @@ func RunResize(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||
resourceVersion := cmdutil.GetFlagString(cmd, "resource-version")
|
||||
currentSize := cmdutil.GetFlagInt(cmd, "current-replicas")
|
||||
precondition := &kubectl.ResizePrecondition{currentSize, resourceVersion}
|
||||
cond := kubectl.ResizeCondition(resizer, precondition, info.Namespace, info.Name, uint(count))
|
||||
retry := &kubectl.RetryParams{Interval: retryFrequency, Timeout: retryTimeout}
|
||||
|
||||
msg := "resized"
|
||||
if err = wait.Poll(retryFrequency, retryTimeout, cond); err != nil {
|
||||
msg = fmt.Sprintf("Failed to resize controller in spite of retrying for %s", retryTimeout)
|
||||
if err != nil {
|
||||
if err := resizer.Resize(info.Namespace, info.Name, uint(count), precondition, retry, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", msg)
|
||||
fmt.Fprint(out, "resized\n")
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ type ReplicationControllerResizer struct {
|
|||
}
|
||||
|
||||
type RetryParams struct {
|
||||
interval, timeout time.Duration
|
||||
Interval, Timeout time.Duration
|
||||
}
|
||||
|
||||
// ResizeCondition is a closure around Resize that facilitates retries via util.wait
|
||||
|
@ -149,18 +149,16 @@ func (resizer *ReplicationControllerResizer) Resize(namespace, name string, newS
|
|||
}
|
||||
if retry == nil {
|
||||
// Make it try only once, immediately
|
||||
retry = &RetryParams{interval: time.Millisecond, timeout: time.Millisecond}
|
||||
retry = &RetryParams{Interval: time.Millisecond, Timeout: time.Millisecond}
|
||||
}
|
||||
cond := ResizeCondition(resizer, preconditions, namespace, name, newSize)
|
||||
if err := wait.Poll(retry.interval, retry.timeout, cond); err != nil {
|
||||
if err := wait.Poll(retry.Interval, retry.Timeout, cond); err != nil {
|
||||
return err
|
||||
}
|
||||
if waitForReplicas != nil {
|
||||
rc := &api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: namespace, Name: name}}
|
||||
if err := wait.Poll(waitForReplicas.interval, waitForReplicas.timeout,
|
||||
resizer.c.ControllerHasDesiredReplicas(rc)); err != nil {
|
||||
return err
|
||||
}
|
||||
return wait.Poll(waitForReplicas.Interval, waitForReplicas.Timeout,
|
||||
resizer.c.ControllerHasDesiredReplicas(rc))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue