@@ -21,7 +21,7 @@ import (
21
21
"fmt"
22
22
"time"
23
23
24
- . "github.com/onsi/ginkgo"
24
+ "github.com/onsi/ginkgo"
25
25
26
26
apps "k8s.io/api/apps/v1"
27
27
"k8s.io/api/core/v1"
@@ -30,19 +30,18 @@ import (
30
30
"k8s.io/apimachinery/pkg/util/wait"
31
31
"k8s.io/apimachinery/pkg/watch"
32
32
clientset "k8s.io/client-go/kubernetes"
33
- scaleclient "k8s.io/client-go/scale"
34
33
watchtools "k8s.io/client-go/tools/watch"
35
- appsinternal "k8s.io/kubernetes/pkg/apis/apps"
36
34
deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
37
35
testutils "k8s.io/kubernetes/test/utils"
38
36
imageutils "k8s.io/kubernetes/test/utils/image"
39
37
)
40
38
39
+ // UpdateDeploymentWithRetries updates the specified deployment with retries.
41
40
func UpdateDeploymentWithRetries (c clientset.Interface , namespace , name string , applyUpdate testutils.UpdateDeploymentFunc ) (* apps.Deployment , error ) {
42
41
return testutils .UpdateDeploymentWithRetries (c , namespace , name , applyUpdate , Logf , Poll , pollShortTimeout )
43
42
}
44
43
45
- // Waits for the deployment to clean up old rcs.
44
+ // WaitForDeploymentOldRSsNum waits for the deployment to clean up old rcs.
46
45
func WaitForDeploymentOldRSsNum (c clientset.Interface , ns , deploymentName string , desiredRSNum int ) error {
47
46
var oldRSs []* apps.ReplicaSet
48
47
var d * apps.Deployment
@@ -71,10 +70,12 @@ func logReplicaSetsOfDeployment(deployment *apps.Deployment, allOldRSs []*apps.R
71
70
testutils .LogReplicaSetsOfDeployment (deployment , allOldRSs , newRS , Logf )
72
71
}
73
72
73
+ // WaitForObservedDeployment waits for the specified deployment generation.
74
74
func WaitForObservedDeployment (c clientset.Interface , ns , deploymentName string , desiredGeneration int64 ) error {
75
75
return testutils .WaitForObservedDeployment (c , ns , deploymentName , desiredGeneration )
76
76
}
77
77
78
+ // WaitForDeploymentWithCondition waits for the specified deployment condition.
78
79
func WaitForDeploymentWithCondition (c clientset.Interface , ns , deploymentName , reason string , condType apps.DeploymentConditionType ) error {
79
80
return testutils .WaitForDeploymentWithCondition (c , ns , deploymentName , reason , condType , Logf , Poll , pollLongTimeout )
80
81
}
@@ -86,6 +87,7 @@ func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName
86
87
return testutils .WaitForDeploymentRevisionAndImage (c , ns , deploymentName , revision , image , Logf , Poll , pollLongTimeout )
87
88
}
88
89
90
+ // NewDeployment returns a deployment spec with the specified argument.
89
91
func NewDeployment (deploymentName string , replicas int32 , podLabels map [string ]string , imageName , image string , strategyType apps.DeploymentStrategyType ) * apps.Deployment {
90
92
zero := int64 (0 )
91
93
return & apps.Deployment {
@@ -117,14 +119,14 @@ func NewDeployment(deploymentName string, replicas int32, podLabels map[string]s
117
119
}
118
120
}
119
121
120
- // Waits for the deployment to complete, and don't check if rolling update strategy is broken.
122
+ // WaitForDeploymentComplete waits for the deployment to complete, and don't check if rolling update strategy is broken.
121
123
// Rolling update strategy is used only during a rolling update, and can be violated in other situations,
122
124
// such as shortly after a scaling event or the deployment is just created.
123
125
func WaitForDeploymentComplete (c clientset.Interface , d * apps.Deployment ) error {
124
126
return testutils .WaitForDeploymentComplete (c , d , Logf , Poll , pollLongTimeout )
125
127
}
126
128
127
- // Waits for the deployment to complete, and check rolling update strategy isn't broken at any times.
129
+ // WaitForDeploymentCompleteAndCheckRolling waits for the deployment to complete, and check rolling update strategy isn't broken at any times.
128
130
// Rolling update strategy should not be broken during a rolling update.
129
131
func WaitForDeploymentCompleteAndCheckRolling (c clientset.Interface , d * apps.Deployment ) error {
130
132
return testutils .WaitForDeploymentCompleteAndCheckRolling (c , d , Logf , Poll , pollLongTimeout )
@@ -184,12 +186,9 @@ func WatchRecreateDeployment(c clientset.Interface, d *apps.Deployment) error {
184
186
return err
185
187
}
186
188
187
- func ScaleDeployment (clientset clientset.Interface , scalesGetter scaleclient.ScalesGetter , ns , name string , size uint , wait bool ) error {
188
- return ScaleResource (clientset , scalesGetter , ns , name , size , wait , appsinternal .Kind ("Deployment" ), appsinternal .Resource ("deployments" ))
189
- }
190
-
189
+ // RunDeployment runs a delopyment with the specified config.
191
190
func RunDeployment (config testutils.DeploymentConfig ) error {
192
- By (fmt .Sprintf ("creating deployment %s in namespace %s" , config .Name , config .Namespace ))
191
+ ginkgo . By (fmt .Sprintf ("creating deployment %s in namespace %s" , config .Name , config .Namespace ))
193
192
config .NodeDumpFunc = DumpNodeDebugInfo
194
193
config .ContainerDumpFunc = LogFailedContainers
195
194
return testutils .RunDeployment (config )
@@ -199,6 +198,7 @@ func logPodsOfDeployment(c clientset.Interface, deployment *apps.Deployment, rsL
199
198
testutils .LogPodsOfDeployment (c , deployment , rsList , Logf )
200
199
}
201
200
201
+ // WaitForDeploymentRevision waits for becoming the target revision of a delopyment.
202
202
func WaitForDeploymentRevision (c clientset.Interface , d * apps.Deployment , targetRevision string ) error {
203
203
err := wait .PollImmediate (Poll , pollLongTimeout , func () (bool , error ) {
204
204
deployment , err := c .AppsV1 ().Deployments (d .Namespace ).Get (d .Name , metav1.GetOptions {})
@@ -219,6 +219,7 @@ func CheckDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName,
219
219
return testutils .CheckDeploymentRevisionAndImage (c , ns , deploymentName , revision , image )
220
220
}
221
221
222
+ // CreateDeployment creates a deployment.
222
223
func CreateDeployment (client clientset.Interface , replicas int32 , podLabels map [string ]string , nodeSelector map [string ]string , namespace string , pvclaims []* v1.PersistentVolumeClaim , command string ) (* apps.Deployment , error ) {
223
224
deploymentSpec := MakeDeployment (replicas , podLabels , nodeSelector , namespace , pvclaims , false , command )
224
225
deployment , err := client .AppsV1 ().Deployments (namespace ).Create (deploymentSpec )
0 commit comments