Skip to content

Commit 516da2d

Browse files
committed
fix: skip container removal during in-place update resizing
Prevent unnecessary container removal during in-place update resizing by adding a condition to check if the pod is in resizing state. This avoids disruptions during the update process.
1 parent 8ae7edb commit 516da2d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,13 @@ func (p *DynamicPolicy) Allocate(ctx context.Context,
850850
_ = p.removeContainer(req.PodUid, req.ContainerName, false)
851851
}
852852
} else if respErr != nil {
853-
_ = p.removeContainer(req.PodUid, req.ContainerName, false)
853+
inplaceUpdateResizing := util.PodInplaceUpdateResizing(req)
854+
if !inplaceUpdateResizing {
855+
_ = p.removeContainer(req.PodUid, req.ContainerName, false)
856+
}
854857
_ = p.emitter.StoreInt64(util.MetricNameAllocateFailed, 1, metrics.MetricTypeNameRaw,
855858
metrics.MetricTag{Key: "error_message", Val: metric.MetricTagValueFormat(respErr)},
856-
metrics.MetricTag{Key: util.MetricTagNameInplaceUpdateResizing, Val: strconv.FormatBool(util.PodInplaceUpdateResizing(req))})
859+
metrics.MetricTag{Key: util.MetricTagNameInplaceUpdateResizing, Val: strconv.FormatBool(inplaceUpdateResizing)})
857860
}
858861
if err := p.state.StoreState(); err != nil {
859862
general.ErrorS(err, "store state failed", "podName", req.PodName, "containerName", req.ContainerName)

pkg/agent/qrm-plugins/memory/dynamicpolicy/policy.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,13 @@ func (p *DynamicPolicy) Allocate(ctx context.Context,
959959
_ = p.removeContainer(req.PodUid, req.ContainerName, false)
960960
}
961961
} else if respErr != nil {
962-
_ = p.removeContainer(req.PodUid, req.ContainerName, false)
962+
inplaceUpdateResizing := util.PodInplaceUpdateResizing(req)
963+
if !inplaceUpdateResizing {
964+
_ = p.removeContainer(req.PodUid, req.ContainerName, false)
965+
}
963966
_ = p.emitter.StoreInt64(util.MetricNameAllocateFailed, 1, metrics.MetricTypeNameRaw,
964967
metrics.MetricTag{Key: "error_message", Val: metric.MetricTagValueFormat(respErr)},
965-
metrics.MetricTag{Key: util.MetricTagNameInplaceUpdateResizing, Val: strconv.FormatBool(util.PodInplaceUpdateResizing(req))})
968+
metrics.MetricTag{Key: util.MetricTagNameInplaceUpdateResizing, Val: strconv.FormatBool(inplaceUpdateResizing)})
966969
}
967970
if err := p.state.StoreState(); err != nil {
968971
general.ErrorS(err, "store state failed", "podName", req.PodName, "containerName", req.ContainerName)

0 commit comments

Comments
 (0)