Skip to content

Commit

Permalink
fix revision missing for reverse translation. (istio#30206)
Browse files Browse the repository at this point in the history
* fix revision missing for reverse translation.

* update test cases.

* add releasenote.
  • Loading branch information
morvencao authored Jan 20, 2021
1 parent 68d5c3f commit ab85aab
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
8 changes: 8 additions & 0 deletions operator/pkg/translate/translate_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ func translateHPASpec(inPath string, outPath string, valueTree map[string]interf

// There is no direct source from value.yaml for scaleTargetRef value, we need to construct from component name
if found {
revision := ""
rev, ok := cpSpecTree["revision"]
if ok {
revision = rev.(string)
}
st := make(map[string]interface{})
stVal := `
apiVersion: apps/v1
Expand All @@ -460,6 +465,9 @@ name: %s`
// convert from values component name to correct deployment target
if newPS == "pilot" {
newPS = "istiod"
if revision != "" {
newPS = newPS + "-" + revision
}
}
stString := fmt.Sprintf(stVal, newPS)
if err := yaml.Unmarshal([]byte(stString), &st); err != nil {
Expand Down
42 changes: 42 additions & 0 deletions operator/pkg/translate/translate_value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,48 @@ spec:
hub: docker.io/istio
tag: 1.2.3
istioNamespace: istio-system
`,
},
{
desc: "pilot env k8s setting with non-empty hpa values",
inIOPSpec: `
spec:
revision: canary
components:
pilot:
enabled: true
values:
pilot:
autoscaleMin: 1
autoscaleMax: 3
cpu:
targetAverageUtilization: 80
`,
want: `
spec:
revision: canary
components:
pilot:
enabled: true
k8s:
hpaSpec:
maxReplicas: 3
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: istiod-canary
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
values:
pilot:
autoscaleMin: 1
autoscaleMax: 3
cpu:
targetAverageUtilization: 80
`,
},
}
Expand Down
9 changes: 9 additions & 0 deletions releasenotes/notes/30203.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: release-notes/v2
kind: bug-fix
area: installation
issue:
- 30203
releaseNotes:
- |
**Fixed** revision is not applied to the scale target reference of HorizontalPodAutoscaler when helm values for hpa are specified explicitly.

0 comments on commit ab85aab

Please sign in to comment.