Skip to content

Commit 778fce3

Browse files
authored
fix(controller): add backward compatibility for --metricsport flag (#4457)
* fix(controller): add backward compatibility for --metricsport flag. Fixes #4428 Add deprecated --metricsport flag alias to maintain backward compatibility with Helm charts while encouraging migration to --metricsPort. - Adds --metricsport as deprecated alias for --metricsPort - Shows deprecation warning when --metricsport is used - Maintains full backward compatibility with existing deployments Signed-off-by: puretension <rlrlfhtm5@gmail.com> * fix: correct JSONPath in inconclusive background analysis test - Change jsonPath from {$.json} to {$} to get full response - Update conditions to use result.json.status instead of result.status - Fixes flaky TestCanaryInconclusiveBackgroundAnalysis e2e test Signed-off-by: puretension <rlrlfhtm5@gmail.com> --------- Signed-off-by: puretension <rlrlfhtm5@gmail.com>
1 parent a40c40a commit 778fce3

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

cmd/rollouts-controller/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ func newCommand() *cobra.Command {
303303
command.Flags().StringVar(&logFormat, "logformat", "", "Set the logging format. One of: text|json")
304304
command.Flags().IntVar(&klogLevel, "kloglevel", 0, "Set the klog logging level")
305305
command.Flags().IntVar(&metricsPort, "metricsPort", controller.DefaultMetricsPort, "Set the port the metrics endpoint should be exposed over")
306+
command.Flags().IntVar(&metricsPort, "metricsport", controller.DefaultMetricsPort, "Set the port the metrics endpoint should be exposed over (deprecated, use --metricsPort)")
307+
command.Flags().MarkDeprecated("metricsport", "use --metricsPort instead")
306308
command.Flags().IntVar(&healthzPort, "healthzPort", controller.DefaultHealthzPort, "Set the port the healthz endpoint should be exposed over")
307309
command.Flags().StringVar(&instanceID, "instance-id", "", "Indicates which argo rollout objects the controller should operate on")
308310
command.Flags().Float32Var(&qps, "qps", defaults.DefaultQPS, "Maximum QPS (queries per second) to the K8s API server")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestMetricsPortFlagCompatibility(t *testing.T) {
10+
cmd := newCommand()
11+
12+
// Test that both flags are available
13+
metricsPortFlag := cmd.Flags().Lookup("metricsPort")
14+
assert.NotNil(t, metricsPortFlag, "metricsPort flag should exist")
15+
16+
metricsportFlag := cmd.Flags().Lookup("metricsport")
17+
assert.NotNil(t, metricsportFlag, "metricsport flag should exist for backward compatibility")
18+
19+
// Test that deprecated flag is marked as deprecated
20+
assert.True(t, metricsportFlag.Deprecated != "", "metricsport flag should be marked as deprecated")
21+
}

test/e2e/functional/analysistemplate-web-background-inconclusive.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ spec:
1111
- name: web
1212
interval: 7s
1313
inconclusiveLimit: 3
14-
successCondition: result.status == "success"
15-
failureCondition: result.status == "failure"
14+
successCondition: result.json.status == "success"
15+
failureCondition: result.json.status == "failure"
1616
provider:
1717
web:
1818
url: "{{args.url-val}}"
1919
method: POST
2020
jsonBody:
2121
status: "inconclusive"
22-
jsonPath: "{$.json}"
22+
jsonPath: "{$}"

0 commit comments

Comments
 (0)