Skip to content

Commit

Permalink
[-] fix --retry-num parameter handling, fixes #272 (#280)
Browse files Browse the repository at this point in the history
* Fix retry-num parameter handling.

This introduces --retry-num and --retry-after command-line parameters
and makes sure the value for `retry-num' is more than zero as otherwise
the ARP client is not being launched.

Fixes: #272

* use pflag.Int() for integer parameters

---------

Co-authored-by: Michael Banck <[email protected]>
  • Loading branch information
pashagolub and mbanck-ntap authored Nov 19, 2024
1 parent c32449e commit bf9fece
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions vipconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ func defineFlags() {

pflag.String("consul-token", "", "Token for consul DCS endpoints.")

pflag.String("interval", "1000", "DCS scan interval in milliseconds.")
pflag.Int("interval", 1000, "DCS scan interval in milliseconds.")
pflag.String("manager-type", "basic", "Type of VIP-management to be used. Supported values: basic, hetzner.")

pflag.Int("retry-after", 250, "Time to wait before retrying interactions with outside components in milliseconds.")
pflag.Int("retry-num", 3, "Number of times interactions with outside components are retried.")

pflag.Bool("verbose", false, "Be verbose. Currently only implemented for manager-type=hetzner .")

pflag.CommandLine.SortFlags = false
Expand Down Expand Up @@ -153,12 +156,12 @@ func mapDeprecated() error {
}

func setDefaults() {
defaults := map[string]string{
"dcs-type": "etcd",
"interval": "1000",
defaults := map[string]any{
"hostingtype": "basic",
"retry-num": "3",
"retry-after": "250",
"dcs-type": "etcd",
"interval": 1000,
"retry-after": 250,
"retry-num": 3,
}

for k, v := range defaults {
Expand Down Expand Up @@ -200,6 +203,11 @@ func setDefaults() {
viper.Set("trigger-value", triggerValue)
}
}

// set retry-num to default if not set or set to zero
if retryNum := viper.GetInt("retry-num"); retryNum <= 0 {
viper.Set("retry-num", 3)
}
}

func checkSetting(name string) bool {
Expand Down

0 comments on commit bf9fece

Please sign in to comment.