Skip to content

Commit 9a9361c

Browse files
committed
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>
1 parent 6cf05d9 commit 9a9361c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
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+
}

0 commit comments

Comments
 (0)