Skip to content

Commit 0d10893

Browse files
authored
Merge pull request #4671 from haytok/improve-the-visibility-of-orphaned-containers
chore: improve the visibility of orphaned containers in logs
2 parents 4ca50d9 + 38507f9 commit 0d10893

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

pkg/composer/down.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (c *Composer) Down(ctx context.Context, downOptions DownOptions) error {
6565
return fmt.Errorf("error removeing orphaned containers: %w", err)
6666
}
6767
} else {
68-
log.G(ctx).Warnf("found %d orphaned containers: %v, you can run this command with the --remove-orphans flag to clean it up", len(orphans), orphans)
68+
log.G(ctx).Warnf("found %d orphaned containers: %v, you can run this command with the --remove-orphans flag to clean it up", len(orphans), containerShortIDs(orphans))
6969
}
7070
}
7171

pkg/composer/orphans.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ func (c *Composer) getOrphanContainers(ctx context.Context, parsedServices []*se
5555

5656
return orphanContainers, nil
5757
}
58+
59+
func containerShortIDs(containers []containerd.Container) []string {
60+
names := make([]string, 0, len(containers))
61+
for _, c := range containers {
62+
names = append(names, c.ID()[:12])
63+
}
64+
return names
65+
}

pkg/composer/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (c *Composer) Run(ctx context.Context, ro RunOptions) error {
201201
return fmt.Errorf("error removing orphaned containers: %w", err)
202202
}
203203
} else {
204-
log.G(ctx).Warnf("found %d orphaned containers: %v, you can run this command with the --remove-orphans flag to clean it up", len(orphans), orphans)
204+
log.G(ctx).Warnf("found %d orphaned containers: %v, you can run this command with the --remove-orphans flag to clean it up", len(orphans), containerShortIDs(orphans))
205205
}
206206
}
207207

pkg/composer/up.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (c *Composer) Up(ctx context.Context, uo UpOptions, services []string) erro
116116
return fmt.Errorf("error removing orphaned containers: %w", err)
117117
}
118118
} else {
119-
log.G(ctx).Warnf("found %d orphaned containers: %v, you can run this command with the --remove-orphans flag to clean it up", len(orphans), orphans)
119+
log.G(ctx).Warnf("found %d orphaned containers: %v, you can run this command with the --remove-orphans flag to clean it up", len(orphans), containerShortIDs(orphans))
120120
}
121121
}
122122

0 commit comments

Comments
 (0)