From 4dbba5b1c1036acdbc35f01982b0f15fa00f5dc4 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Mon, 29 Apr 2024 06:02:35 +0000 Subject: [PATCH] Only sync log settings to running instance manager pod No need to sync log settings to non-running instance manager pod for avoiding flooding warning messages. Longhorn 8466 Signed-off-by: Derek Su --- controller/instance_manager_controller.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/controller/instance_manager_controller.go b/controller/instance_manager_controller.go index 39f5fa0d97..a4cb4ecd8b 100644 --- a/controller/instance_manager_controller.go +++ b/controller/instance_manager_controller.go @@ -455,11 +455,15 @@ func (imc *InstanceManagerController) syncInstanceStatus(im *longhorn.InstanceMa return nil } -func (imc *InstanceManagerController) syncLogSettingsToIMPod(im *longhorn.InstanceManager) error { +func (imc *InstanceManagerController) syncLogSettingsToInstanceManagerPod(im *longhorn.InstanceManager) error { if types.IsDataEngineV1(im.Spec.DataEngine) { return nil } + if im.Status.CurrentState != longhorn.InstanceManagerStateRunning { + return nil + } + client, err := engineapi.NewInstanceManagerClient(im) if err != nil { return errors.Wrapf(err, "failed to create instance manager client for %v", im.Name) @@ -501,9 +505,9 @@ func (imc *InstanceManagerController) handlePod(im *longhorn.InstanceManager) er return err } - err = imc.syncLogSettingsToIMPod(im) + err = imc.syncLogSettingsToInstanceManagerPod(im) if err != nil { - log.WithError(err).Warnf("Failed to sync log settings to instance manager pod") + log.WithError(err).Warnf("Failed to sync log settings to instance manager pod %v", im.Name) } isSettingSynced, isPodDeletedOrNotRunning, areInstancesRunningInPod, err := imc.areDangerZoneSettingsSyncedToIMPod(im)