From a844cc6f67f31c754ac25133a058a356a8b7f4fe Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Tue, 7 Apr 2026 21:03:11 +1000 Subject: [PATCH] fix(pre-deploy): include hook containers in logs, ls, stop commands --- pkg/client/logs.go | 7 ++++--- pkg/client/service.go | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/client/logs.go b/pkg/client/logs.go index 8414e7bc..75c5a9e6 100644 --- a/pkg/client/logs.go +++ b/pkg/client/logs.go @@ -24,7 +24,8 @@ func (cli *Client) ServiceLogs( return svc, nil, fmt.Errorf("inspect service: %w", err) } - if len(svc.Containers) == 0 { + allContainers := append(svc.Containers, svc.HookContainers...) + if len(allContainers) == 0 { return svc, nil, fmt.Errorf("no containers found for service: %s", serviceNameOrID) } @@ -35,8 +36,8 @@ func (cli *Client) ServiceLogs( return svc, nil, fmt.Errorf("list machines: %w", err) } - ctrStreams := make([]<-chan api.ServiceLogEntry, 0, len(svc.Containers)) - for _, ctr := range svc.Containers { + ctrStreams := make([]<-chan api.ServiceLogEntry, 0, len(allContainers)) + for _, ctr := range allContainers { // Skip containers not running on the specified machines. m := machines.FindByNameOrID(ctr.MachineID) if len(opts.Machines) > 0 && m == nil { diff --git a/pkg/client/service.go b/pkg/client/service.go index e7c65920..83b2f378 100644 --- a/pkg/client/service.go +++ b/pkg/client/service.go @@ -287,8 +287,8 @@ func (cli *Client) StopService(ctx context.Context, id string, opts container.St wg := sync.WaitGroup{} errCh := make(chan error) - // Stop all containers on all machines that belong to the service. - for _, mc := range svc.Containers { + // Stop all containers on all machines that belong to the service, including hook containers. + for _, mc := range append(svc.Containers, svc.HookContainers...) { wg.Go(func() { err := cli.StopContainer(ctx, svc.ID, mc.Container.ID, opts) if err != nil { @@ -378,7 +378,7 @@ func (cli *Client) ListServices(ctx context.Context) ([]api.Service, error) { continue } - for _, ctr := range mc.Containers { + for _, ctr := range append(mc.Containers, mc.HookContainers...) { if _, ok := servicesByID[ctr.ServiceID()]; ok { continue }