systemd-vaultd-update-secrets: fix case when user reload the service manually

main
Jörg Thalheim 2 years ago
parent f0fd03caca
commit 2ae36946ae

@ -32,16 +32,16 @@ func updateSecrets(serviceName, target string) error {
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
// wait for the file to be created // wait for the file to be created
fmt.Printf("waiting for %s to be created", jsonPath) log.Printf("waiting for %s to be created", jsonPath)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
continue continue
} }
return fmt.Errorf("failed to stat vault json file %s: %w", serviceName, err) return fmt.Errorf("failed to stat vault json file %s: %w", serviceName, err)
} }
if jsonStat.ModTime().Before(stat.ModTime()) { if jsonStat.ModTime().Before(stat.ModTime()) && i < 9 {
// wait for the file to be updated // wait for the file to be updated
fmt.Printf("waiting for %s to be updated", jsonPath) log.Printf("waiting for %s to be updated", jsonPath)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
continue continue
} }
@ -50,7 +50,7 @@ func updateSecrets(serviceName, target string) error {
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
// wait for the file to be created // wait for the file to be created
fmt.Printf("waiting for %s to be created", jsonPath) log.Printf("waiting for %s to be created", jsonPath)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
continue continue
} }

Loading…
Cancel
Save