Browse code

Removing unnecessary namespace prefix for deployment/deploymentConfig/Repo

jhadvig authored on 2015/05/28 17:52:19
Showing 4 changed files
... ...
@@ -42,7 +42,7 @@ func (c *DeploymentConfigChangeController) Handle(config *deployapi.DeploymentCo
42 42
 	}
43 43
 
44 44
 	if !hasChangeTrigger {
45
-		glog.V(4).Infof("Ignoring DeploymentConfig %s/%s; no change triggers detected", config.Namespace, deployutil.LabelForDeploymentConfig(config))
45
+		glog.V(4).Infof("Ignoring DeploymentConfig %s; no change triggers detected", deployutil.LabelForDeploymentConfig(config))
46 46
 		return nil
47 47
 	}
48 48
 
... ...
@@ -50,11 +50,11 @@ func (c *DeploymentConfigChangeController) Handle(config *deployapi.DeploymentCo
50 50
 		_, _, err := c.generateDeployment(config)
51 51
 		if err != nil {
52 52
 			if kerrors.IsConflict(err) {
53
-				return fatalError(fmt.Sprintf("DeploymentConfig %s/%s updated since retrieval; aborting trigger: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err))
53
+				return fatalError(fmt.Sprintf("DeploymentConfig %s updated since retrieval; aborting trigger: %v", deployutil.LabelForDeploymentConfig(config), err))
54 54
 			}
55
-			return fmt.Errorf("couldn't create initial Deployment for DeploymentConfig %s/%s: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err)
55
+			return fmt.Errorf("couldn't create initial Deployment for DeploymentConfig %s: %v", deployutil.LabelForDeploymentConfig(config), err)
56 56
 		}
57
-		glog.V(4).Infof("Created initial Deployment for DeploymentConfig %s/%s", config.Namespace, deployutil.LabelForDeploymentConfig(config))
57
+		glog.V(4).Infof("Created initial Deployment for DeploymentConfig %s", deployutil.LabelForDeploymentConfig(config))
58 58
 		return nil
59 59
 	}
60 60
 
... ...
@@ -62,15 +62,15 @@ func (c *DeploymentConfigChangeController) Handle(config *deployapi.DeploymentCo
62 62
 	deployment, err := c.changeStrategy.getDeployment(config.Namespace, latestDeploymentName)
63 63
 	if err != nil {
64 64
 		if kerrors.IsNotFound(err) {
65
-			glog.V(2).Infof("Ignoring change for DeploymentConfig %s/%s; no existing Deployment found", config.Namespace, deployutil.LabelForDeploymentConfig(config))
65
+			glog.V(2).Infof("Ignoring change for DeploymentConfig %s; no existing Deployment found", deployutil.LabelForDeploymentConfig(config))
66 66
 			return nil
67 67
 		}
68
-		return fmt.Errorf("couldn't retrieve Deployment for DeploymentConfig %s/%s: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err)
68
+		return fmt.Errorf("couldn't retrieve Deployment for DeploymentConfig %s: %v", deployutil.LabelForDeploymentConfig(config), err)
69 69
 	}
70 70
 
71 71
 	deployedConfig, err := c.decodeConfig(deployment)
72 72
 	if err != nil {
73
-		return fatalError(fmt.Sprintf("error decoding DeploymentConfig from Deployment %s for DeploymentConfig %s/%s: %v", deployutil.LabelForDeployment(deployment), config.Namespace, deployutil.LabelForDeploymentConfig(config), err))
73
+		return fatalError(fmt.Sprintf("error decoding DeploymentConfig from Deployment %s for DeploymentConfig %s: %v", deployutil.LabelForDeployment(deployment), deployutil.LabelForDeploymentConfig(config), err))
74 74
 	}
75 75
 
76 76
 	if deployutil.PodSpecsEqual(config.Template.ControllerTemplate.Template.Spec, deployedConfig.Template.ControllerTemplate.Template.Spec) {
... ...
@@ -81,11 +81,11 @@ func (c *DeploymentConfigChangeController) Handle(config *deployapi.DeploymentCo
81 81
 	fromVersion, toVersion, err := c.generateDeployment(config)
82 82
 	if err != nil {
83 83
 		if kerrors.IsConflict(err) {
84
-			return fatalError(fmt.Sprintf("DeploymentConfig %s/%s updated since retrieval; aborting trigger: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err))
84
+			return fatalError(fmt.Sprintf("DeploymentConfig %s updated since retrieval; aborting trigger: %v", deployutil.LabelForDeploymentConfig(config), err))
85 85
 		}
86
-		return fmt.Errorf("couldn't generate deployment for DeploymentConfig %s/%s: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err)
86
+		return fmt.Errorf("couldn't generate deployment for DeploymentConfig %s: %v", deployutil.LabelForDeploymentConfig(config), err)
87 87
 	}
88
-	glog.V(4).Infof("Updated DeploymentConfig %s/%s from version %d to %d for existing deployment %s", config.Namespace, deployutil.LabelForDeploymentConfig(config), fromVersion, toVersion, deployutil.LabelForDeployment(deployment))
88
+	glog.V(4).Infof("Updated DeploymentConfig %s from version %d to %d for existing deployment %s", deployutil.LabelForDeploymentConfig(config), fromVersion, toVersion, deployutil.LabelForDeployment(deployment))
89 89
 	return nil
90 90
 }
91 91
 
... ...
@@ -53,9 +53,9 @@ func (c *DeployerPodController) Handle(pod *kapi.Pod) error {
53 53
 	if currentStatus != nextStatus {
54 54
 		deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(nextStatus)
55 55
 		if _, err := c.deploymentClient.updateDeployment(deployment.Namespace, deployment); err != nil {
56
-			return fmt.Errorf("couldn't update Deployment %s/%s to status %s: %v", deployment.Namespace, deployutil.LabelForDeployment(deployment), nextStatus, err)
56
+			return fmt.Errorf("couldn't update Deployment %s to status %s: %v", deployutil.LabelForDeployment(deployment), nextStatus, err)
57 57
 		}
58
-		glog.V(4).Infof("Updated Deployment %s/%s status from %s to %s", deployment.Namespace, deployutil.LabelForDeployment(deployment), currentStatus, nextStatus)
58
+		glog.V(4).Infof("Updated Deployment %s status from %s to %s", deployutil.LabelForDeployment(deployment), currentStatus, nextStatus)
59 59
 	}
60 60
 
61 61
 	return nil
... ...
@@ -58,7 +58,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig)
58 58
 	// Check if any existing inflight deployments (any non-terminal state).
59 59
 	existingDeployments, err := c.deploymentClient.listDeploymentsForConfig(config.Namespace, config.Name)
60 60
 	if err != nil {
61
-		return fmt.Errorf("couldn't list Deployments for DeploymentConfig %s/%s: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err)
61
+		return fmt.Errorf("couldn't list Deployments for DeploymentConfig %s: %v", deployutil.LabelForDeploymentConfig(config), err)
62 62
 	}
63 63
 	var inflightDeployment *kapi.ReplicationController
64 64
 	for _, deployment := range existingDeployments.Items {
... ...
@@ -84,9 +84,9 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig)
84 84
 			deploymentForCancellation.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue
85 85
 			deploymentForCancellation.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledNewerDeploymentExists
86 86
 			if _, err := c.deploymentClient.updateDeployment(deploymentForCancellation.Namespace, deploymentForCancellation); err != nil {
87
-				glog.Errorf("couldn't cancel Deployment %s/%s: %v", deploymentForCancellation.Namespace, deployutil.LabelForDeployment(deploymentForCancellation), err)
87
+				glog.Errorf("couldn't cancel Deployment %s: %v", deployutil.LabelForDeployment(deploymentForCancellation), err)
88 88
 			}
89
-			glog.V(4).Infof("Cancelled Deployment %s for DeploymentConfig %s/%s", deployutil.LabelForDeployment(deploymentForCancellation), config.Namespace, deployutil.LabelForDeploymentConfig(config))
89
+			glog.V(4).Infof("Cancelled Deployment %s for DeploymentConfig %s", deployutil.LabelForDeployment(deploymentForCancellation), deployutil.LabelForDeploymentConfig(config))
90 90
 		}
91 91
 	}
92 92
 
... ...
@@ -98,14 +98,14 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig)
98 98
 			return nil
99 99
 		}
100 100
 		// if this is an earlier deployment, raise a transientError so that the deployment config can be re-queued
101
-		glog.V(4).Infof("Found previous inflight Deployment for %s/%s - will requeue", config.Namespace, deployutil.LabelForDeploymentConfig(config))
102
-		return transientError(fmt.Sprintf("found previous inflight Deployment for %s/%s - requeuing", config.Namespace, deployutil.LabelForDeploymentConfig(config)))
101
+		glog.V(4).Infof("Found previous inflight Deployment for %s - will requeue", deployutil.LabelForDeploymentConfig(config))
102
+		return transientError(fmt.Sprintf("found previous inflight Deployment for %s - requeuing", deployutil.LabelForDeploymentConfig(config)))
103 103
 	}
104 104
 
105 105
 	// Try and build a deployment for the config.
106 106
 	deployment, err := c.makeDeployment(config)
107 107
 	if err != nil {
108
-		return fatalError(fmt.Sprintf("couldn't make Deployment from (potentially invalid) DeploymentConfig %s/%s: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err))
108
+		return fatalError(fmt.Sprintf("couldn't make Deployment from (potentially invalid) DeploymentConfig %s: %v", deployutil.LabelForDeploymentConfig(config), err))
109 109
 	}
110 110
 
111 111
 	// Compute the desired replicas for the deployment. The count should match
... ...
@@ -127,20 +127,20 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig)
127 127
 
128 128
 	// Create the deployment.
129 129
 	if _, err := c.deploymentClient.createDeployment(config.Namespace, deployment); err == nil {
130
-		glog.V(4).Infof("Created Deployment for DeploymentConfig %s/%s", config.Namespace, deployutil.LabelForDeploymentConfig(config))
130
+		glog.V(4).Infof("Created Deployment for DeploymentConfig %s", deployutil.LabelForDeploymentConfig(config))
131 131
 		return nil
132 132
 	} else {
133 133
 		// If the deployment was already created, just move on. The cache could be stale, or another
134 134
 		// process could have already handled this update.
135 135
 		if errors.IsAlreadyExists(err) {
136
-			c.recorder.Eventf(config, "alreadyExists", "Deployment already exists for DeploymentConfig: %s/%s", config.Namespace, deployutil.LabelForDeploymentConfig(config))
137
-			glog.V(4).Infof("Deployment already exists for DeploymentConfig %s/%s", config.Namespace, deployutil.LabelForDeploymentConfig(config))
136
+			c.recorder.Eventf(config, "alreadyExists", "Deployment already exists for DeploymentConfig: %s", deployutil.LabelForDeploymentConfig(config))
137
+			glog.V(4).Infof("Deployment already exists for DeploymentConfig %s", deployutil.LabelForDeploymentConfig(config))
138 138
 			return nil
139 139
 		}
140 140
 
141 141
 		// log an event if the deployment could not be created that the user can discover
142 142
 		c.recorder.Eventf(config, "failedCreate", "Error creating: %v", err)
143
-		return fmt.Errorf("couldn't create Deployment for DeploymentConfig %s/%s: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err)
143
+		return fmt.Errorf("couldn't create Deployment for DeploymentConfig %s: %v", deployutil.LabelForDeploymentConfig(config), err)
144 144
 	}
145 145
 }
146 146
 
... ...
@@ -29,13 +29,13 @@ func (e fatalError) Error() string {
29 29
 func (c *ImageChangeController) Handle(imageRepo *imageapi.ImageStream) error {
30 30
 	configs, err := c.deploymentConfigClient.listDeploymentConfigs()
31 31
 	if err != nil {
32
-		return fmt.Errorf("couldn't get list of DeploymentConfig while handling ImageStream %s/%s: %v", imageRepo.Namespace, labelForRepo(imageRepo), err)
32
+		return fmt.Errorf("couldn't get list of DeploymentConfig while handling ImageStream %s: %v", labelForRepo(imageRepo), err)
33 33
 	}
34 34
 
35 35
 	// Find any configs which should be updated based on the new image state
36 36
 	configsToUpdate := map[string]*deployapi.DeploymentConfig{}
37 37
 	for _, config := range configs {
38
-		glog.V(4).Infof("Detecting changed images for DeploymentConfig %s/%s", config.Namespace, deployutil.LabelForDeploymentConfig(config))
38
+		glog.V(4).Infof("Detecting changed images for DeploymentConfig %s", deployutil.LabelForDeploymentConfig(config))
39 39
 
40 40
 		for _, trigger := range config.Triggers {
41 41
 			params := trigger.ImageChangeParams
... ...
@@ -53,7 +53,7 @@ func (c *ImageChangeController) Handle(imageRepo *imageapi.ImageStream) error {
53 53
 			// Find the latest tag event for the trigger tag
54 54
 			latestEvent := imageapi.LatestTaggedImage(imageRepo, params.Tag)
55 55
 			if latestEvent == nil {
56
-				glog.V(2).Infof("Couldn't find latest tag event for tag %s in ImageStream %s/%s", params.Tag, imageRepo.Namespace, labelForRepo(imageRepo))
56
+				glog.V(2).Infof("Couldn't find latest tag event for tag %s in ImageStream %s", params.Tag, labelForRepo(imageRepo))
57 57
 				continue
58 58
 			}
59 59
 
... ...
@@ -72,18 +72,18 @@ func (c *ImageChangeController) Handle(imageRepo *imageapi.ImageStream) error {
72 72
 		err := c.regenerate(config)
73 73
 		if err != nil {
74 74
 			anyFailed = true
75
-			glog.V(2).Infof("Couldn't regenerate DeploymentConfig %s/%s: %s", config.Namespace, deployutil.LabelForDeploymentConfig(config), err)
75
+			glog.V(2).Infof("Couldn't regenerate DeploymentConfig %s: %s", deployutil.LabelForDeploymentConfig(config), err)
76 76
 			continue
77 77
 		}
78 78
 
79
-		glog.V(4).Infof("Regenerated DeploymentConfig %s/%s in response to image change trigger", config.Namespace, deployutil.LabelForDeploymentConfig(config))
79
+		glog.V(4).Infof("Regenerated DeploymentConfig %s in response to image change trigger", deployutil.LabelForDeploymentConfig(config))
80 80
 	}
81 81
 
82 82
 	if anyFailed {
83
-		return fatalError(fmt.Sprintf("couldn't update some DeploymentConfig for trigger on ImageStream %s/%s", imageRepo.Namespace, labelForRepo(imageRepo)))
83
+		return fatalError(fmt.Sprintf("couldn't update some DeploymentConfig for trigger on ImageStream %s", labelForRepo(imageRepo)))
84 84
 	}
85 85
 
86
-	glog.V(4).Infof("Updated all DeploymentConfigs for trigger on ImageStream %s/%s", imageRepo.Namespace, labelForRepo(imageRepo))
86
+	glog.V(4).Infof("Updated all DeploymentConfigs for trigger on ImageStream %s", labelForRepo(imageRepo))
87 87
 	return nil
88 88
 }
89 89
 
... ...
@@ -119,12 +119,12 @@ func (c *ImageChangeController) regenerate(config *deployapi.DeploymentConfig) e
119 119
 	// Get a regenerated config which includes the new image repo references
120 120
 	newConfig, err := c.deploymentConfigClient.generateDeploymentConfig(config.Namespace, config.Name)
121 121
 	if err != nil {
122
-		return fmt.Errorf("error generating new version of DeploymentConfig %s/%s: %v", config.Namespace, deployutil.LabelForDeploymentConfig(config), err)
122
+		return fmt.Errorf("error generating new version of DeploymentConfig %s: %v", deployutil.LabelForDeploymentConfig(config), err)
123 123
 	}
124 124
 
125 125
 	// No update occured
126 126
 	if config.LatestVersion == newConfig.LatestVersion {
127
-		glog.V(4).Infof("No version difference for generated DeploymentConfig %s/%s", config.Namespace, deployutil.LabelForDeploymentConfig(config))
127
+		glog.V(4).Infof("No version difference for generated DeploymentConfig %s", deployutil.LabelForDeploymentConfig(config))
128 128
 		return nil
129 129
 	}
130 130
 
... ...
@@ -134,7 +134,7 @@ func (c *ImageChangeController) regenerate(config *deployapi.DeploymentConfig) e
134 134
 		return err
135 135
 	}
136 136
 
137
-	glog.Infof("Regenerated DeploymentConfig %s/%s for image updates", config.Namespace, deployutil.LabelForDeploymentConfig(config))
137
+	glog.Infof("Regenerated DeploymentConfig %s for image updates", deployutil.LabelForDeploymentConfig(config))
138 138
 	return nil
139 139
 }
140 140