diff --git a/go.sum b/go.sum index cc24e9f..cde0e84 100644 --- a/go.sum +++ b/go.sum @@ -1021,10 +1021,6 @@ k8s.io/sample-apiserver v0.22.2/go.mod h1:h+/DIV5EmuNq4vfPr5TSXy9mIBVXXlPAKQMPbj k8s.io/system-validators v1.5.0/go.mod h1:bPldcLgkIUK22ALflnsXk8pvkTEndYdNuaHH6gRrl0Q= k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -kusionstack.io/kube-api v0.7.4-0.20251013070018-4c09604521e4 h1:VQS8BsRs7jXTY+wwtRjOIfSxDq/Mu7ZIaFZ9CxRIe6U= -kusionstack.io/kube-api v0.7.4-0.20251013070018-4c09604521e4/go.mod h1:e1jtrQH2LK5fD2nTyfIXG6nYrYbU8VXShRxTRwVPaLk= -kusionstack.io/kube-api v0.7.4-0.20251201074336-61ceab2afe3a h1:hRzUDjPPqBrA3CAiqKur0lHMpBS9p/apsUVTzNf4lMo= -kusionstack.io/kube-api v0.7.4-0.20251201074336-61ceab2afe3a/go.mod h1:e1jtrQH2LK5fD2nTyfIXG6nYrYbU8VXShRxTRwVPaLk= kusionstack.io/kube-api v0.7.4 h1:9fM+SZtYvuVn5L/DuG7oAC+Z17uSDAeVbiAfjugI3SQ= kusionstack.io/kube-api v0.7.4/go.mod h1:e1jtrQH2LK5fD2nTyfIXG6nYrYbU8VXShRxTRwVPaLk= kusionstack.io/kube-utils v0.2.1-0.20251125083928-1134a582b341 h1:dnMtHJvIpU3338WpqGiNN2qXWZFiXaoiuzR9jwhvWpg= diff --git a/pkg/controllers/rolloutrun/executor/do_hook.go b/pkg/controllers/rolloutrun/executor/do_hook.go index 2a7a78e..50cd963 100644 --- a/pkg/controllers/rolloutrun/executor/do_hook.go +++ b/pkg/controllers/rolloutrun/executor/do_hook.go @@ -4,6 +4,7 @@ import ( "time" "github.com/samber/lo" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" rolloutv1alpha1 "kusionstack.io/kube-api/rollout/v1alpha1" @@ -56,6 +57,9 @@ func (r *webhookExecutorImpl) Do(ctx *ExecutorContext, hookType rolloutv1alpha1. // shorten long message hookResult.Message = utils.Abbreviate(hookResult.Message, 1024) + if hookResult.State == rolloutv1alpha1.WebhookCompleted { + hookResult.FinishTime = ptr.To(metav1.Now()) + } ctx.SetWebhookStatus(rolloutv1alpha1.RolloutWebhookStatus(*hookResult)) if hookResult.State == rolloutv1alpha1.WebhookOnHold && diff --git a/pkg/controllers/rolloutrun/webhook/probe/http/http.go b/pkg/controllers/rolloutrun/webhook/probe/http/http.go index d22707d..753cb94 100644 --- a/pkg/controllers/rolloutrun/webhook/probe/http/http.go +++ b/pkg/controllers/rolloutrun/webhook/probe/http/http.go @@ -124,7 +124,7 @@ func DoHTTPProbe(url string, payload *rolloutv1alpha1.RolloutWebhookReview, clie return probe.Result{ Code: rolloutv1alpha1.WebhookReviewCodeError, Reason: "HTTPResponseError", - Message: fmt.Sprintf("HTTP probe failed with statuscode: %d, body: %q", res.StatusCode, string(b)), + Message: fmt.Sprintf("HTTP probe failed with statuscode: %d, request: %q, response: %q", res.StatusCode, string(bodyBytes), string(b)), } } diff --git a/pkg/controllers/rolloutrun/webhook/worker.go b/pkg/controllers/rolloutrun/webhook/worker.go index 306e74b..b024a2a 100644 --- a/pkg/controllers/rolloutrun/webhook/worker.go +++ b/pkg/controllers/rolloutrun/webhook/worker.go @@ -20,6 +20,7 @@ import ( "sync" "time" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/utils/ptr" @@ -88,7 +89,8 @@ func newWorker(m *manager, key types.UID, webhook rolloutv1alpha1.RolloutWebhook } // init result w.lastResult = Result{ - State: rolloutv1alpha1.WebhookRunning, + State: rolloutv1alpha1.WebhookRunning, + StartTime: ptr.To(metav1.Now()), CodeReasonMessage: rolloutv1alpha1.CodeReasonMessage{ Code: rolloutv1alpha1.WebhookReviewCodeProcessing, Reason: "Processing", @@ -176,6 +178,9 @@ func (w *worker) doProbe() (keepGoing bool) { State: rolloutv1alpha1.WebhookRunning, CodeReasonMessage: probeResult, } + if w.lastResult.StartTime != nil { + result.StartTime = w.lastResult.StartTime + } switch result.Code { case rolloutv1alpha1.WebhookReviewCodeOK: diff --git a/pkg/controllers/scalerun/executor/batch.go b/pkg/controllers/scalerun/executor/batch.go index 65a3929..7a6610b 100644 --- a/pkg/controllers/scalerun/executor/batch.go +++ b/pkg/controllers/scalerun/executor/batch.go @@ -262,7 +262,7 @@ func (e *batchExecutor) checkScaledReady(info *workload.Info, scaledFrom, scaled } if scaledFrom >= scaledTo { - return info.Status.CurrentReplicas <= info.Status.Replicas + return info.Status.CurrentReplicas <= info.Status.Replicas && info.Status.TerminatingReplicas == 0 } else { return info.Status.AvailableReplicas >= info.Status.Replicas } diff --git a/pkg/workload/info.go b/pkg/workload/info.go index e246702..3ae1adf 100644 --- a/pkg/workload/info.go +++ b/pkg/workload/info.go @@ -63,6 +63,8 @@ type InfoStatus struct { UpdatedReadyReplicas int32 // UpdatedAvailableReplicas is the number of service available pods targeted by workload that have the updated template spec. UpdatedAvailableReplicas int32 + // TerminatingReplicas is the number of pods which is marked deletion timestamp + TerminatingReplicas int32 } func NewInfo(cluster string, gvk schema.GroupVersionKind, obj client.Object, status InfoStatus) *Info {