Skip to content

Commit d3cdba1

Browse files
authored
fix(translator): Add translate threshold in upstream policy translation (#7784)
* add translate threshold in upstream policy translation * update changelog * Thanks to the contribution from elbrogan-vizio(@elbrogan-vizio) by PR #7756
1 parent 2bb2029 commit d3cdba1

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Adding a new version? You'll need three changes:
121121
DBLess mode in the translator of ingress-controller. This enables user to use
122122
explicit `null`s in plugins.
123123
[#7751](https://github.com/Kong/kubernetes-ingress-controller/pull/7751)
124+
- Translate `healtchchecks.thershold` in `KongUpstreamPolicy` to the
125+
`healthchecks.thershold` field in Kong upstreams.
126+
(Thanks to [@elbrogan-vizio](https://github.com/elbrogan-vizio) who contributed to the fix.)
127+
[#7784](https://github.com/Kong/kubernetes-ingress-controller/pull/7784)
124128

125129
## [3.5.2]
126130

internal/dataplane/kongstate/kongupstreampolicy.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ func translateHealthchecks(healthchecks *configurationv1beta1.KongUpstreamHealth
171171
return nil
172172
}
173173
return &kong.Healthcheck{
174-
Active: translateActiveHealthcheck(healthchecks.Active),
175-
Passive: translatePassiveHealthcheck(healthchecks.Passive),
174+
Active: translateActiveHealthcheck(healthchecks.Active),
175+
Passive: translatePassiveHealthcheck(healthchecks.Passive),
176+
Threshold: translateThreshold(healthchecks.Threshold),
176177
}
177178
}
178179

@@ -204,6 +205,13 @@ func translatePassiveHealthcheck(healthcheck *configurationv1beta1.KongUpstreamP
204205
}
205206
}
206207

208+
func translateThreshold(threshold *int) *float64 {
209+
if threshold == nil {
210+
return nil
211+
}
212+
return lo.ToPtr(float64(*threshold))
213+
}
214+
207215
func translateHealthy(healthy *configurationv1beta1.KongUpstreamHealthcheckHealthy) *kong.Healthy {
208216
if healthy == nil {
209217
return nil

internal/dataplane/kongstate/kongupstreampolicy_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func TestTranslateKongUpstreamPolicy(t *testing.T) {
383383
Timeouts: lo.ToPtr(120),
384384
},
385385
},
386-
Threshold: lo.ToPtr(140),
386+
Threshold: lo.ToPtr(15),
387387
},
388388
},
389389
expectedUpstream: &kong.Upstream{
@@ -418,6 +418,7 @@ func TestTranslateKongUpstreamPolicy(t *testing.T) {
418418
Timeouts: lo.ToPtr(120),
419419
},
420420
},
421+
Threshold: lo.ToPtr(15.0),
421422
},
422423
},
423424
},

test/kongintegration/kongupstreampolicy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func TestKongUpstreamPolicyTranslation(t *testing.T) {
175175
Timeouts: lo.ToPtr(120),
176176
},
177177
},
178-
Threshold: lo.ToPtr(140),
178+
Threshold: lo.ToPtr(10),
179179
},
180180
},
181181
expectedUpstream: &kong.Upstream{
@@ -214,7 +214,7 @@ func TestKongUpstreamPolicyTranslation(t *testing.T) {
214214
Timeouts: lo.ToPtr(120),
215215
},
216216
},
217-
Threshold: lo.ToPtr(0.),
217+
Threshold: lo.ToPtr(10.0),
218218
},
219219
},
220220
},

0 commit comments

Comments
 (0)