| ... | ... |
@@ -715,7 +715,7 @@ |
| 715 | 715 |
"strategy": {
|
| 716 | 716 |
"type": "CustomPod", |
| 717 | 717 |
"customPod": {
|
| 718 |
- "image": "127.0.0.1:5000/openshift/kube-deploy" |
|
| 718 |
+ "image": "127.0.0.1:5000/openshift/origin-deployer" |
|
| 719 | 719 |
} |
| 720 | 720 |
}, |
| 721 | 721 |
"controllerTemplate": {
|
| ... | ... |
@@ -771,7 +771,7 @@ |
| 771 | 771 |
"strategy": {
|
| 772 | 772 |
"type": "CustomPod", |
| 773 | 773 |
"customPod": {
|
| 774 |
- "image": "127.0.0.1:5000/openshift/kube-deploy" |
|
| 774 |
+ "image": "127.0.0.1:5000/openshift/origin-deployer" |
|
| 775 | 775 |
} |
| 776 | 776 |
}, |
| 777 | 777 |
"controllerTemplate": {
|
| ... | ... |
@@ -819,7 +819,7 @@ |
| 819 | 819 |
"strategy": {
|
| 820 | 820 |
"type": "CustomPod", |
| 821 | 821 |
"customPod": {
|
| 822 |
- "image": "127.0.0.1:5000/openshift/kube-deploy" |
|
| 822 |
+ "image": "127.0.0.1:5000/openshift/origin-deployer" |
|
| 823 | 823 |
} |
| 824 | 824 |
}, |
| 825 | 825 |
"controllerTemplate": {
|
| ... | ... |
@@ -878,7 +878,7 @@ |
| 878 | 878 |
"strategy": {
|
| 879 | 879 |
"type": "CustomPod", |
| 880 | 880 |
"customPod": {
|
| 881 |
- "image": "127.0.0.1:5000/openshift/kube-deploy" |
|
| 881 |
+ "image": "127.0.0.1:5000/openshift/origin-deployer" |
|
| 882 | 882 |
} |
| 883 | 883 |
}, |
| 884 | 884 |
"controllerTemplate": {
|
| ... | ... |
@@ -927,7 +927,7 @@ |
| 927 | 927 |
"strategy": {
|
| 928 | 928 |
"type": "CustomPod", |
| 929 | 929 |
"customPod": {
|
| 930 |
- "image": "127.0.0.1:5000/openshift/kube-deploy" |
|
| 930 |
+ "image": "127.0.0.1:5000/openshift/origin-deployer" |
|
| 931 | 931 |
} |
| 932 | 932 |
}, |
| 933 | 933 |
"controllerTemplate": {
|
| ... | ... |
@@ -974,7 +974,7 @@ |
| 974 | 974 |
"strategy": {
|
| 975 | 975 |
"type": "CustomPod", |
| 976 | 976 |
"customPod": {
|
| 977 |
- "image": "127.0.0.1:5000/openshift/kube-deploy" |
|
| 977 |
+ "image": "127.0.0.1:5000/openshift/origin-deployer" |
|
| 978 | 978 |
} |
| 979 | 979 |
}, |
| 980 | 980 |
"controllerTemplate": {
|
| ... | ... |
@@ -1021,7 +1021,7 @@ |
| 1021 | 1021 |
"strategy": {
|
| 1022 | 1022 |
"type": "CustomPod", |
| 1023 | 1023 |
"customPod": {
|
| 1024 |
- "image": "127.0.0.1:5000/openshift/kube-deploy" |
|
| 1024 |
+ "image": "127.0.0.1:5000/openshift/origin-deployer" |
|
| 1025 | 1025 |
} |
| 1026 | 1026 |
}, |
| 1027 | 1027 |
"controllerTemplate": {
|
| ... | ... |
@@ -80,7 +80,6 @@ func TestChangeWithTemplateDiff(t *testing.T) {
|
| 80 | 80 |
} else if updated.Details.Causes[0].Type != deployapi.DeploymentTriggerOnConfigChange {
|
| 81 | 81 |
t.Fatalf("expected config change cause to be set to config change trigger, got %s", updated.Details.Causes[0].Type)
|
| 82 | 82 |
} |
| 83 |
- |
|
| 84 | 83 |
} |
| 85 | 84 |
|
| 86 | 85 |
func TestChangeWithoutTemplateDiff(t *testing.T) {
|
| ... | ... |
@@ -129,138 +128,138 @@ func (i *testChangeStrategy) UpdateDeploymentConfig(ctx kapi.Context, config *de |
| 129 | 129 |
} |
| 130 | 130 |
|
| 131 | 131 |
func initialConfig() *deployapi.DeploymentConfig {
|
| 132 |
- return &deployapi.DeploymentConfig{
|
|
| 133 |
- TypeMeta: kapi.TypeMeta{ID: "test-deploy-config"},
|
|
| 134 |
- Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 135 |
- {
|
|
| 136 |
- Type: deployapi.DeploymentTriggerOnConfigChange, |
|
| 137 |
- }, |
|
| 138 |
- }, |
|
| 139 |
- LatestVersion: 2, |
|
| 140 |
- Template: deployapi.DeploymentTemplate{
|
|
| 141 |
- ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 142 |
- Replicas: 1, |
|
| 143 |
- ReplicaSelector: map[string]string{
|
|
| 144 |
- "name": "test-pod", |
|
| 145 |
- }, |
|
| 146 |
- PodTemplate: kapi.PodTemplate{
|
|
| 147 |
- Labels: map[string]string{
|
|
| 148 |
- "name": "test-pod", |
|
| 149 |
- }, |
|
| 150 |
- DesiredState: kapi.PodState{
|
|
| 151 |
- Manifest: kapi.ContainerManifest{
|
|
| 152 |
- Version: "v1beta1", |
|
| 153 |
- Containers: []kapi.Container{
|
|
| 154 |
- {
|
|
| 155 |
- Name: "container-1", |
|
| 156 |
- Image: "registry:8080/openshift/test-image:ref-1", |
|
| 157 |
- }, |
|
| 158 |
- }, |
|
| 159 |
- }, |
|
| 160 |
- }, |
|
| 161 |
- }, |
|
| 162 |
- }, |
|
| 163 |
- }, |
|
| 164 |
- } |
|
| 132 |
+ return &deployapi.DeploymentConfig{
|
|
| 133 |
+ TypeMeta: kapi.TypeMeta{ID: "test-deploy-config"},
|
|
| 134 |
+ Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 135 |
+ {
|
|
| 136 |
+ Type: deployapi.DeploymentTriggerOnConfigChange, |
|
| 137 |
+ }, |
|
| 138 |
+ }, |
|
| 139 |
+ LatestVersion: 2, |
|
| 140 |
+ Template: deployapi.DeploymentTemplate{
|
|
| 141 |
+ ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 142 |
+ Replicas: 1, |
|
| 143 |
+ ReplicaSelector: map[string]string{
|
|
| 144 |
+ "name": "test-pod", |
|
| 145 |
+ }, |
|
| 146 |
+ PodTemplate: kapi.PodTemplate{
|
|
| 147 |
+ Labels: map[string]string{
|
|
| 148 |
+ "name": "test-pod", |
|
| 149 |
+ }, |
|
| 150 |
+ DesiredState: kapi.PodState{
|
|
| 151 |
+ Manifest: kapi.ContainerManifest{
|
|
| 152 |
+ Version: "v1beta1", |
|
| 153 |
+ Containers: []kapi.Container{
|
|
| 154 |
+ {
|
|
| 155 |
+ Name: "container-1", |
|
| 156 |
+ Image: "registry:8080/openshift/test-image:ref-1", |
|
| 157 |
+ }, |
|
| 158 |
+ }, |
|
| 159 |
+ }, |
|
| 160 |
+ }, |
|
| 161 |
+ }, |
|
| 162 |
+ }, |
|
| 163 |
+ }, |
|
| 164 |
+ } |
|
| 165 | 165 |
} |
| 166 | 166 |
|
| 167 | 167 |
func diffedConfig() *deployapi.DeploymentConfig {
|
| 168 |
- return &deployapi.DeploymentConfig{
|
|
| 169 |
- TypeMeta: kapi.TypeMeta{ID: "test-deploy-config"},
|
|
| 170 |
- Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 171 |
- {
|
|
| 172 |
- Type: deployapi.DeploymentTriggerOnConfigChange, |
|
| 173 |
- }, |
|
| 174 |
- }, |
|
| 175 |
- LatestVersion: 2, |
|
| 176 |
- Template: deployapi.DeploymentTemplate{
|
|
| 177 |
- ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 178 |
- Replicas: 1, |
|
| 179 |
- ReplicaSelector: map[string]string{
|
|
| 180 |
- "name": "test-pod-2", |
|
| 181 |
- }, |
|
| 182 |
- PodTemplate: kapi.PodTemplate{
|
|
| 183 |
- Labels: map[string]string{
|
|
| 184 |
- "name": "test-pod-2", |
|
| 185 |
- }, |
|
| 186 |
- DesiredState: kapi.PodState{
|
|
| 187 |
- Manifest: kapi.ContainerManifest{
|
|
| 188 |
- Version: "v1beta1", |
|
| 189 |
- Containers: []kapi.Container{
|
|
| 190 |
- {
|
|
| 191 |
- Name: "container-2", |
|
| 192 |
- Image: "registry:8080/openshift/test-image:ref-1", |
|
| 193 |
- }, |
|
| 194 |
- }, |
|
| 195 |
- }, |
|
| 196 |
- }, |
|
| 197 |
- }, |
|
| 198 |
- }, |
|
| 199 |
- }, |
|
| 200 |
- } |
|
| 168 |
+ return &deployapi.DeploymentConfig{
|
|
| 169 |
+ TypeMeta: kapi.TypeMeta{ID: "test-deploy-config"},
|
|
| 170 |
+ Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 171 |
+ {
|
|
| 172 |
+ Type: deployapi.DeploymentTriggerOnConfigChange, |
|
| 173 |
+ }, |
|
| 174 |
+ }, |
|
| 175 |
+ LatestVersion: 2, |
|
| 176 |
+ Template: deployapi.DeploymentTemplate{
|
|
| 177 |
+ ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 178 |
+ Replicas: 1, |
|
| 179 |
+ ReplicaSelector: map[string]string{
|
|
| 180 |
+ "name": "test-pod-2", |
|
| 181 |
+ }, |
|
| 182 |
+ PodTemplate: kapi.PodTemplate{
|
|
| 183 |
+ Labels: map[string]string{
|
|
| 184 |
+ "name": "test-pod-2", |
|
| 185 |
+ }, |
|
| 186 |
+ DesiredState: kapi.PodState{
|
|
| 187 |
+ Manifest: kapi.ContainerManifest{
|
|
| 188 |
+ Version: "v1beta1", |
|
| 189 |
+ Containers: []kapi.Container{
|
|
| 190 |
+ {
|
|
| 191 |
+ Name: "container-2", |
|
| 192 |
+ Image: "registry:8080/openshift/test-image:ref-1", |
|
| 193 |
+ }, |
|
| 194 |
+ }, |
|
| 195 |
+ }, |
|
| 196 |
+ }, |
|
| 197 |
+ }, |
|
| 198 |
+ }, |
|
| 199 |
+ }, |
|
| 200 |
+ } |
|
| 201 | 201 |
} |
| 202 | 202 |
|
| 203 | 203 |
func generatedConfig() *deployapi.DeploymentConfig {
|
| 204 |
- return &deployapi.DeploymentConfig{
|
|
| 205 |
- TypeMeta: kapi.TypeMeta{ID: "test-deploy-config"},
|
|
| 206 |
- Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 207 |
- {
|
|
| 208 |
- Type: deployapi.DeploymentTriggerOnConfigChange, |
|
| 209 |
- }, |
|
| 210 |
- }, |
|
| 211 |
- LatestVersion: 3, |
|
| 212 |
- Template: deployapi.DeploymentTemplate{
|
|
| 213 |
- ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 214 |
- Replicas: 1, |
|
| 215 |
- ReplicaSelector: map[string]string{
|
|
| 216 |
- "name": "test-pod", |
|
| 217 |
- }, |
|
| 218 |
- PodTemplate: kapi.PodTemplate{
|
|
| 219 |
- Labels: map[string]string{
|
|
| 220 |
- "name": "test-pod", |
|
| 221 |
- }, |
|
| 222 |
- DesiredState: kapi.PodState{
|
|
| 223 |
- Manifest: kapi.ContainerManifest{
|
|
| 224 |
- Version: "v1beta1", |
|
| 225 |
- Containers: []kapi.Container{
|
|
| 226 |
- {
|
|
| 227 |
- Name: "container-1", |
|
| 228 |
- Image: "registry:8080/openshift/test-image:ref-2", |
|
| 229 |
- }, |
|
| 230 |
- }, |
|
| 231 |
- }, |
|
| 232 |
- }, |
|
| 233 |
- }, |
|
| 234 |
- }, |
|
| 235 |
- }, |
|
| 236 |
- } |
|
| 204 |
+ return &deployapi.DeploymentConfig{
|
|
| 205 |
+ TypeMeta: kapi.TypeMeta{ID: "test-deploy-config"},
|
|
| 206 |
+ Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 207 |
+ {
|
|
| 208 |
+ Type: deployapi.DeploymentTriggerOnConfigChange, |
|
| 209 |
+ }, |
|
| 210 |
+ }, |
|
| 211 |
+ LatestVersion: 3, |
|
| 212 |
+ Template: deployapi.DeploymentTemplate{
|
|
| 213 |
+ ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 214 |
+ Replicas: 1, |
|
| 215 |
+ ReplicaSelector: map[string]string{
|
|
| 216 |
+ "name": "test-pod", |
|
| 217 |
+ }, |
|
| 218 |
+ PodTemplate: kapi.PodTemplate{
|
|
| 219 |
+ Labels: map[string]string{
|
|
| 220 |
+ "name": "test-pod", |
|
| 221 |
+ }, |
|
| 222 |
+ DesiredState: kapi.PodState{
|
|
| 223 |
+ Manifest: kapi.ContainerManifest{
|
|
| 224 |
+ Version: "v1beta1", |
|
| 225 |
+ Containers: []kapi.Container{
|
|
| 226 |
+ {
|
|
| 227 |
+ Name: "container-1", |
|
| 228 |
+ Image: "registry:8080/openshift/test-image:ref-2", |
|
| 229 |
+ }, |
|
| 230 |
+ }, |
|
| 231 |
+ }, |
|
| 232 |
+ }, |
|
| 233 |
+ }, |
|
| 234 |
+ }, |
|
| 235 |
+ }, |
|
| 236 |
+ } |
|
| 237 | 237 |
} |
| 238 | 238 |
|
| 239 | 239 |
func matchingInitialDeployment() *deployapi.Deployment {
|
| 240 |
- return &deployapi.Deployment{
|
|
| 241 |
- TypeMeta: kapi.TypeMeta{ID: "test-deploy-config-1"},
|
|
| 242 |
- Status: deployapi.DeploymentStatusNew, |
|
| 243 |
- ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 244 |
- Replicas: 1, |
|
| 245 |
- ReplicaSelector: map[string]string{
|
|
| 246 |
- "name": "test-pod", |
|
| 247 |
- }, |
|
| 248 |
- PodTemplate: kapi.PodTemplate{
|
|
| 249 |
- Labels: map[string]string{
|
|
| 250 |
- "name": "test-pod", |
|
| 251 |
- }, |
|
| 252 |
- DesiredState: kapi.PodState{
|
|
| 253 |
- Manifest: kapi.ContainerManifest{
|
|
| 254 |
- Version: "v1beta1", |
|
| 255 |
- Containers: []kapi.Container{
|
|
| 256 |
- {
|
|
| 257 |
- Name: "container-1", |
|
| 258 |
- Image: "registry:8080/openshift/test-image:ref-1", |
|
| 259 |
- }, |
|
| 260 |
- }, |
|
| 261 |
- }, |
|
| 262 |
- }, |
|
| 263 |
- }, |
|
| 264 |
- }, |
|
| 265 |
- } |
|
| 240 |
+ return &deployapi.Deployment{
|
|
| 241 |
+ TypeMeta: kapi.TypeMeta{ID: "test-deploy-config-1"},
|
|
| 242 |
+ Status: deployapi.DeploymentStatusNew, |
|
| 243 |
+ ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 244 |
+ Replicas: 1, |
|
| 245 |
+ ReplicaSelector: map[string]string{
|
|
| 246 |
+ "name": "test-pod", |
|
| 247 |
+ }, |
|
| 248 |
+ PodTemplate: kapi.PodTemplate{
|
|
| 249 |
+ Labels: map[string]string{
|
|
| 250 |
+ "name": "test-pod", |
|
| 251 |
+ }, |
|
| 252 |
+ DesiredState: kapi.PodState{
|
|
| 253 |
+ Manifest: kapi.ContainerManifest{
|
|
| 254 |
+ Version: "v1beta1", |
|
| 255 |
+ Containers: []kapi.Container{
|
|
| 256 |
+ {
|
|
| 257 |
+ Name: "container-1", |
|
| 258 |
+ Image: "registry:8080/openshift/test-image:ref-1", |
|
| 259 |
+ }, |
|
| 260 |
+ }, |
|
| 261 |
+ }, |
|
| 262 |
+ }, |
|
| 263 |
+ }, |
|
| 264 |
+ }, |
|
| 265 |
+ } |
|
| 266 | 266 |
} |
| ... | ... |
@@ -1,207 +1,207 @@ |
| 1 | 1 |
package controller |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "testing" |
|
| 4 |
+ "testing" |
|
| 5 | 5 |
|
| 6 |
- kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
|
| 7 |
- kerrors "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
|
| 8 |
- deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 6 |
+ kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
|
| 7 |
+ kerrors "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
|
| 8 |
+ deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
type testDeploymentInterface struct {
|
| 12 |
- GetDeploymentFunc func(id string) (*deployapi.Deployment, error) |
|
| 13 |
- CreateDeploymentFunc func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) |
|
| 12 |
+ GetDeploymentFunc func(id string) (*deployapi.Deployment, error) |
|
| 13 |
+ CreateDeploymentFunc func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) |
|
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 | 16 |
func (i *testDeploymentInterface) GetDeployment(ctx kapi.Context, id string) (*deployapi.Deployment, error) {
|
| 17 |
- return i.GetDeploymentFunc(id) |
|
| 17 |
+ return i.GetDeploymentFunc(id) |
|
| 18 | 18 |
} |
| 19 | 19 |
|
| 20 | 20 |
func (i *testDeploymentInterface) CreateDeployment(ctx kapi.Context, deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
| 21 |
- return i.CreateDeploymentFunc(deployment) |
|
| 21 |
+ return i.CreateDeploymentFunc(deployment) |
|
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 | 24 |
func TestHandleNewDeploymentConfig(t *testing.T) {
|
| 25 |
- controller := &DeploymentConfigController{
|
|
| 26 |
- DeploymentInterface: &testDeploymentInterface{
|
|
| 27 |
- GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 28 |
- t.Fatalf("unexpected call with id %s", id)
|
|
| 29 |
- return nil, nil |
|
| 30 |
- }, |
|
| 31 |
- CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 32 |
- t.Fatalf("unexpected call with deployment %v", deployment)
|
|
| 33 |
- return nil, nil |
|
| 34 |
- }, |
|
| 35 |
- }, |
|
| 36 |
- NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 37 |
- deploymentConfig := manualDeploymentConfig() |
|
| 38 |
- deploymentConfig.LatestVersion = 0 |
|
| 39 |
- return deploymentConfig |
|
| 40 |
- }, |
|
| 41 |
- } |
|
| 42 |
- |
|
| 43 |
- controller.HandleDeploymentConfig() |
|
| 25 |
+ controller := &DeploymentConfigController{
|
|
| 26 |
+ DeploymentInterface: &testDeploymentInterface{
|
|
| 27 |
+ GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 28 |
+ t.Fatalf("unexpected call with id %s", id)
|
|
| 29 |
+ return nil, nil |
|
| 30 |
+ }, |
|
| 31 |
+ CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 32 |
+ t.Fatalf("unexpected call with deployment %v", deployment)
|
|
| 33 |
+ return nil, nil |
|
| 34 |
+ }, |
|
| 35 |
+ }, |
|
| 36 |
+ NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 37 |
+ deploymentConfig := manualDeploymentConfig() |
|
| 38 |
+ deploymentConfig.LatestVersion = 0 |
|
| 39 |
+ return deploymentConfig |
|
| 40 |
+ }, |
|
| 41 |
+ } |
|
| 42 |
+ |
|
| 43 |
+ controller.HandleDeploymentConfig() |
|
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 | 46 |
func TestHandleInitialDeployment(t *testing.T) {
|
| 47 |
- deploymentConfig := manualDeploymentConfig() |
|
| 48 |
- deploymentConfig.LatestVersion = 1 |
|
| 49 |
- |
|
| 50 |
- var deployed *deployapi.Deployment |
|
| 51 |
- |
|
| 52 |
- controller := &DeploymentConfigController{
|
|
| 53 |
- DeploymentInterface: &testDeploymentInterface{
|
|
| 54 |
- GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 55 |
- return nil, kerrors.NewNotFound("deployment", id)
|
|
| 56 |
- }, |
|
| 57 |
- CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 58 |
- deployed = deployment |
|
| 59 |
- return deployment, nil |
|
| 60 |
- }, |
|
| 61 |
- }, |
|
| 62 |
- NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 63 |
- return deploymentConfig |
|
| 64 |
- }, |
|
| 65 |
- } |
|
| 66 |
- |
|
| 67 |
- controller.HandleDeploymentConfig() |
|
| 68 |
- |
|
| 69 |
- if deployed == nil {
|
|
| 70 |
- t.Fatalf("expected a deployment")
|
|
| 71 |
- } |
|
| 72 |
- |
|
| 73 |
- if e, a := deploymentConfig.ID, deployed.Labels[deployapi.DeploymentConfigLabel]; e != a {
|
|
| 74 |
- t.Fatalf("expected deployment with label %s, got %s", e, a)
|
|
| 75 |
- } |
|
| 47 |
+ deploymentConfig := manualDeploymentConfig() |
|
| 48 |
+ deploymentConfig.LatestVersion = 1 |
|
| 49 |
+ |
|
| 50 |
+ var deployed *deployapi.Deployment |
|
| 51 |
+ |
|
| 52 |
+ controller := &DeploymentConfigController{
|
|
| 53 |
+ DeploymentInterface: &testDeploymentInterface{
|
|
| 54 |
+ GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 55 |
+ return nil, kerrors.NewNotFound("deployment", id)
|
|
| 56 |
+ }, |
|
| 57 |
+ CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 58 |
+ deployed = deployment |
|
| 59 |
+ return deployment, nil |
|
| 60 |
+ }, |
|
| 61 |
+ }, |
|
| 62 |
+ NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 63 |
+ return deploymentConfig |
|
| 64 |
+ }, |
|
| 65 |
+ } |
|
| 66 |
+ |
|
| 67 |
+ controller.HandleDeploymentConfig() |
|
| 68 |
+ |
|
| 69 |
+ if deployed == nil {
|
|
| 70 |
+ t.Fatalf("expected a deployment")
|
|
| 71 |
+ } |
|
| 72 |
+ |
|
| 73 |
+ if e, a := deploymentConfig.ID, deployed.Labels[deployapi.DeploymentConfigLabel]; e != a {
|
|
| 74 |
+ t.Fatalf("expected deployment with label %s, got %s", e, a)
|
|
| 75 |
+ } |
|
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 | 78 |
func TestHandleConfigChangeNoPodTemplateDiff(t *testing.T) {
|
| 79 |
- controller := &DeploymentConfigController{
|
|
| 80 |
- DeploymentInterface: &testDeploymentInterface{
|
|
| 81 |
- GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 82 |
- return matchingDeployment(), nil |
|
| 83 |
- }, |
|
| 84 |
- CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 85 |
- t.Fatalf("unexpected call to to create deployment: %v", deployment)
|
|
| 86 |
- return nil, nil |
|
| 87 |
- }, |
|
| 88 |
- }, |
|
| 89 |
- NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 90 |
- deploymentConfig := manualDeploymentConfig() |
|
| 91 |
- deploymentConfig.LatestVersion = 0 |
|
| 92 |
- return deploymentConfig |
|
| 93 |
- }, |
|
| 94 |
- } |
|
| 95 |
- |
|
| 96 |
- controller.HandleDeploymentConfig() |
|
| 79 |
+ controller := &DeploymentConfigController{
|
|
| 80 |
+ DeploymentInterface: &testDeploymentInterface{
|
|
| 81 |
+ GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 82 |
+ return matchingDeployment(), nil |
|
| 83 |
+ }, |
|
| 84 |
+ CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 85 |
+ t.Fatalf("unexpected call to to create deployment: %v", deployment)
|
|
| 86 |
+ return nil, nil |
|
| 87 |
+ }, |
|
| 88 |
+ }, |
|
| 89 |
+ NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 90 |
+ deploymentConfig := manualDeploymentConfig() |
|
| 91 |
+ deploymentConfig.LatestVersion = 0 |
|
| 92 |
+ return deploymentConfig |
|
| 93 |
+ }, |
|
| 94 |
+ } |
|
| 95 |
+ |
|
| 96 |
+ controller.HandleDeploymentConfig() |
|
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 | 99 |
func TestHandleConfigChangeWithPodTemplateDiff(t *testing.T) {
|
| 100 |
- deploymentConfig := manualDeploymentConfig() |
|
| 101 |
- deploymentConfig.LatestVersion = 2 |
|
| 102 |
- deploymentConfig.Template.ControllerTemplate.PodTemplate.Labels["foo"] = "bar" |
|
| 103 |
- |
|
| 104 |
- var deployed *deployapi.Deployment |
|
| 105 |
- |
|
| 106 |
- controller := &DeploymentConfigController{
|
|
| 107 |
- DeploymentInterface: &testDeploymentInterface{
|
|
| 108 |
- GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 109 |
- return nil, kerrors.NewNotFound("deployment", id)
|
|
| 110 |
- }, |
|
| 111 |
- CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 112 |
- deployed = deployment |
|
| 113 |
- return deployment, nil |
|
| 114 |
- }, |
|
| 115 |
- }, |
|
| 116 |
- NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 117 |
- return deploymentConfig |
|
| 118 |
- }, |
|
| 119 |
- } |
|
| 120 |
- |
|
| 121 |
- controller.HandleDeploymentConfig() |
|
| 122 |
- |
|
| 123 |
- if deployed == nil {
|
|
| 124 |
- t.Fatalf("expected a deployment")
|
|
| 125 |
- } |
|
| 126 |
- |
|
| 127 |
- if e, a := deploymentConfig.ID, deployed.Labels[deployapi.DeploymentConfigLabel]; e != a {
|
|
| 128 |
- t.Fatalf("expected deployment with label %s, got %s", e, a)
|
|
| 129 |
- } |
|
| 100 |
+ deploymentConfig := manualDeploymentConfig() |
|
| 101 |
+ deploymentConfig.LatestVersion = 2 |
|
| 102 |
+ deploymentConfig.Template.ControllerTemplate.PodTemplate.Labels["foo"] = "bar" |
|
| 103 |
+ |
|
| 104 |
+ var deployed *deployapi.Deployment |
|
| 105 |
+ |
|
| 106 |
+ controller := &DeploymentConfigController{
|
|
| 107 |
+ DeploymentInterface: &testDeploymentInterface{
|
|
| 108 |
+ GetDeploymentFunc: func(id string) (*deployapi.Deployment, error) {
|
|
| 109 |
+ return nil, kerrors.NewNotFound("deployment", id)
|
|
| 110 |
+ }, |
|
| 111 |
+ CreateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 112 |
+ deployed = deployment |
|
| 113 |
+ return deployment, nil |
|
| 114 |
+ }, |
|
| 115 |
+ }, |
|
| 116 |
+ NextDeploymentConfig: func() *deployapi.DeploymentConfig {
|
|
| 117 |
+ return deploymentConfig |
|
| 118 |
+ }, |
|
| 119 |
+ } |
|
| 120 |
+ |
|
| 121 |
+ controller.HandleDeploymentConfig() |
|
| 122 |
+ |
|
| 123 |
+ if deployed == nil {
|
|
| 124 |
+ t.Fatalf("expected a deployment")
|
|
| 125 |
+ } |
|
| 126 |
+ |
|
| 127 |
+ if e, a := deploymentConfig.ID, deployed.Labels[deployapi.DeploymentConfigLabel]; e != a {
|
|
| 128 |
+ t.Fatalf("expected deployment with label %s, got %s", e, a)
|
|
| 129 |
+ } |
|
| 130 | 130 |
} |
| 131 | 131 |
|
| 132 | 132 |
func manualDeploymentConfig() *deployapi.DeploymentConfig {
|
| 133 |
- return &deployapi.DeploymentConfig{
|
|
| 134 |
- TypeMeta: kapi.TypeMeta{ID: "manual-deploy-config"},
|
|
| 135 |
- Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 136 |
- {
|
|
| 137 |
- Type: deployapi.DeploymentTriggerManual, |
|
| 138 |
- }, |
|
| 139 |
- }, |
|
| 140 |
- Template: deployapi.DeploymentTemplate{
|
|
| 141 |
- Strategy: deployapi.DeploymentStrategy{
|
|
| 142 |
- Type: deployapi.DeploymentStrategyTypeCustomPod, |
|
| 143 |
- CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
|
| 144 |
- Image: "registry:8080/openshift/kube-deploy", |
|
| 145 |
- }, |
|
| 146 |
- }, |
|
| 147 |
- ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 148 |
- Replicas: 1, |
|
| 149 |
- ReplicaSelector: map[string]string{
|
|
| 150 |
- "name": "test-pod", |
|
| 151 |
- }, |
|
| 152 |
- PodTemplate: kapi.PodTemplate{
|
|
| 153 |
- Labels: map[string]string{
|
|
| 154 |
- "name": "test-pod", |
|
| 155 |
- }, |
|
| 156 |
- DesiredState: kapi.PodState{
|
|
| 157 |
- Manifest: kapi.ContainerManifest{
|
|
| 158 |
- Version: "v1beta1", |
|
| 159 |
- Containers: []kapi.Container{
|
|
| 160 |
- {
|
|
| 161 |
- Name: "container-1", |
|
| 162 |
- Image: "registry:8080/openshift/test-image:ref-1", |
|
| 163 |
- }, |
|
| 164 |
- }, |
|
| 165 |
- }, |
|
| 166 |
- }, |
|
| 167 |
- }, |
|
| 168 |
- }, |
|
| 169 |
- }, |
|
| 170 |
- } |
|
| 133 |
+ return &deployapi.DeploymentConfig{
|
|
| 134 |
+ TypeMeta: kapi.TypeMeta{ID: "manual-deploy-config"},
|
|
| 135 |
+ Triggers: []deployapi.DeploymentTriggerPolicy{
|
|
| 136 |
+ {
|
|
| 137 |
+ Type: deployapi.DeploymentTriggerManual, |
|
| 138 |
+ }, |
|
| 139 |
+ }, |
|
| 140 |
+ Template: deployapi.DeploymentTemplate{
|
|
| 141 |
+ Strategy: deployapi.DeploymentStrategy{
|
|
| 142 |
+ Type: deployapi.DeploymentStrategyTypeCustomPod, |
|
| 143 |
+ CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
|
| 144 |
+ Image: "registry:8080/openshift/origin-deployer", |
|
| 145 |
+ }, |
|
| 146 |
+ }, |
|
| 147 |
+ ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 148 |
+ Replicas: 1, |
|
| 149 |
+ ReplicaSelector: map[string]string{
|
|
| 150 |
+ "name": "test-pod", |
|
| 151 |
+ }, |
|
| 152 |
+ PodTemplate: kapi.PodTemplate{
|
|
| 153 |
+ Labels: map[string]string{
|
|
| 154 |
+ "name": "test-pod", |
|
| 155 |
+ }, |
|
| 156 |
+ DesiredState: kapi.PodState{
|
|
| 157 |
+ Manifest: kapi.ContainerManifest{
|
|
| 158 |
+ Version: "v1beta1", |
|
| 159 |
+ Containers: []kapi.Container{
|
|
| 160 |
+ {
|
|
| 161 |
+ Name: "container-1", |
|
| 162 |
+ Image: "registry:8080/openshift/test-image:ref-1", |
|
| 163 |
+ }, |
|
| 164 |
+ }, |
|
| 165 |
+ }, |
|
| 166 |
+ }, |
|
| 167 |
+ }, |
|
| 168 |
+ }, |
|
| 169 |
+ }, |
|
| 170 |
+ } |
|
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 | 173 |
func matchingDeployment() *deployapi.Deployment {
|
| 174 |
- return &deployapi.Deployment{
|
|
| 175 |
- TypeMeta: kapi.TypeMeta{ID: "manual-deploy-config-1"},
|
|
| 176 |
- Status: deployapi.DeploymentStatusNew, |
|
| 177 |
- Strategy: deployapi.DeploymentStrategy{
|
|
| 178 |
- Type: deployapi.DeploymentStrategyTypeCustomPod, |
|
| 179 |
- CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
|
| 180 |
- Image: "registry:8080/repo1:ref1", |
|
| 181 |
- Environment: []kapi.EnvVar{},
|
|
| 182 |
- }, |
|
| 183 |
- }, |
|
| 184 |
- ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 185 |
- Replicas: 1, |
|
| 186 |
- ReplicaSelector: map[string]string{
|
|
| 187 |
- "name": "test-pod", |
|
| 188 |
- }, |
|
| 189 |
- PodTemplate: kapi.PodTemplate{
|
|
| 190 |
- Labels: map[string]string{
|
|
| 191 |
- "name": "test-pod", |
|
| 192 |
- }, |
|
| 193 |
- DesiredState: kapi.PodState{
|
|
| 194 |
- Manifest: kapi.ContainerManifest{
|
|
| 195 |
- Version: "v1beta1", |
|
| 196 |
- Containers: []kapi.Container{
|
|
| 197 |
- {
|
|
| 198 |
- Name: "container-1", |
|
| 199 |
- Image: "registry:8080/openshift/test-image:ref-1", |
|
| 200 |
- }, |
|
| 201 |
- }, |
|
| 202 |
- }, |
|
| 203 |
- }, |
|
| 204 |
- }, |
|
| 205 |
- }, |
|
| 206 |
- } |
|
| 174 |
+ return &deployapi.Deployment{
|
|
| 175 |
+ TypeMeta: kapi.TypeMeta{ID: "manual-deploy-config-1"},
|
|
| 176 |
+ Status: deployapi.DeploymentStatusNew, |
|
| 177 |
+ Strategy: deployapi.DeploymentStrategy{
|
|
| 178 |
+ Type: deployapi.DeploymentStrategyTypeCustomPod, |
|
| 179 |
+ CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
|
| 180 |
+ Image: "registry:8080/repo1:ref1", |
|
| 181 |
+ Environment: []kapi.EnvVar{},
|
|
| 182 |
+ }, |
|
| 183 |
+ }, |
|
| 184 |
+ ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 185 |
+ Replicas: 1, |
|
| 186 |
+ ReplicaSelector: map[string]string{
|
|
| 187 |
+ "name": "test-pod", |
|
| 188 |
+ }, |
|
| 189 |
+ PodTemplate: kapi.PodTemplate{
|
|
| 190 |
+ Labels: map[string]string{
|
|
| 191 |
+ "name": "test-pod", |
|
| 192 |
+ }, |
|
| 193 |
+ DesiredState: kapi.PodState{
|
|
| 194 |
+ Manifest: kapi.ContainerManifest{
|
|
| 195 |
+ Version: "v1beta1", |
|
| 196 |
+ Containers: []kapi.Container{
|
|
| 197 |
+ {
|
|
| 198 |
+ Name: "container-1", |
|
| 199 |
+ Image: "registry:8080/openshift/test-image:ref-1", |
|
| 200 |
+ }, |
|
| 201 |
+ }, |
|
| 202 |
+ }, |
|
| 203 |
+ }, |
|
| 204 |
+ }, |
|
| 205 |
+ }, |
|
| 206 |
+ } |
|
| 207 | 207 |
} |
| ... | ... |
@@ -184,7 +184,7 @@ func imageChangeDeploymentConfig() *deployapi.DeploymentConfig {
|
| 184 | 184 |
Strategy: deployapi.DeploymentStrategy{
|
| 185 | 185 |
Type: deployapi.DeploymentStrategyTypeCustomPod, |
| 186 | 186 |
CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
| 187 |
- Image: "registry:8080/openshift/kube-deploy", |
|
| 187 |
+ Image: "registry:8080/openshift/origin-deployer", |
|
| 188 | 188 |
}, |
| 189 | 189 |
}, |
| 190 | 190 |
ControllerTemplate: kapi.ReplicationControllerState{
|
| ... | ... |
@@ -231,7 +231,7 @@ func regeneratedConfig(ctx kapi.Context) *deployapi.DeploymentConfig {
|
| 231 | 231 |
Strategy: deployapi.DeploymentStrategy{
|
| 232 | 232 |
Type: deployapi.DeploymentStrategyTypeCustomPod, |
| 233 | 233 |
CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
| 234 |
- Image: "registry:8080/openshift/kube-deploy", |
|
| 234 |
+ Image: "registry:8080/openshift/origin-deployer", |
|
| 235 | 235 |
}, |
| 236 | 236 |
}, |
| 237 | 237 |
ControllerTemplate: kapi.ReplicationControllerState{
|
| ... | ... |
@@ -377,7 +377,10 @@ func changeDeploymentConfig() *deployapi.DeploymentConfig {
|
| 377 | 377 |
}, |
| 378 | 378 |
Template: deployapi.DeploymentTemplate{
|
| 379 | 379 |
Strategy: deployapi.DeploymentStrategy{
|
| 380 |
- Type: deployapi.DeploymentStrategyTypeBasic, |
|
| 380 |
+ Type: deployapi.DeploymentStrategyTypeCustomPod, |
|
| 381 |
+ CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
|
| 382 |
+ Image: "registry:8080/openshift/origin-deployer", |
|
| 383 |
+ }, |
|
| 381 | 384 |
}, |
| 382 | 385 |
ControllerTemplate: kapi.ReplicationControllerState{
|
| 383 | 386 |
Replicas: 1, |