From fba813c084937c1e1c648a64c9aebf0d453d04aa Mon Sep 17 00:00:00 2001 From: googs1025 Date: Sun, 8 Dec 2024 21:30:56 +0800 Subject: [PATCH] fix(event): fix event display problem Signed-off-by: googs1025 --- pkg/upgrade/drain_manager.go | 4 ++-- pkg/upgrade/node_upgrade_state_provider.go | 12 ++++++------ pkg/upgrade/pod_manager.go | 8 ++++---- pkg/upgrade/validation_manager.go | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/upgrade/drain_manager.go b/pkg/upgrade/drain_manager.go index d8814048..ba52443e 100644 --- a/pkg/upgrade/drain_manager.go +++ b/pkg/upgrade/drain_manager.go @@ -112,7 +112,7 @@ func (m *DrainManagerImpl) ScheduleNodesDrain(ctx context.Context, drainConfig * m.log.V(consts.LogLevelError).Error(err, "Failed to cordon node", "node", node.Name) _ = m.nodeUpgradeStateProvider.ChangeNodeUpgradeState(ctx, node, UpgradeStateFailed) logEventf(m.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(), - "Failed to cordon the node, %s", err.Error()) + fmt.Sprintf("Failed to cordon the node, %s", err.Error())) return } m.log.V(consts.LogLevelInfo).Info("Cordoned the node", "node", node.Name) @@ -122,7 +122,7 @@ func (m *DrainManagerImpl) ScheduleNodesDrain(ctx context.Context, drainConfig * m.log.V(consts.LogLevelError).Error(err, "Failed to drain node", "node", node.Name) _ = m.nodeUpgradeStateProvider.ChangeNodeUpgradeState(ctx, node, UpgradeStateFailed) logEventf(m.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(), - "Failed to drain the node, %s", err.Error()) + fmt.Sprintf("Failed to drain the node, %s", err.Error())) return } m.log.V(consts.LogLevelInfo).Info("Drained the node", "node", node.Name) diff --git a/pkg/upgrade/node_upgrade_state_provider.go b/pkg/upgrade/node_upgrade_state_provider.go index e6e1760b..70b6d1b1 100644 --- a/pkg/upgrade/node_upgrade_state_provider.go +++ b/pkg/upgrade/node_upgrade_state_provider.go @@ -85,7 +85,7 @@ func (p *NodeUpgradeStateProviderImpl) ChangeNodeUpgradeState( "node", node, "state", newNodeState) logEventf(p.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(), - "Failed to update node state label to %s, %s", newNodeState, err.Error()) + fmt.Sprintf("Failed to update node state label to %s, %s", newNodeState, err.Error())) return err } @@ -121,13 +121,13 @@ func (p *NodeUpgradeStateProviderImpl) ChangeNodeUpgradeState( "node", node, "state", newNodeState) logEventf(p.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(), - "Failed to update node state label to %s, %s", newNodeState, err.Error()) + fmt.Sprintf("Failed to update node state label to %s, %s", newNodeState, err.Error())) } else { p.Log.V(consts.LogLevelInfo).Info("Successfully changed node upgrade state label", "node", node.Name, "new state", newNodeState) logEventf(p.eventRecorder, node, corev1.EventTypeNormal, GetEventReason(), - "Successfully updated node state label to %s", newNodeState) + fmt.Sprintf("Successfully updated node state label to %s", newNodeState)) } return err @@ -156,7 +156,7 @@ func (p *NodeUpgradeStateProviderImpl) ChangeNodeUpgradeAnnotation( "annotationKey", key, "annotationValue", value) logEventf(p.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(), - "Failed to update node annotation %s=%s: %s", key, value, err.Error()) + fmt.Sprintf("Failed to update node annotation %s=%s: %s", key, value, err.Error())) return err } @@ -202,14 +202,14 @@ func (p *NodeUpgradeStateProviderImpl) ChangeNodeUpgradeAnnotation( "annotationKey", key, "annotationValue", value) logEventf(p.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(), - "Failed to update node annotation to %s=%s: %s", key, value, err.Error()) + fmt.Sprintf("Failed to update node annotation to %s=%s: %s", key, value, err.Error())) } else { p.Log.V(consts.LogLevelInfo).Info("Successfully changed node upgrade state annotation", "node", node.Name, "annotationKey", key, "annotationValue", value) logEventf(p.eventRecorder, node, corev1.EventTypeNormal, GetEventReason(), - "Successfully updated node annotation to %s=%s", key, value) + fmt.Sprintf("Successfully updated node annotation to %s=%s", key, value)) } return err diff --git a/pkg/upgrade/pod_manager.go b/pkg/upgrade/pod_manager.go index f704ede4..e1b3a633 100644 --- a/pkg/upgrade/pod_manager.go +++ b/pkg/upgrade/pod_manager.go @@ -214,7 +214,7 @@ func (m *PodManagerImpl) SchedulePodEviction(ctx context.Context, config *PodMan if err != nil { m.log.V(consts.LogLevelError).Error(err, "Failed to delete pods on the node", "node", node.Name) logEventf(m.eventRecorder, &node, corev1.EventTypeWarning, GetEventReason(), - "Failed to delete workload pods on the node for the driver upgrade, %s", err.Error()) + fmt.Sprintf("Failed to delete workload pods on the node for the driver upgrade, %s", err.Error())) m.updateNodeToDrainOrFailed(ctx, node, config.DrainEnabled) return } @@ -246,7 +246,7 @@ func (m *PodManagerImpl) SchedulePodsRestart(ctx context.Context, pods []*corev1 if err != nil { m.log.V(consts.LogLevelInfo).Error(err, "Failed to delete pod", "pod", pod.Name) logEventf(m.eventRecorder, pod, corev1.EventTypeWarning, GetEventReason(), - "Failed to restart driver pod %s", err.Error()) + fmt.Sprintf("Failed to restart driver pod %s", err.Error())) return err } } @@ -294,7 +294,7 @@ func (m *PodManagerImpl) ScheduleCheckOnPodCompletion(ctx context.Context, confi err = m.HandleTimeoutOnPodCompletions(ctx, &node, int64(config.WaitForCompletionSpec.TimeoutSecond)) if err != nil { logEventf(m.eventRecorder, &node, corev1.EventTypeWarning, GetEventReason(), - "Failed to handle timeout for job completions, %s", err.Error()) + fmt.Sprintf("Failed to handle timeout for job completions, %s", err.Error())) return } } @@ -305,7 +305,7 @@ func (m *PodManagerImpl) ScheduleCheckOnPodCompletion(ctx context.Context, confi err = m.nodeUpgradeStateProvider.ChangeNodeUpgradeAnnotation(ctx, &node, annotationKey, "null") if err != nil { logEventf(m.eventRecorder, &node, corev1.EventTypeWarning, GetEventReason(), - "Failed to remove annotation used to track job completions: %s", err.Error()) + fmt.Sprintf("Failed to remove annotation used to track job completions: %s", err.Error())) return } // update node state diff --git a/pkg/upgrade/validation_manager.go b/pkg/upgrade/validation_manager.go index f3ec7027..bc40e99f 100644 --- a/pkg/upgrade/validation_manager.go +++ b/pkg/upgrade/validation_manager.go @@ -97,7 +97,7 @@ func (m *ValidationManagerImpl) Validate(ctx context.Context, node *corev1.Node) err = m.handleTimeout(ctx, node, int64(validationTimeoutSeconds)) if err != nil { logEventf(m.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(), - "Failed to handle timeout for validation state", err.Error()) + fmt.Sprintf("Failed to handle timeout for validation state: %s", err.Error())) return false, fmt.Errorf("unable to handle timeout for validation state: %v", err) } done = false