Skip to content

Commit de12586

Browse files
Merge pull request #18524 from tnozicka/backport-dc-trigger-reconciliation-on-image-change-release-3.7
Automatic merge from submit-queue. [3.7] Backport dc trigger reconciliation on image change release - fixup import and variable names to avoid conflicts with backports - backport https://github.com/openshift/origin/pull/17539/commits - backport https://github.com/openshift/origin/pull/18118/commits /cc @mfojtik @ironcladlou
2 parents f28eb2e + 030fac4 commit de12586

File tree

9 files changed

+967
-599
lines changed

9 files changed

+967
-599
lines changed

pkg/apps/controller/deployer/deployer_controller.go

+77-77
Large diffs are not rendered by default.

pkg/apps/controller/deployer/deployer_controller_test.go

+129-129
Large diffs are not rendered by default.

pkg/apps/controller/deploymentconfig/deploymentconfig_controller.go

+138-128
Large diffs are not rendered by default.

pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go

+135-108
Large diffs are not rendered by default.

pkg/image/trigger/deploymentconfigs/deploymentconfigs.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,19 @@ func (i deploymentConfigTriggerIndexer) Index(obj, old interface{}) (string, *tr
127127
default:
128128
// updated
129129
dc = obj.(*appsapi.DeploymentConfig)
130+
oldDC := old.(*appsapi.DeploymentConfig)
130131
triggers = calculateDeploymentConfigTriggers(dc)
131-
oldTriggers := calculateDeploymentConfigTriggers(old.(*appsapi.DeploymentConfig))
132+
oldTriggers := calculateDeploymentConfigTriggers(oldDC)
132133
switch {
133134
case len(oldTriggers) == 0:
134135
change = cache.Added
135136
case !reflect.DeepEqual(oldTriggers, triggers):
136137
change = cache.Updated
138+
// We need to react on image changes as well. Image names could change,
139+
// images could be set to different value or resetted to "" e.g. by oc apply
140+
// and we need to make sure those changes get reconciled by re-resolving images
141+
case !reflect.DeepEqual(dc.Spec.Template.Spec.Containers, oldDC.Spec.Template.Spec.Containers):
142+
change = cache.Updated
137143
}
138144
}
139145

@@ -190,9 +196,6 @@ func UpdateDeploymentConfigImages(dc *appsapi.DeploymentConfig, tagRetriever tri
190196
glog.V(4).Infof("trigger %#v in deployment %s is not resolveable", p, dc.Name)
191197
return nil, false, nil
192198
}
193-
if ref == p.LastTriggeredImage {
194-
continue
195-
}
196199

197200
if len(ref) == 0 {
198201
ref = p.LastTriggeredImage

test/extended/deployments/deployments.go

+344-24
Large diffs are not rendered by default.

test/extended/deployments/util.go

+81-67
Large diffs are not rendered by default.

test/extended/testdata/bindata.go

+28-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
apiVersion: v1
2-
kind: List
3-
items:
4-
- apiVersion: v1
5-
kind: DeploymentConfig
6-
metadata:
7-
labels:
8-
app: example
9-
name: example
10-
spec:
11-
replicas: 1
12-
template:
13-
metadata:
14-
labels:
15-
app: example
16-
spec:
17-
containers:
18-
- imagePullPolicy: Always
19-
name: test
20-
command:
21-
- /bin/sleep
22-
- "100"
23-
test: false
24-
triggers:
25-
- imageChangeParams:
26-
automatic: true
27-
containerNames:
28-
- test
29-
from:
30-
kind: ImageStreamTag
31-
name: test:v1
32-
type: ImageChange
2+
kind: DeploymentConfig
3+
metadata:
4+
labels:
5+
app: example
6+
name: example
7+
spec:
8+
replicas: 1
9+
template:
10+
metadata:
11+
labels:
12+
app: example
13+
spec:
14+
containers:
15+
- imagePullPolicy: Always
16+
name: test
17+
command:
18+
- /bin/sleep
19+
- "100"
20+
test: false
21+
triggers:
22+
- imageChangeParams:
23+
automatic: true
24+
containerNames:
25+
- test
26+
from:
27+
kind: ImageStreamTag
28+
name: test:v1
29+
type: ImageChange

0 commit comments

Comments
 (0)