Skip to content

Commit

Permalink
fix(logging): make RPC call to instance-manager to set log level
Browse files Browse the repository at this point in the history
Signed-off-by: James Munson <[email protected]>
  • Loading branch information
james-munson committed Nov 22, 2024
1 parent e0b9f14 commit 95f3152
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 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,7 +532,7 @@ func (imc *InstanceManagerController) syncLogSettingsToInstanceManagerPod(im *lo
defer client.Close()

settingNames := []types.SettingName{
types.SettingNameV2DataEngineLogLevel,
types.SettingNameLogLevel,
types.SettingNameV2DataEngineLogFlags,
}

Expand All @@ -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)
}
}
}
}
Expand Down

0 comments on commit 95f3152

Please sign in to comment.