Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logging): make RPC call to instance-manager to set log level #3280

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions controller/instance_manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -536,6 +532,7 @@ func (imc *InstanceManagerController) syncLogSettingsToInstanceManagerPod(im *lo
defer client.Close()

settingNames := []types.SettingName{
types.SettingNameLogLevel,
types.SettingNameV2DataEngineLogLevel,
types.SettingNameV2DataEngineLogFlags,
james-munson marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -547,15 +544,26 @@ func (imc *InstanceManagerController) syncLogSettingsToInstanceManagerPod(im *lo
}

switch settingName {
case types.SettingNameV2DataEngineLogLevel:
err = client.LogSetLevel(longhorn.DataEngineTypeV2, "spdk_tgt", setting.Value)
case types.SettingNameLogLevel:
// We use this to set the instance-manager log level, for either engine type.
err = client.LogSetLevel("", "", 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 setting %v value: %v", settingName, setting.Value)
}
case types.SettingNameV2DataEngineLogLevel:
// We use this to set the spdk_tgt log level independently of the instance-manager's.
if types.IsDataEngineV2(im.Spec.DataEngine) {
err = client.LogSetLevel(longhorn.DataEngineTypeV2, "", setting.Value)
if err != nil {
return errors.Wrapf(err, "failed to set spdk_tgt log level to setting %v value: %v", settingName, setting.Value)
}
}
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 setting %v value: %v", settingName, setting.Value)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion controller/setting_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ func (sc *SettingController) updateLogLevel(settingName types.SettingName) error
return err
}
if oldLevel != newLevel {
logrus.Infof("Updating log level from %v to %v", oldLevel, newLevel)
logrus.Warnf("Updating log level from %v to %v", oldLevel, newLevel)
logrus.SetLevel(newLevel)
}

Expand Down
Loading