Skip to content

Commit f4c84d4

Browse files
authored
fix: Fix common config bootstrap startup failed in no-secty mode (#5237)
* fix: Fix common config bootstrap startup failed in no-secty mode Add retry logic to wait for core-keeper available, the config bootstrap will retry to send put request to core-keeper if failed. fix #5236 Signed-off-by: bruce <[email protected]> * refactor: refactor the retry function refactor the retry function fix #5236 Signed-off-by: bruce <[email protected]> --------- Signed-off-by: bruce <[email protected]>
1 parent 4476c2f commit f4c84d4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/core/common_config/main.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ package common_config
1818
import (
1919
"context"
2020
"fmt"
21-
"gopkg.in/yaml.v3"
2221
"net/http"
2322
"os"
2423
"os/signal"
2524
"sync"
2625
"syscall"
2726

27+
"gopkg.in/yaml.v3"
28+
2829
"github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/config"
2930
"github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/container"
3031
"github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/environment"
@@ -98,9 +99,16 @@ func Main(ctx context.Context, cancel context.CancelFunc, args []string) {
9899
}
99100

100101
// push not done flag to configClient
101-
err = configClient.PutConfigurationValue(commonConfigDone, []byte(common.ValueFalse))
102+
for startupTimer.HasNotElapsed() { // Since common config bootstrap depends on the core-keeper, add a retry mechanism to ensure the core-keeper has started
103+
err = configClient.PutConfigurationValue(commonConfigDone, []byte(common.ValueFalse))
104+
if err == nil {
105+
break
106+
}
107+
lc.Warnf("Failed to push %s on startup, will try again: %s", commonConfigDone, err.Error())
108+
startupTimer.SleepForInterval()
109+
}
102110
if err != nil {
103-
lc.Errorf("failed to push %s on startup: %s", commonConfigDone, err.Error())
111+
lc.Errorf("Failed to push %s on startup: %s", commonConfigDone, err.Error())
104112
os.Exit(1)
105113
}
106114

0 commit comments

Comments
 (0)