From fd1f73a5e7e575f7a175e574f98a824c22d5f5e0 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Wed, 29 May 2024 09:11:59 +0200 Subject: [PATCH] prevent concurrent map write relying on project immutability Signed-off-by: Nicolas De Loof --- pkg/compose/restart.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/compose/restart.go b/pkg/compose/restart.go index e0ab730b4..ffb40e44d 100644 --- a/pkg/compose/restart.go +++ b/pkg/compose/restart.go @@ -56,13 +56,16 @@ func (s *composeService) restart(ctx context.Context, projectName string, option } // ignore depends_on relations which are not impacted by restarting service or not required - for i, service := range project.Services { - for name, r := range service.DependsOn { + project, err = project.WithServicesTransform(func(name string, s types.ServiceConfig) (types.ServiceConfig, error) { + for name, r := range s.DependsOn { if !r.Restart { - delete(service.DependsOn, name) + delete(s.DependsOn, name) } } - project.Services[i] = service + return s, nil + }) + if err != nil { + return err } if len(options.Services) != 0 {