mirror of https://github.com/k3s-io/k3s
Fix printer hack to get a versioned client
parent
1910b5a1dd
commit
83895daed1
|
@ -355,7 +355,7 @@ func (dc *DeploymentController) deletePod(obj interface{}) {
|
|||
glog.V(4).Infof("Pod %s deleted.", pod.Name)
|
||||
if d := dc.getDeploymentForPod(pod); d != nil && d.Spec.Strategy.Type == extensions.RecreateDeploymentStrategyType {
|
||||
// Sync if this Deployment now has no more Pods.
|
||||
rsList, err := util.ListReplicaSets(d, util.RsListFromClient(dc.client))
|
||||
rsList, err := util.ListReplicaSets(d, util.RsListFromClient(dc.client.ExtensionsV1beta1()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
corelisters "k8s.io/client-go/listers/core/v1"
|
||||
extensionslisters "k8s.io/client-go/listers/extensions/v1beta1"
|
||||
"k8s.io/client-go/util/integer"
|
||||
|
@ -497,7 +498,7 @@ func getReplicaSetFraction(rs extensions.ReplicaSet, d extensions.Deployment) in
|
|||
// GetAllReplicaSets returns the old and new replica sets targeted by the given Deployment. It gets PodList and ReplicaSetList from client interface.
|
||||
// Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets.
|
||||
// The third returned value is the new replica set, and it may be nil if it doesn't exist yet.
|
||||
func GetAllReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, *extensions.ReplicaSet, error) {
|
||||
func GetAllReplicaSets(deployment *extensions.Deployment, c extensionsv1beta1.ExtensionsV1beta1Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, *extensions.ReplicaSet, error) {
|
||||
rsList, err := ListReplicaSets(deployment, RsListFromClient(c))
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
@ -515,7 +516,7 @@ func GetAllReplicaSets(deployment *extensions.Deployment, c clientset.Interface)
|
|||
|
||||
// GetOldReplicaSets returns the old replica sets targeted by the given Deployment; get PodList and ReplicaSetList from client interface.
|
||||
// Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets.
|
||||
func GetOldReplicaSets(deployment *extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) {
|
||||
func GetOldReplicaSets(deployment *extensions.Deployment, c extensionsv1beta1.ExtensionsV1beta1Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) {
|
||||
rsList, err := ListReplicaSets(deployment, RsListFromClient(c))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -525,7 +526,7 @@ func GetOldReplicaSets(deployment *extensions.Deployment, c clientset.Interface)
|
|||
|
||||
// GetNewReplicaSet returns a replica set that matches the intent of the given deployment; get ReplicaSetList from client interface.
|
||||
// Returns nil if the new replica set doesn't exist yet.
|
||||
func GetNewReplicaSet(deployment *extensions.Deployment, c clientset.Interface) (*extensions.ReplicaSet, error) {
|
||||
func GetNewReplicaSet(deployment *extensions.Deployment, c extensionsv1beta1.ExtensionsV1beta1Interface) (*extensions.ReplicaSet, error) {
|
||||
rsList, err := ListReplicaSets(deployment, RsListFromClient(c))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -534,9 +535,9 @@ func GetNewReplicaSet(deployment *extensions.Deployment, c clientset.Interface)
|
|||
}
|
||||
|
||||
// RsListFromClient returns an rsListFunc that wraps the given client.
|
||||
func RsListFromClient(c clientset.Interface) RsListFunc {
|
||||
func RsListFromClient(c extensionsv1beta1.ExtensionsV1beta1Interface) RsListFunc {
|
||||
return func(namespace string, options metav1.ListOptions) ([]*extensions.ReplicaSet, error) {
|
||||
rsList, err := c.Extensions().ReplicaSets(namespace).List(options)
|
||||
rsList, err := c.ReplicaSets(namespace).List(options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ func TestGetNewRS(t *testing.T) {
|
|||
fakeClient = addListRSReactor(fakeClient, test.objs[1])
|
||||
fakeClient = addUpdatePodsReactor(fakeClient)
|
||||
fakeClient = addUpdateRSReactor(fakeClient)
|
||||
rs, err := GetNewReplicaSet(&newDeployment, fakeClient)
|
||||
rs, err := GetNewReplicaSet(&newDeployment, fakeClient.ExtensionsV1beta1())
|
||||
if err != nil {
|
||||
t.Errorf("In test case %s, got unexpected error %v", test.Name, err)
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ func TestGetOldRSs(t *testing.T) {
|
|||
fakeClient = addListRSReactor(fakeClient, test.objs[0])
|
||||
fakeClient = addGetRSReactor(fakeClient, test.objs[0])
|
||||
fakeClient = addUpdateRSReactor(fakeClient)
|
||||
_, rss, err := GetOldReplicaSets(&newDeployment, fakeClient)
|
||||
_, rss, err := GetOldReplicaSets(&newDeployment, fakeClient.ExtensionsV1beta1())
|
||||
if err != nil {
|
||||
t.Errorf("In test case %s, got unexpected error %v", test.Name, err)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
||||
externalclientset "k8s.io/client-go/kubernetes"
|
||||
clientappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
||||
clientextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
k8s_api_v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
|
@ -71,12 +72,12 @@ type DeploymentHistoryViewer struct {
|
|||
// ViewHistory returns a revision-to-replicaset map as the revision history of a deployment
|
||||
// TODO: this should be a describer
|
||||
func (h *DeploymentHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error) {
|
||||
versionedClient := versionedClientsetForDeployment(h.c)
|
||||
deployment, err := versionedClient.Extensions().Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
versionedExtensionsClient := versionedExtensionsClientV1beta1(h.c)
|
||||
deployment, err := versionedExtensionsClient.Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to retrieve deployment %s: %v", name, err)
|
||||
}
|
||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(deployment, versionedClient)
|
||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(deployment, versionedExtensionsClient)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to retrieve replica sets from deployment %s: %v", name, err)
|
||||
}
|
||||
|
@ -153,8 +154,9 @@ type DaemonSetHistoryViewer struct {
|
|||
// ViewHistory returns a revision-to-history map as the revision history of a deployment
|
||||
// TODO: this should be a describer
|
||||
func (h *DaemonSetHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error) {
|
||||
versionedClient := versionedClientsetForDaemonSet(h.c)
|
||||
ds, allHistory, err := controlledHistories(versionedClient, namespace, name)
|
||||
versionedExtensionsClient := versionedExtensionsClientV1beta1(h.c)
|
||||
versionedAppsClient := versionedAppsClientV1beta1(h.c)
|
||||
ds, allHistory, err := controlledHistories(versionedExtensionsClient, versionedAppsClient, namespace, name)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to find history controlled by DaemonSet %s: %v", name, err)
|
||||
}
|
||||
|
@ -256,8 +258,8 @@ func (h *StatefulSetHistoryViewer) ViewHistory(namespace, name string, revision
|
|||
}
|
||||
|
||||
// controlledHistories returns all ControllerRevisions controlled by the given DaemonSet
|
||||
func controlledHistories(c externalclientset.Interface, namespace, name string) (*extensionsv1beta1.DaemonSet, []*appsv1beta1.ControllerRevision, error) {
|
||||
ds, err := c.ExtensionsV1beta1().DaemonSets(namespace).Get(name, metav1.GetOptions{})
|
||||
func controlledHistories(extensions clientextensionsv1beta1.ExtensionsV1beta1Interface, apps clientappsv1beta1.AppsV1beta1Interface, namespace, name string) (*extensionsv1beta1.DaemonSet, []*appsv1beta1.ControllerRevision, error) {
|
||||
ds, err := extensions.DaemonSets(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to retrieve DaemonSet %s: %v", name, err)
|
||||
}
|
||||
|
@ -266,7 +268,7 @@ func controlledHistories(c externalclientset.Interface, namespace, name string)
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
historyList, err := c.AppsV1beta1().ControllerRevisions(ds.Namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
|
||||
historyList, err := apps.ControllerRevisions(ds.Namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
|
@ -151,8 +151,8 @@ func simpleDryRun(deployment *extensions.Deployment, c clientset.Interface, toRe
|
|||
if err := api.Scheme.Convert(deployment, externalDeployment, nil); err != nil {
|
||||
return "", fmt.Errorf("failed to convert deployment, %v", err)
|
||||
}
|
||||
versionedClient := versionedClientsetForDeployment(c)
|
||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(externalDeployment, versionedClient)
|
||||
versionedExtensionsClient := versionedExtensionsClientV1beta1(c)
|
||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(externalDeployment, versionedExtensionsClient)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to retrieve replica sets from deployment %s: %v", deployment.Name, err)
|
||||
}
|
||||
|
@ -221,8 +221,9 @@ func (r *DaemonSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations ma
|
|||
if !ok {
|
||||
return "", fmt.Errorf("passed object is not a DaemonSet: %#v", obj)
|
||||
}
|
||||
versionedClient := versionedClientsetForDaemonSet(r.c)
|
||||
versionedDS, allHistory, err := controlledHistories(versionedClient, ds.Namespace, ds.Name)
|
||||
versionedExtensionsClient := versionedExtensionsClientV1beta1(r.c)
|
||||
versionedAppsClient := versionedAppsClientV1beta1(r.c)
|
||||
versionedDS, allHistory, err := controlledHistories(versionedExtensionsClient, versionedAppsClient, ds.Namespace, ds.Name)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to find history controlled by DaemonSet %s: %v", ds.Name, err)
|
||||
}
|
||||
|
@ -275,7 +276,7 @@ func (r *DaemonSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations ma
|
|||
}
|
||||
|
||||
// Restore revision
|
||||
if _, err = versionedClient.ExtensionsV1beta1().DaemonSets(ds.Namespace).Patch(ds.Name, types.StrategicMergePatchType, toHistory.Data.Raw); err != nil {
|
||||
if _, err = versionedExtensionsClient.DaemonSets(ds.Namespace).Patch(ds.Name, types.StrategicMergePatchType, toHistory.Data.Raw); err != nil {
|
||||
return "", fmt.Errorf("failed restoring revision %d: %v", toRevision, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,29 +17,23 @@ limitations under the License.
|
|||
package kubectl
|
||||
|
||||
import (
|
||||
externalclientset "k8s.io/client-go/kubernetes"
|
||||
apps "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
||||
core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
extensions "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
clientappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
||||
clientextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
internalclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
)
|
||||
|
||||
func versionedClientsetForDeployment(internalClient internalclientset.Interface) externalclientset.Interface {
|
||||
// TODO: get rid of this and plumb the caller correctly
|
||||
func versionedExtensionsClientV1beta1(internalClient internalclientset.Interface) clientextensionsv1beta1.ExtensionsV1beta1Interface {
|
||||
if internalClient == nil {
|
||||
return &externalclientset.Clientset{}
|
||||
}
|
||||
return &externalclientset.Clientset{
|
||||
CoreV1Client: core.New(internalClient.Core().RESTClient()),
|
||||
ExtensionsV1beta1Client: extensions.New(internalClient.Extensions().RESTClient()),
|
||||
return &clientextensionsv1beta1.ExtensionsV1beta1Client{}
|
||||
}
|
||||
return clientextensionsv1beta1.New(internalClient.Extensions().RESTClient())
|
||||
}
|
||||
|
||||
func versionedClientsetForDaemonSet(internalClient internalclientset.Interface) externalclientset.Interface {
|
||||
// TODO: get rid of this and plumb the caller correctly
|
||||
func versionedAppsClientV1beta1(internalClient internalclientset.Interface) clientappsv1beta1.AppsV1beta1Interface {
|
||||
if internalClient == nil {
|
||||
return &externalclientset.Clientset{}
|
||||
}
|
||||
return &externalclientset.Clientset{
|
||||
AppsV1beta1Client: apps.New(internalClient.Apps().RESTClient()),
|
||||
ExtensionsV1beta1Client: extensions.New(internalClient.Extensions().RESTClient()),
|
||||
return &clientappsv1beta1.AppsV1beta1Client{}
|
||||
}
|
||||
return clientappsv1beta1.New(internalClient.Apps().RESTClient())
|
||||
}
|
||||
|
|
|
@ -46,9 +46,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/client-go/dynamic"
|
||||
versionedclientset "k8s.io/client-go/kubernetes"
|
||||
coreclientset "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
extensionsclientset "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
clientextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
federation "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||
fedclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_clientset"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
|
@ -141,12 +139,12 @@ func describerMap(c clientset.Interface) map[schema.GroupKind]printers.Describer
|
|||
extensions.Kind("PodSecurityPolicy"): &PodSecurityPolicyDescriber{c},
|
||||
autoscaling.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c},
|
||||
extensions.Kind("DaemonSet"): &DaemonSetDescriber{c},
|
||||
extensions.Kind("Deployment"): &DeploymentDescriber{c, versionedClientsetForDeployment(c)},
|
||||
extensions.Kind("Deployment"): &DeploymentDescriber{c, versionedExtensionsClientV1beta1(c)},
|
||||
extensions.Kind("Ingress"): &IngressDescriber{c},
|
||||
batch.Kind("Job"): &JobDescriber{c},
|
||||
batch.Kind("CronJob"): &CronJobDescriber{c},
|
||||
apps.Kind("StatefulSet"): &StatefulSetDescriber{c},
|
||||
apps.Kind("Deployment"): &DeploymentDescriber{c, versionedClientsetForDeployment(c)},
|
||||
apps.Kind("Deployment"): &DeploymentDescriber{c, versionedExtensionsClientV1beta1(c)},
|
||||
apps.Kind("DaemonSet"): &DaemonSetDescriber{c},
|
||||
certificates.Kind("CertificateSigningRequest"): &CertificateSigningRequestDescriber{c},
|
||||
storage.Kind("StorageClass"): &StorageClassDescriber{c},
|
||||
|
@ -2836,11 +2834,11 @@ func DescribeEvents(el *api.EventList, w PrefixWriter) {
|
|||
// DeploymentDescriber generates information about a deployment.
|
||||
type DeploymentDescriber struct {
|
||||
clientset.Interface
|
||||
versionedClient versionedclientset.Interface
|
||||
extensionV1beta1Client clientextensionsv1beta1.ExtensionsV1beta1Interface
|
||||
}
|
||||
|
||||
func (dd *DeploymentDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (string, error) {
|
||||
d, err := dd.versionedClient.Extensions().Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
d, err := dd.extensionV1beta1Client.Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -2885,7 +2883,7 @@ func describeDeployment(d *versionedextension.Deployment, selector labels.Select
|
|||
w.Write(LEVEL_1, "%v \t%v\t%v\n", c.Type, c.Status, c.Reason)
|
||||
}
|
||||
}
|
||||
oldRSs, _, newRS, err := deploymentutil.GetAllReplicaSets(d, dd.versionedClient)
|
||||
oldRSs, _, newRS, err := deploymentutil.GetAllReplicaSets(d, dd.extensionV1beta1Client)
|
||||
if err == nil {
|
||||
w.Write(LEVEL_0, "OldReplicaSets:\t%s\n", printReplicaSetsByLabels(oldRSs))
|
||||
var newRSs []*versionedextension.ReplicaSet
|
||||
|
@ -3650,14 +3648,12 @@ func (list SortableVolumeMounts) Less(i, j int) bool {
|
|||
return list[i].MountPath < list[j].MountPath
|
||||
}
|
||||
|
||||
func versionedClientsetForDeployment(internalClient clientset.Interface) versionedclientset.Interface {
|
||||
// TODO: get rid of this and plumb the caller correctly
|
||||
func versionedExtensionsClientV1beta1(internalClient clientset.Interface) clientextensionsv1beta1.ExtensionsV1beta1Interface {
|
||||
if internalClient == nil {
|
||||
return &versionedclientset.Clientset{}
|
||||
}
|
||||
return &versionedclientset.Clientset{
|
||||
CoreV1Client: coreclientset.New(internalClient.Core().RESTClient()),
|
||||
ExtensionsV1beta1Client: extensionsclientset.New(internalClient.Extensions().RESTClient()),
|
||||
return &clientextensionsv1beta1.ExtensionsV1beta1Client{}
|
||||
}
|
||||
return clientextensionsv1beta1.New(internalClient.Extensions().RESTClient())
|
||||
}
|
||||
|
||||
var maxAnnotationLen = 200
|
||||
|
|
|
@ -774,7 +774,7 @@ func TestDescribeDeployment(t *testing.T) {
|
|||
},
|
||||
},
|
||||
})
|
||||
d := DeploymentDescriber{fake, versionedFake}
|
||||
d := DeploymentDescriber{fake, versionedFake.ExtensionsV1beta1()}
|
||||
out, err := d.Describe("foo", "bar", printers.DescriberSettings{ShowEvents: true})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@ -1267,7 +1267,7 @@ func TestDescribeEvents(t *testing.T) {
|
|||
Replicas: utilpointer.Int32Ptr(1),
|
||||
Selector: &metav1.LabelSelector{},
|
||||
},
|
||||
}),
|
||||
}).ExtensionsV1beta1(),
|
||||
},
|
||||
"EndpointsDescriber": &EndpointsDescriber{
|
||||
fake.NewSimpleClientset(&api.Endpoints{
|
||||
|
|
|
@ -186,7 +186,7 @@ func checkDeploymentRevision(c clientset.Interface, ns, deploymentName, revision
|
|||
deployment, err := c.Extensions().Deployments(ns).Get(deploymentName, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
// Check revision of the new replica set of this deployment
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(newRS).NotTo(Equal(nilRs))
|
||||
Expect(newRS.Annotations).NotTo(Equal(nil))
|
||||
|
@ -268,7 +268,7 @@ func testDeleteDeployment(f *framework.Framework) {
|
|||
|
||||
deployment, err := c.Extensions().Deployments(ns).Get(deploymentName, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(newRS).NotTo(Equal(nilRs))
|
||||
stopDeployment(c, internalClient, ns, deploymentName)
|
||||
|
@ -318,7 +318,7 @@ func testRollingUpdateDeployment(f *framework.Framework) {
|
|||
framework.Logf("Ensuring deployment %q has one old replica set (the one it adopted)", deploy.Name)
|
||||
deployment, err := c.Extensions().Deployments(ns).Get(deploymentName, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, allOldRSs, err := deploymentutil.GetOldReplicaSets(deployment, c)
|
||||
_, allOldRSs, err := deploymentutil.GetOldReplicaSets(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(allOldRSs)).Should(Equal(1))
|
||||
// The old RS should contain pod-template-hash in its selector, label, and template label
|
||||
|
@ -542,7 +542,7 @@ func testPausedDeployment(f *framework.Framework) {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
// Verify that there is no latest state realized for the new deployment.
|
||||
rs, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
rs, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(rs).To(Equal(nilRs))
|
||||
|
||||
|
@ -594,11 +594,11 @@ func testPausedDeployment(f *framework.Framework) {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
framework.Logf("Looking for new replicaset for paused deployment %q (there should be none)", deploymentName)
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(newRS).To(Equal(nilRs))
|
||||
|
||||
_, allOldRs, err := deploymentutil.GetOldReplicaSets(deployment, c)
|
||||
_, allOldRs, err := deploymentutil.GetOldReplicaSets(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
if len(allOldRs) != 1 {
|
||||
err = fmt.Errorf("expected an old replica set")
|
||||
|
@ -951,7 +951,7 @@ func testScalePausedDeployment(f *framework.Framework) {
|
|||
err = framework.WaitForObservedDeployment(c, ns, deploymentName, deployment.Generation)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
rs, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
rs, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*(rs.Spec.Replicas)).Should(Equal(newReplicas))
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ func testScaledRolloutDeployment(f *framework.Framework) {
|
|||
framework.Logf("Waiting for deployment %q to complete", deployment.Name)
|
||||
Expect(framework.WaitForDeploymentStatusValid(c, deployment)).NotTo(HaveOccurred())
|
||||
|
||||
first, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
first, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
// Update the deployment with a non-existent image so that the new replica set will be blocked.
|
||||
|
@ -1007,7 +1007,7 @@ func testScaledRolloutDeployment(f *framework.Framework) {
|
|||
}
|
||||
|
||||
framework.Logf("Checking that the replica sets for %q are synced", deploymentName)
|
||||
second, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
second, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
first, err = c.Extensions().ReplicaSets(first.Namespace).Get(first.Name, metav1.GetOptions{})
|
||||
|
@ -1070,7 +1070,7 @@ func testScaledRolloutDeployment(f *framework.Framework) {
|
|||
oldRs, err := c.Extensions().ReplicaSets(rs.Namespace).Get(rs.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
newRs, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
newRs, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
oldCond := replicaSetHasDesiredReplicas(c.Extensions(), oldRs)
|
||||
|
@ -1433,7 +1433,7 @@ func testDeploymentHashCollisionAvoidance(f *framework.Framework) {
|
|||
// once it has no owner reference, then recreate the Deployment if we ever proceed with
|
||||
// https://github.com/kubernetes/kubernetes/issues/44237
|
||||
framework.Logf("Mock a hash collision")
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
var nilRs *extensions.ReplicaSet
|
||||
Expect(newRS).NotTo(Equal(nilRs))
|
||||
|
|
|
@ -72,7 +72,7 @@ func WaitForDeploymentOldRSsNum(c clientset.Interface, ns, deploymentName string
|
|||
}
|
||||
d = deployment
|
||||
|
||||
_, oldRSs, err = deploymentutil.GetOldReplicaSets(deployment, c)
|
||||
_, oldRSs, err = deploymentutil.GetOldReplicaSets(deployment, c.ExtensionsV1beta1())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func WaitForDeploymentWithCondition(c clientset.Interface, ns, deploymentName, r
|
|||
})
|
||||
if pollErr == wait.ErrWaitTimeout {
|
||||
pollErr = fmt.Errorf("deployment %q never updated with the desired condition and reason: %v", deployment.Name, deployment.Status.Conditions)
|
||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(deployment, c)
|
||||
_, allOldRSs, newRS, err := deploymentutil.GetAllReplicaSets(deployment, c.ExtensionsV1beta1())
|
||||
if err == nil {
|
||||
logReplicaSetsOfDeployment(deployment, allOldRSs, newRS)
|
||||
logPodsOfDeployment(c, deployment, append(allOldRSs, newRS))
|
||||
|
@ -176,7 +176,7 @@ func WaitForDeploymentStatus(c clientset.Interface, d *extensions.Deployment) er
|
|||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
oldRSs, allOldRSs, newRS, err = deploymentutil.GetAllReplicaSets(deployment, c)
|
||||
oldRSs, allOldRSs, newRS, err = deploymentutil.GetAllReplicaSets(deployment, c.ExtensionsV1beta1())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -276,8 +276,8 @@ func WatchRecreateDeployment(c clientset.Interface, d *extensions.Deployment) er
|
|||
status = d.Status
|
||||
|
||||
if d.Status.UpdatedReplicas > 0 && d.Status.Replicas != d.Status.UpdatedReplicas {
|
||||
_, allOldRSs, err := deploymentutil.GetOldReplicaSets(d, c)
|
||||
newRS, nerr := deploymentutil.GetNewReplicaSet(d, c)
|
||||
_, allOldRSs, err := deploymentutil.GetOldReplicaSets(d, c.ExtensionsV1beta1())
|
||||
newRS, nerr := deploymentutil.GetNewReplicaSet(d, c.ExtensionsV1beta1())
|
||||
if err == nil && nerr == nil {
|
||||
Logf("%+v", d)
|
||||
logReplicaSetsOfDeployment(d, allOldRSs, newRS)
|
||||
|
|
|
@ -63,7 +63,7 @@ func CheckNewRSAnnotations(c clientset.Interface, ns, deploymentName string, exp
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ func (t *DeploymentUpgradeTest) Setup(f *framework.Framework) {
|
|||
By(fmt.Sprintf("Waiting deployment %q to complete", deploymentName))
|
||||
framework.ExpectNoError(framework.WaitForDeploymentStatusValid(c, deployment))
|
||||
|
||||
rs, err := deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
rs, err := deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
framework.ExpectNoError(err)
|
||||
if rs == nil {
|
||||
framework.ExpectNoError(fmt.Errorf("expected a new replica set for deployment %q, found none", deployment.Name))
|
||||
|
@ -108,7 +108,7 @@ func (t *DeploymentUpgradeTest) Setup(f *framework.Framework) {
|
|||
By(fmt.Sprintf("Waiting deployment %q to complete", deploymentName))
|
||||
framework.ExpectNoError(framework.WaitForDeploymentStatus(c, deployment))
|
||||
|
||||
rs, err = deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
rs, err = deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
framework.ExpectNoError(err)
|
||||
if rs == nil {
|
||||
framework.ExpectNoError(fmt.Errorf("expected a new replica set for deployment %q", deployment.Name))
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestNewDeployment(t *testing.T) {
|
|||
tester.waitForDeploymentStatusValidAndMarkPodsReady()
|
||||
|
||||
// Check new RS annotations
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deploy, c)
|
||||
newRS, err := deploymentutil.GetNewReplicaSet(deploy, c.ExtensionsV1beta1())
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get new ReplicaSet of Deployment %s: %v", deploy.Name, err)
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ func WaitForDeploymentStatusValid(c clientset.Interface, d *extensions.Deploymen
|
|||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
oldRSs, allOldRSs, newRS, err = deploymentutil.GetAllReplicaSets(deployment, c)
|
||||
oldRSs, allOldRSs, newRS, err = deploymentutil.GetAllReplicaSets(deployment, c.ExtensionsV1beta1())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName
|
|||
}
|
||||
// The new ReplicaSet needs to be non-nil and contain the pod-template-hash label
|
||||
|
||||
newRS, err = deploymentutil.GetNewReplicaSet(deployment, c)
|
||||
newRS, err = deploymentutil.GetNewReplicaSet(deployment, c.ExtensionsV1beta1())
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
Loading…
Reference in New Issue