From cbeac1c065417a7179717e94330c37456b5ccdab Mon Sep 17 00:00:00 2001 From: qmhu <brillantroad@gmail.com> Date: Fri, 11 Feb 2022 15:21:19 +0800 Subject: [PATCH] revert to status update to support 1.14 --- pkg/controller/ehpa/effective_hpa_controller.go | 4 +--- pkg/controller/ehpa/hpa.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/controller/ehpa/effective_hpa_controller.go b/pkg/controller/ehpa/effective_hpa_controller.go index ec973a8..c045f27 100644 --- a/pkg/controller/ehpa/effective_hpa_controller.go +++ b/pkg/controller/ehpa/effective_hpa_controller.go @@ -130,10 +130,8 @@ func (c *EffectiveHPAController) UpdateStatus(ctx context.Context, ehpa *autosca if !equality.Semantic.DeepEqual(&ehpa.Status, newStatus) { klog.V(4).Infof("EffectiveHorizontalPodAutoscaler status should be updated, currentStatus %v newStatus %v", &ehpa.Status, newStatus) - // use patch to avoid conflict errors - patch := client.MergeFrom(ehpa) ehpa.Status = *newStatus - err := c.Patch(ctx, ehpa, patch) + err := c.Status().Update(ctx, ehpa) if err != nil { c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedUpdateStatus", err.Error()) klog.Errorf("Failed to update status, ehpa %s error %v", klog.KObj(ehpa), err) diff --git a/pkg/controller/ehpa/hpa.go b/pkg/controller/ehpa/hpa.go index bfc772a..8ae29fa 100644 --- a/pkg/controller/ehpa/hpa.go +++ b/pkg/controller/ehpa/hpa.go @@ -68,7 +68,7 @@ func (c *EffectiveHPAController) CreateHPA(ctx context.Context, ehpa *autoscalin err = c.Client.Create(ctx, hpa) if err != nil { c.Recorder.Event(ehpa, v1.EventTypeNormal, "FailedCreateHPA", err.Error()) - klog.Errorf("Failed to create HorizontalPodAutoscaler, error %v", hpa, err) + klog.Errorf("Failed to create HorizontalPodAutoscaler %s, error %v", klog.KObj(hpa), err) return nil, err } -- GitLab