summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--container/config_test.go21
-rw-r--r--internal/sdnotify/sdnotify.go14
2 files changed, 27 insertions, 8 deletions
diff --git a/container/config_test.go b/container/config_test.go
index fdc81fce..da3ca74a 100644
--- a/container/config_test.go
+++ b/container/config_test.go
@@ -15,9 +15,12 @@ func TestNewConfig_SuccessfulReading(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, c)
+ ll, err := container.ParseLogLevel(c.LogLevel)
+ assert.NoError(t, err)
+
assert.Equal(t, time.Second*10, c.GracePeriod)
assert.True(t, c.PrintGraph)
- assert.Equal(t, slog.LevelWarn, c.LogLevel)
+ assert.Equal(t, slog.LevelWarn, ll.Level())
}
func TestNewConfig_WithoutEndureKey(t *testing.T) {
@@ -28,9 +31,12 @@ func TestNewConfig_WithoutEndureKey(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, c)
+ ll, err := container.ParseLogLevel(c.LogLevel)
+ assert.NoError(t, err)
+
assert.Equal(t, time.Second*30, c.GracePeriod)
assert.False(t, c.PrintGraph)
- assert.Equal(t, slog.LevelError, c.LogLevel)
+ assert.Equal(t, slog.LevelError, ll.Level())
}
func TestNewConfig_LoggingLevels(t *testing.T) {
@@ -53,15 +59,16 @@ func TestNewConfig_LoggingLevels(t *testing.T) {
assert.NoError(t, cfgPlugin.Init())
c, err := container.NewConfig(tt.path)
+ assert.NotNil(t, c)
+ ll, err2 := container.ParseLogLevel(c.LogLevel)
if tt.wantError {
- assert.Nil(t, c)
- assert.Error(t, err)
- assert.Contains(t, err.Error(), "unknown log level")
+ assert.Error(t, err2)
+ assert.Contains(t, err2.Error(), "unknown log level")
} else {
assert.NoError(t, err)
- assert.NotNil(t, c)
- assert.Equal(t, tt.wantLevel, c.LogLevel)
+ assert.NoError(t, err2)
+ assert.Equal(t, tt.wantLevel, ll.Level())
}
})
}
diff --git a/internal/sdnotify/sdnotify.go b/internal/sdnotify/sdnotify.go
index d88c0e88..114284ee 100644
--- a/internal/sdnotify/sdnotify.go
+++ b/internal/sdnotify/sdnotify.go
@@ -96,7 +96,19 @@ func StartWatchdog(interval int, stopCh chan struct{}) {
case <-stopCh:
return
case <-ticker.C:
- _, _ = SdNotify(Watchdog)
+ supported, err := SdNotify(Watchdog)
+ if err != nil {
+ // notification supported, but failure happened, retry
+ continue
+ }
+ // notification not supported, stop
+ if !supported && err == nil {
+ return
+ }
+ // notification supported, data has been sent, continue
+ if supported && err == nil {
+ continue
+ }
}
}
}()