Skip to content

Commit 756e15b

Browse files
Merge pull request #18809 from tnozicka/fix-dc-selectors-in-scale-endpoint
Automatic merge from submit-queue. Fix DC selectors for autoscaling Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1544496 Hotfix before #18640 /cc @mfojtik @liggitt @DirectXMan12
2 parents c7e8dd2 + 1592b65 commit 756e15b

File tree

1 file changed

+10
-1
lines changed
  • pkg/apps/registry/deployconfig/etcd

1 file changed

+10
-1
lines changed

pkg/apps/registry/deployconfig/etcd/etcd.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ func (r *ScaleREST) Update(ctx apirequest.Context, name string, objInfo rest.Upd
139139

140140
// scaleFromConfig builds a scale resource out of a deployment config.
141141
func scaleFromConfig(dc *appsapi.DeploymentConfig) *autoscaling.Scale {
142+
// We need to make sure that the implicit selector won't have invalid value specified by user.
143+
// Should be fixed globally in https://github.com/openshift/origin/pull/18640
144+
selector := map[string]string{}
145+
// Copy the map not to pollute the one on DC
146+
for k, v := range dc.Spec.Selector {
147+
selector[k] = v
148+
}
149+
selector[appsapi.DeploymentConfigLabel] = dc.Name
150+
142151
return &autoscaling.Scale{
143152
ObjectMeta: metav1.ObjectMeta{
144153
Name: dc.Name,
@@ -152,7 +161,7 @@ func scaleFromConfig(dc *appsapi.DeploymentConfig) *autoscaling.Scale {
152161
},
153162
Status: autoscaling.ScaleStatus{
154163
Replicas: dc.Status.Replicas,
155-
Selector: labels.Set(dc.Spec.Selector).String(),
164+
Selector: labels.Set(selector).String(),
156165
},
157166
}
158167
}

0 commit comments

Comments
 (0)