From 871273533a1fb5cf67bc4be3b8a99f0fcd1c257a Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Tue, 21 Jan 2025 23:08:12 +0800 Subject: [PATCH] fix(region): panic occured when removing post overlay --- pkg/compute/models/containers.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/compute/models/containers.go b/pkg/compute/models/containers.go index 207dc8a9e98..fc1f8bcdda1 100644 --- a/pkg/compute/models/containers.go +++ b/pkg/compute/models/containers.go @@ -1175,11 +1175,14 @@ func (c *SContainer) PerformRemoveVolumeMountPostOverlay(ctx context.Context, us func (c *SContainer) removePostOverlay(vmd *apis.ContainerVolumeMountDisk, ov *apis.ContainerVolumeMountDiskPostOverlay) *apis.ContainerVolumeMountDisk { curOvs := vmd.PostOverlay - for i, cov := range curOvs { + resultOvs := []*apis.ContainerVolumeMountDiskPostOverlay{} + for i := range curOvs { + cov := curOvs[i] if cov.IsEqual(*ov) { - curOvs = append(curOvs[:i], curOvs[i+1:]...) + continue } + resultOvs = append(resultOvs, cov) } - vmd.PostOverlay = curOvs + vmd.PostOverlay = resultOvs return vmd }