mirror of https://github.com/k3s-io/k3s
ReplicaSet: Use apps/v1 RS in e2e test.
parent
bb407944ee
commit
b27836032a
|
@ -242,7 +242,7 @@ func testRollingUpdateDeployment(f *framework.Framework) {
|
||||||
rsRevision := "3546343826724305832"
|
rsRevision := "3546343826724305832"
|
||||||
annotations := make(map[string]string)
|
annotations := make(map[string]string)
|
||||||
annotations[deploymentutil.RevisionAnnotation] = rsRevision
|
annotations[deploymentutil.RevisionAnnotation] = rsRevision
|
||||||
rs := newRS(rsName, replicas, rsPodLabels, NginxImageName, NginxImage)
|
rs := newExtensionsRS(rsName, replicas, rsPodLabels, NginxImageName, NginxImage)
|
||||||
rs.Annotations = annotations
|
rs.Annotations = annotations
|
||||||
framework.Logf("Creating replica set %q (going to be adopted)", rs.Name)
|
framework.Logf("Creating replica set %q (going to be adopted)", rs.Name)
|
||||||
_, err := c.ExtensionsV1beta1().ReplicaSets(ns).Create(rs)
|
_, err := c.ExtensionsV1beta1().ReplicaSets(ns).Create(rs)
|
||||||
|
@ -324,7 +324,7 @@ func testDeploymentCleanUpPolicy(f *framework.Framework) {
|
||||||
rsName := "test-cleanup-controller"
|
rsName := "test-cleanup-controller"
|
||||||
replicas := int32(1)
|
replicas := int32(1)
|
||||||
revisionHistoryLimit := utilpointer.Int32Ptr(0)
|
revisionHistoryLimit := utilpointer.Int32Ptr(0)
|
||||||
_, err := c.ExtensionsV1beta1().ReplicaSets(ns).Create(newRS(rsName, replicas, rsPodLabels, NginxImageName, NginxImage))
|
_, err := c.ExtensionsV1beta1().ReplicaSets(ns).Create(newExtensionsRS(rsName, replicas, rsPodLabels, NginxImageName, NginxImage))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
// Verify that the required pods have come up.
|
// Verify that the required pods have come up.
|
||||||
|
@ -395,7 +395,7 @@ func testRolloverDeployment(f *framework.Framework) {
|
||||||
|
|
||||||
rsName := "test-rollover-controller"
|
rsName := "test-rollover-controller"
|
||||||
rsReplicas := int32(1)
|
rsReplicas := int32(1)
|
||||||
_, err := c.ExtensionsV1beta1().ReplicaSets(ns).Create(newRS(rsName, rsReplicas, rsPodLabels, NginxImageName, NginxImage))
|
_, err := c.ExtensionsV1beta1().ReplicaSets(ns).Create(newExtensionsRS(rsName, rsReplicas, rsPodLabels, NginxImageName, NginxImage))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
// Verify that the required pods have come up.
|
// Verify that the required pods have come up.
|
||||||
err = framework.VerifyPodsRunning(c, ns, podName, false, rsReplicas)
|
err = framework.VerifyPodsRunning(c, ns, podName, false, rsReplicas)
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
apps "k8s.io/api/apps/v1"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
@ -36,7 +37,37 @@ import (
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newRS(rsName string, replicas int32, rsPodLabels map[string]string, imageName string, image string) *extensions.ReplicaSet {
|
func newRS(rsName string, replicas int32, rsPodLabels map[string]string, imageName string, image string) *apps.ReplicaSet {
|
||||||
|
zero := int64(0)
|
||||||
|
return &apps.ReplicaSet{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: rsName,
|
||||||
|
},
|
||||||
|
Spec: apps.ReplicaSetSpec{
|
||||||
|
Selector: &metav1.LabelSelector{
|
||||||
|
MatchLabels: rsPodLabels,
|
||||||
|
},
|
||||||
|
Replicas: &replicas,
|
||||||
|
Template: v1.PodTemplateSpec{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Labels: rsPodLabels,
|
||||||
|
},
|
||||||
|
Spec: v1.PodSpec{
|
||||||
|
TerminationGracePeriodSeconds: &zero,
|
||||||
|
Containers: []v1.Container{
|
||||||
|
{
|
||||||
|
Name: imageName,
|
||||||
|
Image: image,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(#55714): Remove this when Deployment tests use apps/v1 ReplicaSet.
|
||||||
|
func newExtensionsRS(rsName string, replicas int32, rsPodLabels map[string]string, imageName string, image string) *extensions.ReplicaSet {
|
||||||
zero := int64(0)
|
zero := int64(0)
|
||||||
return &extensions.ReplicaSet{
|
return &extensions.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
@ -111,7 +142,7 @@ func testReplicaSetServeImageOrFail(f *framework.Framework, test string, image s
|
||||||
framework.Logf("Creating ReplicaSet %s", name)
|
framework.Logf("Creating ReplicaSet %s", name)
|
||||||
newRS := newRS(name, replicas, map[string]string{"name": name}, name, image)
|
newRS := newRS(name, replicas, map[string]string{"name": name}, name, image)
|
||||||
newRS.Spec.Template.Spec.Containers[0].Ports = []v1.ContainerPort{{ContainerPort: 9376}}
|
newRS.Spec.Template.Spec.Containers[0].Ports = []v1.ContainerPort{{ContainerPort: 9376}}
|
||||||
_, err := f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).Create(newRS)
|
_, err := f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).Create(newRS)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
// Check that pods for the new RS were created.
|
// Check that pods for the new RS were created.
|
||||||
|
@ -187,14 +218,14 @@ func testReplicaSetConditionCheck(f *framework.Framework) {
|
||||||
|
|
||||||
By(fmt.Sprintf("Creating replica set %q that asks for more than the allowed pod quota", name))
|
By(fmt.Sprintf("Creating replica set %q that asks for more than the allowed pod quota", name))
|
||||||
rs := newRS(name, 3, map[string]string{"name": name}, NginxImageName, NginxImage)
|
rs := newRS(name, 3, map[string]string{"name": name}, NginxImageName, NginxImage)
|
||||||
rs, err = c.ExtensionsV1beta1().ReplicaSets(namespace).Create(rs)
|
rs, err = c.AppsV1().ReplicaSets(namespace).Create(rs)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By(fmt.Sprintf("Checking replica set %q has the desired failure condition set", name))
|
By(fmt.Sprintf("Checking replica set %q has the desired failure condition set", name))
|
||||||
generation := rs.Generation
|
generation := rs.Generation
|
||||||
conditions := rs.Status.Conditions
|
conditions := rs.Status.Conditions
|
||||||
err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
|
err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
|
||||||
rs, err = c.ExtensionsV1beta1().ReplicaSets(namespace).Get(name, metav1.GetOptions{})
|
rs, err = c.AppsV1().ReplicaSets(namespace).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -204,7 +235,7 @@ func testReplicaSetConditionCheck(f *framework.Framework) {
|
||||||
}
|
}
|
||||||
conditions = rs.Status.Conditions
|
conditions = rs.Status.Conditions
|
||||||
|
|
||||||
cond := replicaset.GetCondition(rs.Status, extensions.ReplicaSetReplicaFailure)
|
cond := replicaset.GetCondition(rs.Status, apps.ReplicaSetReplicaFailure)
|
||||||
return cond != nil, nil
|
return cond != nil, nil
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -214,7 +245,7 @@ func testReplicaSetConditionCheck(f *framework.Framework) {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By(fmt.Sprintf("Scaling down replica set %q to satisfy pod quota", name))
|
By(fmt.Sprintf("Scaling down replica set %q to satisfy pod quota", name))
|
||||||
rs, err = framework.UpdateReplicaSetWithRetries(c, namespace, name, func(update *extensions.ReplicaSet) {
|
rs, err = framework.UpdateReplicaSetWithRetries(c, namespace, name, func(update *apps.ReplicaSet) {
|
||||||
x := int32(2)
|
x := int32(2)
|
||||||
update.Spec.Replicas = &x
|
update.Spec.Replicas = &x
|
||||||
})
|
})
|
||||||
|
@ -224,7 +255,7 @@ func testReplicaSetConditionCheck(f *framework.Framework) {
|
||||||
generation = rs.Generation
|
generation = rs.Generation
|
||||||
conditions = rs.Status.Conditions
|
conditions = rs.Status.Conditions
|
||||||
err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
|
err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
|
||||||
rs, err = c.ExtensionsV1beta1().ReplicaSets(namespace).Get(name, metav1.GetOptions{})
|
rs, err = c.AppsV1().ReplicaSets(namespace).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -234,7 +265,7 @@ func testReplicaSetConditionCheck(f *framework.Framework) {
|
||||||
}
|
}
|
||||||
conditions = rs.Status.Conditions
|
conditions = rs.Status.Conditions
|
||||||
|
|
||||||
cond := replicaset.GetCondition(rs.Status, extensions.ReplicaSetReplicaFailure)
|
cond := replicaset.GetCondition(rs.Status, apps.ReplicaSetReplicaFailure)
|
||||||
return cond == nil, nil
|
return cond == nil, nil
|
||||||
})
|
})
|
||||||
if err == wait.ErrWaitTimeout {
|
if err == wait.ErrWaitTimeout {
|
||||||
|
@ -267,7 +298,7 @@ func testRSAdoptMatchingAndReleaseNotMatching(f *framework.Framework) {
|
||||||
replicas := int32(1)
|
replicas := int32(1)
|
||||||
rsSt := newRS(name, replicas, map[string]string{"name": name}, name, NginxImageName)
|
rsSt := newRS(name, replicas, map[string]string{"name": name}, name, NginxImageName)
|
||||||
rsSt.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{"name": name}}
|
rsSt.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{"name": name}}
|
||||||
rs, err := f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).Create(rsSt)
|
rs, err := f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).Create(rsSt)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("Then the orphan pod is adopted")
|
By("Then the orphan pod is adopted")
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
|
|
||||||
|
apps "k8s.io/api/apps/v1"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -33,7 +34,7 @@ import (
|
||||||
|
|
||||||
type updateRsFunc func(d *extensions.ReplicaSet)
|
type updateRsFunc func(d *extensions.ReplicaSet)
|
||||||
|
|
||||||
func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate testutils.UpdateReplicaSetFunc) (*extensions.ReplicaSet, error) {
|
func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate testutils.UpdateReplicaSetFunc) (*apps.ReplicaSet, error) {
|
||||||
return testutils.UpdateReplicaSetWithRetries(c, namespace, name, applyUpdate, Logf, Poll, pollShortTimeout)
|
return testutils.UpdateReplicaSetWithRetries(c, namespace, name, applyUpdate, Logf, Poll, pollShortTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +127,8 @@ func RunReplicaSet(config testutils.ReplicaSetConfig) error {
|
||||||
return testutils.RunReplicaSet(config)
|
return testutils.RunReplicaSet(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewReplicaSet(name, namespace string, replicas int32, podLabels map[string]string, imageName, image string) *extensions.ReplicaSet {
|
func NewReplicaSet(name, namespace string, replicas int32, podLabels map[string]string, imageName, image string) *apps.ReplicaSet {
|
||||||
return &extensions.ReplicaSet{
|
return &apps.ReplicaSet{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
Kind: "ReplicaSet",
|
Kind: "ReplicaSet",
|
||||||
APIVersion: "extensions/v1beta1",
|
APIVersion: "extensions/v1beta1",
|
||||||
|
@ -136,7 +137,7 @@ func NewReplicaSet(name, namespace string, replicas int32, podLabels map[string]
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &metav1.LabelSelector{
|
||||||
MatchLabels: podLabels,
|
MatchLabels: podLabels,
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
apps "k8s.io/api/apps/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
@ -54,7 +54,7 @@ func (r *ReplicaSetUpgradeTest) Setup(f *framework.Framework) {
|
||||||
|
|
||||||
By(fmt.Sprintf("Creating replicaset %s in namespace %s", rsName, ns))
|
By(fmt.Sprintf("Creating replicaset %s in namespace %s", rsName, ns))
|
||||||
replicaSet := framework.NewReplicaSet(rsName, ns, 1, map[string]string{"test": "upgrade"}, "nginx", nginxImage)
|
replicaSet := framework.NewReplicaSet(rsName, ns, 1, map[string]string{"test": "upgrade"}, "nginx", nginxImage)
|
||||||
rs, err := c.ExtensionsV1beta1().ReplicaSets(ns).Create(replicaSet)
|
rs, err := c.AppsV1().ReplicaSets(ns).Create(replicaSet)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By(fmt.Sprintf("Waiting for replicaset %s to have all of its replicas ready", rsName))
|
By(fmt.Sprintf("Waiting for replicaset %s to have all of its replicas ready", rsName))
|
||||||
|
@ -67,7 +67,7 @@ func (r *ReplicaSetUpgradeTest) Setup(f *framework.Framework) {
|
||||||
func (r *ReplicaSetUpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upgrade upgrades.UpgradeType) {
|
func (r *ReplicaSetUpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upgrade upgrades.UpgradeType) {
|
||||||
c := f.ClientSet
|
c := f.ClientSet
|
||||||
ns := f.Namespace.Name
|
ns := f.Namespace.Name
|
||||||
rsClient := c.ExtensionsV1beta1().ReplicaSets(ns)
|
rsClient := c.AppsV1().ReplicaSets(ns)
|
||||||
|
|
||||||
// Block until upgrade is done
|
// Block until upgrade is done
|
||||||
By(fmt.Sprintf("Waiting for upgrade to finish before checking replicaset %s", rsName))
|
By(fmt.Sprintf("Waiting for upgrade to finish before checking replicaset %s", rsName))
|
||||||
|
@ -86,7 +86,7 @@ func (r *ReplicaSetUpgradeTest) Test(f *framework.Framework, done <-chan struct{
|
||||||
|
|
||||||
// Verify the upgraded RS is active by scaling up the RS to scaleNum and ensuring all pods are Ready
|
// Verify the upgraded RS is active by scaling up the RS to scaleNum and ensuring all pods are Ready
|
||||||
By(fmt.Sprintf("Scaling up replicaset %s to %d", rsName, scaleNum))
|
By(fmt.Sprintf("Scaling up replicaset %s to %d", rsName, scaleNum))
|
||||||
_, err = framework.UpdateReplicaSetWithRetries(c, ns, rsName, func(rs *extensions.ReplicaSet) {
|
_, err = framework.UpdateReplicaSetWithRetries(c, ns, rsName, func(rs *apps.ReplicaSet) {
|
||||||
*rs.Spec.Replicas = scaleNum
|
*rs.Spec.Replicas = scaleNum
|
||||||
})
|
})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
|
@ -165,7 +165,7 @@ func dcSetup(t *testing.T) (*httptest.Server, framework.CloseFunc, *replicaset.R
|
||||||
t.Fatalf("error creating Deployment controller: %v", err)
|
t.Fatalf("error creating Deployment controller: %v", err)
|
||||||
}
|
}
|
||||||
rm := replicaset.NewReplicaSetController(
|
rm := replicaset.NewReplicaSetController(
|
||||||
informers.Extensions().V1beta1().ReplicaSets(),
|
informers.Apps().V1().ReplicaSets(),
|
||||||
informers.Core().V1().Pods(),
|
informers.Core().V1().Pods(),
|
||||||
clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "replicaset-controller")),
|
clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "replicaset-controller")),
|
||||||
replicaset.BurstReplicas,
|
replicaset.BurstReplicas,
|
||||||
|
@ -364,12 +364,12 @@ func (d *deploymentTester) expectNewReplicaSet() (*v1beta1.ReplicaSet, error) {
|
||||||
return rs, nil
|
return rs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deploymentTester) updateReplicaSet(name string, applyUpdate testutil.UpdateReplicaSetFunc) (*v1beta1.ReplicaSet, error) {
|
func (d *deploymentTester) updateReplicaSet(name string, applyUpdate testutil.UpdateExtensionsReplicaSetFunc) (*v1beta1.ReplicaSet, error) {
|
||||||
return testutil.UpdateReplicaSetWithRetries(d.c, d.deployment.Namespace, name, applyUpdate, d.t.Logf, pollInterval, pollTimeout)
|
return testutil.UpdateExtensionsReplicaSetWithRetries(d.c, d.deployment.Namespace, name, applyUpdate, d.t.Logf, pollInterval, pollTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deploymentTester) updateReplicaSetStatus(name string, applyStatusUpdate testutil.UpdateReplicaSetFunc) (*v1beta1.ReplicaSet, error) {
|
func (d *deploymentTester) updateReplicaSetStatus(name string, applyStatusUpdate testutil.UpdateExtensionsReplicaSetFunc) (*v1beta1.ReplicaSet, error) {
|
||||||
return testutil.UpdateReplicaSetStatusWithRetries(d.c, d.deployment.Namespace, name, applyStatusUpdate, d.t.Logf, pollInterval, pollTimeout)
|
return testutil.UpdateExtensionsReplicaSetStatusWithRetries(d.c, d.deployment.Namespace, name, applyStatusUpdate, d.t.Logf, pollInterval, pollTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// waitForDeploymentRollbackCleared waits for deployment either started rolling back or doesn't need to rollback.
|
// waitForDeploymentRollbackCleared waits for deployment either started rolling back or doesn't need to rollback.
|
||||||
|
|
|
@ -151,7 +151,7 @@ func rmSetup(t *testing.T) (*httptest.Server, framework.CloseFunc, *replicaset.R
|
||||||
informers := informers.NewSharedInformerFactory(clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "rs-informers")), resyncPeriod)
|
informers := informers.NewSharedInformerFactory(clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "rs-informers")), resyncPeriod)
|
||||||
|
|
||||||
rm := replicaset.NewReplicaSetController(
|
rm := replicaset.NewReplicaSetController(
|
||||||
informers.Extensions().V1beta1().ReplicaSets(),
|
informers.Apps().V1().ReplicaSets(),
|
||||||
informers.Core().V1().Pods(),
|
informers.Core().V1().Pods(),
|
||||||
clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "replicaset-controller")),
|
clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "replicaset-controller")),
|
||||||
replicaset.BurstReplicas,
|
replicaset.BurstReplicas,
|
||||||
|
|
|
@ -21,15 +21,43 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
apps "k8s.io/api/apps/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateReplicaSetFunc func(d *extensions.ReplicaSet)
|
type UpdateReplicaSetFunc func(d *apps.ReplicaSet)
|
||||||
|
|
||||||
func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*extensions.ReplicaSet, error) {
|
func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*apps.ReplicaSet, error) {
|
||||||
|
var rs *apps.ReplicaSet
|
||||||
|
var updateErr error
|
||||||
|
pollErr := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) {
|
||||||
|
var err error
|
||||||
|
if rs, err = c.AppsV1().ReplicaSets(namespace).Get(name, metav1.GetOptions{}); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
// Apply the update, then attempt to push it to the apiserver.
|
||||||
|
applyUpdate(rs)
|
||||||
|
if rs, err = c.AppsV1().ReplicaSets(namespace).Update(rs); err == nil {
|
||||||
|
logf("Updating replica set %q", name)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
updateErr = err
|
||||||
|
return false, nil
|
||||||
|
})
|
||||||
|
if pollErr == wait.ErrWaitTimeout {
|
||||||
|
pollErr = fmt.Errorf("couldn't apply the provided updated to replicaset %q: %v", name, updateErr)
|
||||||
|
}
|
||||||
|
return rs, pollErr
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(#55714): Remove this after Deployment tests use apps/v1 ReplicaSet.
|
||||||
|
type UpdateExtensionsReplicaSetFunc func(d *extensions.ReplicaSet)
|
||||||
|
|
||||||
|
// TODO(#55714): Remove this after Deployment tests use apps/v1 ReplicaSet.
|
||||||
|
func UpdateExtensionsReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateExtensionsReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*extensions.ReplicaSet, error) {
|
||||||
var rs *extensions.ReplicaSet
|
var rs *extensions.ReplicaSet
|
||||||
var updateErr error
|
var updateErr error
|
||||||
pollErr := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) {
|
pollErr := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) {
|
||||||
|
@ -67,7 +95,7 @@ func WaitRSStable(t *testing.T, clientSet clientset.Interface, rs *extensions.Re
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateReplicaSetStatusWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*extensions.ReplicaSet, error) {
|
func UpdateExtensionsReplicaSetStatusWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateExtensionsReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*extensions.ReplicaSet, error) {
|
||||||
var rs *extensions.ReplicaSet
|
var rs *extensions.ReplicaSet
|
||||||
var updateErr error
|
var updateErr error
|
||||||
pollErr := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) {
|
pollErr := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) {
|
||||||
|
|
Loading…
Reference in New Issue