Skip to content

Commit 79a743f

Browse files
author
OpenShift Bot
authored
Merge pull request #10625 from zhaosijun/deploymentModify2
Merged by openshift-bot
2 parents 6479676 + 10f3281 commit 79a743f

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

pkg/deploy/controller/deployment/controller.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,35 @@ func (c *DeploymentController) Handle(deployment *kapi.ReplicationController) er
106106
break
107107
}
108108

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.
114135
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 */
117138
// Do a stronger check to validate that the existing deployer pod is
118139
// actually for this deployment, and if not, fail this deployment.
119140
//
@@ -133,28 +154,7 @@ func (c *DeploymentController) Handle(deployment *kapi.ReplicationController) er
133154
nextStatus = nextStatusComp(nextStatus, deployapi.DeploymentStatusPending)
134155
glog.V(4).Infof("Detected existing deployer pod %s for deployment %s", deployer.Name, deployutil.LabelForDeployment(deployment))
135156
}
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))
154157
}
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))
158158

159159
case deployapi.DeploymentStatusPending, deployapi.DeploymentStatusRunning:
160160
switch {

0 commit comments

Comments
 (0)