diff --git a/docs/code-standards.md b/docs/code-standards.md index 9223c609b..3f7622e02 100644 --- a/docs/code-standards.md +++ b/docs/code-standards.md @@ -41,7 +41,7 @@ klog.ErrorDepth(5, fmt.Errorf("failed to get ehpa %s: %v", klog.KObj(ehpa), err) - consider failure paths and success paths - event do not need the object key ```go -c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedGetSubstitute", err.Error()) +c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedGetSubstitute", err.Error()) ``` ### comment diff --git a/pkg/controller/ehpa/effective_hpa_controller.go b/pkg/controller/ehpa/effective_hpa_controller.go index 142bec969..70c6d6deb 100644 --- a/pkg/controller/ehpa/effective_hpa_controller.go +++ b/pkg/controller/ehpa/effective_hpa_controller.go @@ -55,7 +55,7 @@ func (c *EffectiveHPAController) Reconcile(ctx context.Context, req ctrl.Request scale, mapping, err := utils.GetScale(ctx, c.RestMapper, c.ScaleClient, ehpa.Namespace, ehpa.Spec.ScaleTargetRef) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedGetScale", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedGetScale", err.Error()) klog.Errorf("Failed to get scale, ehpa %s", klog.KObj(ehpa)) setCondition(newStatus, autoscalingapi.Ready, metav1.ConditionFalse, "FailedGetScale", "Failed to get scale") c.UpdateStatus(ctx, ehpa, newStatus) @@ -132,7 +132,7 @@ func (c *EffectiveHPAController) Reconcile(ctx context.Context, req ctrl.Request scale.Spec.Replicas = *ehpa.Spec.SpecificReplicas updatedScale, err := c.ScaleClient.Scales(scale.Namespace).Update(ctx, mapping.Resource.GroupResource(), scale, metav1.UpdateOptions{}) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedManualScale", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedManualScale", err.Error()) msg := fmt.Sprintf("Failed to manual scale target to specific replicas, ehpa %s replicas %d", klog.KObj(ehpa), *ehpa.Spec.SpecificReplicas) klog.Error(err, msg) setCondition(newStatus, autoscalingapi.Ready, metav1.ConditionFalse, "FailedScale", msg) @@ -156,7 +156,7 @@ func (c *EffectiveHPAController) UpdateStatus(ctx context.Context, ehpa *autosca ehpa.Status = *newStatus err := c.Status().Update(ctx, ehpa) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedUpdateStatus", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedUpdateStatus", err.Error()) klog.Errorf("Failed to update status, ehpa %s error %v", klog.KObj(ehpa), err) return } diff --git a/pkg/controller/ehpa/hpa.go b/pkg/controller/ehpa/hpa.go index 31382b57f..5abb2822b 100644 --- a/pkg/controller/ehpa/hpa.go +++ b/pkg/controller/ehpa/hpa.go @@ -33,7 +33,7 @@ func (c *EffectiveHPAController) ReconcileHPA(ctx context.Context, ehpa *autosca if errors.IsNotFound(err) { return c.CreateHPA(ctx, ehpa, substitute, tsp) } else { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedGetHPA", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedGetHPA", err.Error()) klog.Errorf("Failed to get HPA, ehpa %s error %v", klog.KObj(ehpa), err) return nil, err } @@ -62,14 +62,14 @@ func (c *EffectiveHPAController) GetHPA(ctx context.Context, ehpa *autoscalingap func (c *EffectiveHPAController) CreateHPA(ctx context.Context, ehpa *autoscalingapi.EffectiveHorizontalPodAutoscaler, substitute *autoscalingapi.Substitute, tsp *predictionapi.TimeSeriesPrediction) (*autoscalingv2.HorizontalPodAutoscaler, error) { hpa, err := c.NewHPAObject(ctx, ehpa, substitute, tsp) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreateHPAObject", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreateHPAObject", err.Error()) klog.Errorf("Failed to create object, HorizontalPodAutoscaler %s error %v", klog.KObj(hpa), err) return nil, err } err = c.Client.Create(ctx, hpa) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreateHPA", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreateHPA", err.Error()) klog.Errorf("Failed to create HorizontalPodAutoscaler %s, error %v", klog.KObj(hpa), err) return nil, err } @@ -140,7 +140,7 @@ func (c *EffectiveHPAController) UpdateHPAIfNeed(ctx context.Context, ehpa *auto var needUpdate bool hpa, err := c.NewHPAObject(ctx, ehpa, substitute, tsp) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreateHPAObject", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreateHPAObject", err.Error()) klog.Errorf("Failed to create object, HorizontalPodAutoscaler %s error %v", klog.KObj(hpa), err) return nil, err } @@ -163,7 +163,7 @@ func (c *EffectiveHPAController) UpdateHPAIfNeed(ctx context.Context, ehpa *auto if needUpdate { err := c.Update(ctx, hpaExist) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedUpdateHPA", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedUpdateHPA", err.Error()) klog.Errorf("Failed to update HorizontalPodAutoscaler %s error %v", klog.KObj(hpaExist), err) return nil, err } diff --git a/pkg/controller/ehpa/predict.go b/pkg/controller/ehpa/predict.go index 862b86e71..f9fee9eb5 100644 --- a/pkg/controller/ehpa/predict.go +++ b/pkg/controller/ehpa/predict.go @@ -31,7 +31,7 @@ func (c *EffectiveHPAController) ReconcilePredication(ctx context.Context, ehpa if errors.IsNotFound(err) { return c.CreatePrediction(ctx, ehpa) } else { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedGetPrediction", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedGetPrediction", err.Error()) klog.Errorf("Failed to get TimeSeriesPrediction, ehpa %s error %v", klog.KObj(ehpa), err) return nil, err } @@ -60,14 +60,14 @@ func (c *EffectiveHPAController) GetPredication(ctx context.Context, ehpa *autos func (c *EffectiveHPAController) CreatePrediction(ctx context.Context, ehpa *autoscalingapi.EffectiveHorizontalPodAutoscaler) (*predictionapi.TimeSeriesPrediction, error) { prediction, err := c.NewPredictionObject(ehpa) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreatePredictionObject", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreatePredictionObject", err.Error()) klog.Errorf("Failed to create object, TimeSeriesPrediction %s error %v", klog.KObj(prediction), err) return nil, err } err = c.Client.Create(ctx, prediction) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreatePrediction", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreatePrediction", err.Error()) klog.Errorf("Failed to create TimeSeriesPrediction %s error %v", klog.KObj(prediction), err) return nil, err } @@ -81,7 +81,7 @@ func (c *EffectiveHPAController) CreatePrediction(ctx context.Context, ehpa *aut func (c *EffectiveHPAController) UpdatePredictionIfNeed(ctx context.Context, ehpa *autoscalingapi.EffectiveHorizontalPodAutoscaler, predictionExist *predictionapi.TimeSeriesPrediction) (*predictionapi.TimeSeriesPrediction, error) { prediction, err := c.NewPredictionObject(ehpa) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreatePredictionObject", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreatePredictionObject", err.Error()) klog.Errorf("Failed to create object, TimeSeriesPrediction %s error %v", klog.KObj(prediction), err) return nil, err } @@ -90,7 +90,7 @@ func (c *EffectiveHPAController) UpdatePredictionIfNeed(ctx context.Context, ehp predictionExist.Spec = prediction.Spec err := c.Update(ctx, predictionExist) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedUpdatePrediction", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedUpdatePrediction", err.Error()) klog.Errorf("Failed to update TimeSeriesPrediction %s", klog.KObj(predictionExist)) return nil, err } diff --git a/pkg/controller/ehpa/substitute.go b/pkg/controller/ehpa/substitute.go index d90eb67f2..9f67586bf 100644 --- a/pkg/controller/ehpa/substitute.go +++ b/pkg/controller/ehpa/substitute.go @@ -28,7 +28,7 @@ func (c *EffectiveHPAController) ReconcileSubstitute(ctx context.Context, ehpa * if errors.IsNotFound(err) { return c.CreateSubstitute(ctx, ehpa, scale) } else { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedGetSubstitute", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedGetSubstitute", err.Error()) klog.Errorf("Failed to get Substitute, ehpa %s error %v", klog.KObj(ehpa), err) return nil, err } @@ -42,14 +42,14 @@ func (c *EffectiveHPAController) ReconcileSubstitute(ctx context.Context, ehpa * func (c *EffectiveHPAController) CreateSubstitute(ctx context.Context, ehpa *autoscalingapi.EffectiveHorizontalPodAutoscaler, scale *autoscalingapiv1.Scale) (*autoscalingapi.Substitute, error) { substitute, err := c.NewSubstituteObject(ehpa, scale) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreateSubstituteObject", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreateSubstituteObject", err.Error()) klog.Errorf("Failed to create object, Substitute %s error %v", klog.KObj(substitute), err) return nil, err } err = c.Client.Create(ctx, substitute) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreateSubstitute", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedCreateSubstitute", err.Error()) klog.Errorf("Failed to create Substitute %s error %v", klog.KObj(substitute), err) return nil, err } @@ -92,7 +92,7 @@ func (c *EffectiveHPAController) UpdateSubstituteIfNeed(ctx context.Context, ehp substituteExist.Spec.SubstituteTargetRef = ehpa.Spec.ScaleTargetRef err := c.Update(ctx, substituteExist) if err != nil { - c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedUpdateSubstitute", err.Error()) + c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedUpdateSubstitute", err.Error()) klog.Errorf("Failed to update Substitute %s, error %v", klog.KObj(substituteExist), err) return nil, err } diff --git a/pkg/controller/ehpa/substitute_controller.go b/pkg/controller/ehpa/substitute_controller.go index a9bf2f085..ff09bb60d 100644 --- a/pkg/controller/ehpa/substitute_controller.go +++ b/pkg/controller/ehpa/substitute_controller.go @@ -48,7 +48,7 @@ func (c *SubstituteController) Reconcile(ctx context.Context, req ctrl.Request) scale, _, err := utils.GetScale(ctx, c.RestMapper, c.ScaleClient, substitute.Namespace, substitute.Spec.SubstituteTargetRef) if err != nil { - c.Recorder.Event(substitute, v1.EventTypeNormal, "FailedGetScale", err.Error()) + c.Recorder.Event(substitute, v1.EventTypeWarning, "FailedGetScale", err.Error()) klog.Errorf("Failed to get scale, Substitute %s error %v", klog.KObj(substitute), err) return ctrl.Result{}, err } @@ -63,7 +63,7 @@ func (c *SubstituteController) Reconcile(ctx context.Context, req ctrl.Request) err := c.Update(ctx, substitute) if err != nil { - c.Recorder.Event(substitute, v1.EventTypeNormal, "FailedUpdateSubstitute", err.Error()) + c.Recorder.Event(substitute, v1.EventTypeWarning, "FailedUpdateSubstitute", err.Error()) klog.Errorf("Failed to update Substitute %s, error %v", klog.KObj(substitute), err) return ctrl.Result{}, err } @@ -75,7 +75,7 @@ func (c *SubstituteController) Reconcile(ctx context.Context, req ctrl.Request) substitute.Status = newStatus err := c.Status().Update(ctx, substitute) if err != nil { - c.Recorder.Event(substitute, v1.EventTypeNormal, "FailedUpdateStatus", err.Error()) + c.Recorder.Event(substitute, v1.EventTypeWarning, "FailedUpdateStatus", err.Error()) klog.Errorf("Failed to update status, Substitute %s error %v", klog.KObj(substitute), err) return ctrl.Result{}, err } diff --git a/pkg/controller/evpa/effective_vpa_controller.go b/pkg/controller/evpa/effective_vpa_controller.go index 189e755c7..c99d3af0a 100644 --- a/pkg/controller/evpa/effective_vpa_controller.go +++ b/pkg/controller/evpa/effective_vpa_controller.go @@ -146,7 +146,7 @@ func (c *EffectiveVPAController) UpdateStatus(ctx context.Context, evpa *autosca evpa.Status = *newStatus err := c.Status().Update(ctx, evpa) if err != nil { - c.Recorder.Event(evpa, v1.EventTypeNormal, "FailedUpdateStatus", err.Error()) + c.Recorder.Event(evpa, v1.EventTypeWarning, "FailedUpdateStatus", err.Error()) klog.Errorf("Failed to update status, evpa %s error %v", klog.KObj(evpa), err) return } diff --git a/pkg/controller/timeseriesprediction/status.go b/pkg/controller/timeseriesprediction/status.go index 814847032..f0479014b 100644 --- a/pkg/controller/timeseriesprediction/status.go +++ b/pkg/controller/timeseriesprediction/status.go @@ -176,7 +176,7 @@ func (tc *Controller) UpdateStatus(ctx context.Context, tsPrediction *prediction tsPrediction.Status = *newStatus err := tc.Client.Status().Update(ctx, tsPrediction) if err != nil { - tc.Recorder.Event(tsPrediction, v1.EventTypeNormal, "FailedUpdateStatus", err.Error()) + tc.Recorder.Event(tsPrediction, v1.EventTypeWarning, "FailedUpdateStatus", err.Error()) klog.Errorf("Failed to update status for %v", klog.KObj(tsPrediction)) return err } diff --git a/site/content/en/docs/Contributing/code-standards.md b/site/content/en/docs/Contributing/code-standards.md index c84f6bbef..124c806e2 100644 --- a/site/content/en/docs/Contributing/code-standards.md +++ b/site/content/en/docs/Contributing/code-standards.md @@ -47,7 +47,7 @@ klog.ErrorDepth(5, fmt.Errorf("failed to get ehpa %s: %v", klog.KObj(ehpa), err) - consider failure paths and success paths - event do not need the object key ```go -c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedGetSubstitute", err.Error()) +c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedGetSubstitute", err.Error()) ``` ### comment diff --git a/site/content/zh/docs/Contributing/code-standards.md b/site/content/zh/docs/Contributing/code-standards.md index b33c0c996..cef825e33 100644 --- a/site/content/zh/docs/Contributing/code-standards.md +++ b/site/content/zh/docs/Contributing/code-standards.md @@ -46,7 +46,7 @@ klog.ErrorDepth(5, fmt.Errorf("failed to get ehpa %s: %v", klog.KObj(ehpa), err) - consider failure paths and success paths - event do not need the object key ```go -c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedGetSubstitute", err.Error()) +c.Recorder.Event(ehpa, v1.EventTypeWarning, "FailedGetSubstitute", err.Error()) ``` ### comment