Skip to content

Commit cc50ada

Browse files
committed
report error (re)creating container
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 5c74f07 commit cc50ada

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

pkg/compose/convergence.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,13 @@ func (s *composeService) createContainer(ctx context.Context, project *types.Pro
595595
w.Event(progress.CreatingEvent(eventName))
596596
ctr, err = s.createMobyContainer(ctx, project, service, name, number, nil, opts, w)
597597
if err != nil {
598+
if ctx.Err() == nil {
599+
w.Event(progress.Event{
600+
ID: eventName,
601+
Status: progress.Error,
602+
StatusText: err.Error(),
603+
})
604+
}
598605
return
599606
}
600607
w.Event(progress.CreatedEvent(eventName))
@@ -603,10 +610,19 @@ func (s *composeService) createContainer(ctx context.Context, project *types.Pro
603610

604611
func (s *composeService) recreateContainer(ctx context.Context, project *types.Project, service types.ServiceConfig,
605612
replaced containerType.Summary, inherit bool, timeout *time.Duration,
606-
) (containerType.Summary, error) {
607-
var created containerType.Summary
613+
) (created containerType.Summary, err error) {
608614
w := progress.ContextWriter(ctx)
609-
w.Event(progress.NewEvent(getContainerProgressName(replaced), progress.Working, "Recreate"))
615+
eventName := getContainerProgressName(replaced)
616+
w.Event(progress.NewEvent(eventName, progress.Working, "Recreate"))
617+
defer func() {
618+
if err != nil && ctx.Err() == nil {
619+
w.Event(progress.Event{
620+
ID: eventName,
621+
Status: progress.Error,
622+
StatusText: err.Error(),
623+
})
624+
}
625+
}()
610626

611627
number, err := strconv.Atoi(replaced.Labels[api.ContainerNumberLabel])
612628
if err != nil {
@@ -646,7 +662,7 @@ func (s *composeService) recreateContainer(ctx context.Context, project *types.P
646662
return created, err
647663
}
648664

649-
w.Event(progress.NewEvent(getContainerProgressName(replaced), progress.Done, "Recreated"))
665+
w.Event(progress.NewEvent(eventName, progress.Done, "Recreated"))
650666
return created, err
651667
}
652668

pkg/compose/pull.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
208208
w.Event(progress.Event{
209209
ID: service.Name,
210210
Status: progress.Warning,
211-
Text: "Warning",
212211
StatusText: "Interrupted",
213212
})
214213
return "", nil

0 commit comments

Comments
 (0)