@@ -106,14 +106,35 @@ func (c *DeploymentController) Handle(deployment *kapi.ReplicationController) er
106
106
break
107
107
}
108
108
109
- // If the pod already exists, it's possible that a previous CreatePod
110
- // succeeded but the deployment state update failed and now we're re-
111
- // entering. Ensure that the pod is the one we created by verifying the
112
- // annotation on it, and throw a retryable error.
113
- if deployerErr != nil && ! kerrors .IsNotFound (deployerErr ) {
109
+ switch {
110
+ case kerrors .IsNotFound (deployerErr ):
111
+ if _ , ok := deployment .Annotations [deployapi .DeploymentIgnorePodAnnotation ]; ok {
112
+ return nil
113
+ }
114
+
115
+ // Generate a deployer pod spec.
116
+ deployerPod , err := c .makeDeployerPod (deployment )
117
+ if err != nil {
118
+ return fatalError (fmt .Sprintf ("couldn't make deployer pod for %s: %v" , deployutil .LabelForDeployment (deployment ), err ))
119
+ }
120
+ // Create the deployer pod.
121
+ deploymentPod , err := c .pn .Pods (deployment .Namespace ).Create (deployerPod )
122
+ // Retry on error.
123
+ if err != nil {
124
+ return actionableError (fmt .Sprintf ("couldn't create deployer pod for %s: %v" , deployutil .LabelForDeployment (deployment ), err ))
125
+ }
126
+ updatedAnnotations [deployapi .DeploymentPodAnnotation ] = deploymentPod .Name
127
+ nextStatus = deployapi .DeploymentStatusPending
128
+ glog .V (4 ).Infof ("Created deployer pod %s for deployment %s" , deploymentPod .Name , deployutil .LabelForDeployment (deployment ))
129
+
130
+ case deployerErr != nil :
131
+ // If the pod already exists, it's possible that a previous CreatePod
132
+ // succeeded but the deployment state update failed and now we're re-
133
+ // entering. Ensure that the pod is the one we created by verifying the
134
+ // annotation on it, and throw a retryable error.
114
135
return fmt .Errorf ("couldn't fetch existing deployer pod for %s: %v" , deployutil .LabelForDeployment (deployment ), deployerErr )
115
- }
116
- if deployerErr == nil && deployer != nil {
136
+
137
+ default : /* deployerErr == nil */
117
138
// Do a stronger check to validate that the existing deployer pod is
118
139
// actually for this deployment, and if not, fail this deployment.
119
140
//
@@ -133,28 +154,7 @@ func (c *DeploymentController) Handle(deployment *kapi.ReplicationController) er
133
154
nextStatus = nextStatusComp (nextStatus , deployapi .DeploymentStatusPending )
134
155
glog .V (4 ).Infof ("Detected existing deployer pod %s for deployment %s" , deployer .Name , deployutil .LabelForDeployment (deployment ))
135
156
}
136
- // Don't try and re-create the deployer pod.
137
- break
138
- }
139
-
140
- if _ , ok := deployment .Annotations [deployapi .DeploymentIgnorePodAnnotation ]; ok {
141
- return nil
142
- }
143
-
144
- // Generate a deployer pod spec.
145
- deployerPod , err := c .makeDeployerPod (deployment )
146
- if err != nil {
147
- return fatalError (fmt .Sprintf ("couldn't make deployer pod for %s: %v" , deployutil .LabelForDeployment (deployment ), err ))
148
- }
149
- // Create the deployer pod.
150
- deploymentPod , err := c .pn .Pods (deployment .Namespace ).Create (deployerPod )
151
- // Retry on error.
152
- if err != nil {
153
- return actionableError (fmt .Sprintf ("couldn't create deployer pod for %s: %v" , deployutil .LabelForDeployment (deployment ), err ))
154
157
}
155
- updatedAnnotations [deployapi .DeploymentPodAnnotation ] = deploymentPod .Name
156
- nextStatus = deployapi .DeploymentStatusPending
157
- glog .V (4 ).Infof ("Created deployer pod %s for deployment %s" , deploymentPod .Name , deployutil .LabelForDeployment (deployment ))
158
158
159
159
case deployapi .DeploymentStatusPending , deployapi .DeploymentStatusRunning :
160
160
switch {
0 commit comments