diff --git a/controller/instance_manager_controller.go b/controller/instance_manager_controller.go index 7ad59550cc..9237305308 100644 --- a/controller/instance_manager_controller.go +++ b/controller/instance_manager_controller.go @@ -521,10 +521,6 @@ func (imc *InstanceManagerController) isDateEngineCPUMaskApplied(im *longhorn.In } func (imc *InstanceManagerController) syncLogSettingsToInstanceManagerPod(im *longhorn.InstanceManager) error { - if types.IsDataEngineV1(im.Spec.DataEngine) { - return nil - } - if im.Status.CurrentState != longhorn.InstanceManagerStateRunning { return nil } @@ -536,7 +532,7 @@ func (imc *InstanceManagerController) syncLogSettingsToInstanceManagerPod(im *lo defer client.Close() settingNames := []types.SettingName{ - types.SettingNameV2DataEngineLogLevel, + types.SettingNameLogLevel, types.SettingNameV2DataEngineLogFlags, } @@ -547,15 +543,21 @@ func (imc *InstanceManagerController) syncLogSettingsToInstanceManagerPod(im *lo } switch settingName { - case types.SettingNameV2DataEngineLogLevel: - err = client.LogSetLevel(longhorn.DataEngineTypeV2, "spdk_tgt", setting.Value) + case types.SettingNameLogLevel: + if types.IsDataEngineV1(im.Spec.DataEngine) { + err = client.LogSetLevel(longhorn.DataEngineTypeV1, "", setting.Value) + } else { + err = client.LogSetLevel(longhorn.DataEngineTypeV2, "", setting.Value) + } if err != nil { - return errors.Wrapf(err, "failed to set log level for %v", settingName) + return errors.Wrapf(err, "failed to set instance-manager log level to %v, using setting %v", setting.Value, settingName) } case types.SettingNameV2DataEngineLogFlags: - err = client.LogSetFlags(longhorn.DataEngineTypeV2, "spdk_tgt", setting.Value) - if err != nil { - return errors.Wrapf(err, "failed to set log flags for %v", settingName) + if types.IsDataEngineV2(im.Spec.DataEngine) { + err = client.LogSetFlags(longhorn.DataEngineTypeV2, "spdk_tgt", setting.Value) + if err != nil { + return errors.Wrapf(err, "failed to set spdk_tgt log flags to %v, using setting %v", setting.Value, settingName) + } } } }