diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f4440e..3929ec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## Unreleased -* [Bugfix] Create default network automatically +* [Bugfix] Create default network automatically. + +* [Bugfix] If `am logs` is passed a service which has multiple bind-mounts configured, Crane is now selecting the first accelerated one, not simply the first one (which might not be accelerated). ## 3.3.2 (2017-11-21) diff --git a/crane/cli.go b/crane/cli.go index 44f3df3..a30d3ec 100644 --- a/crane/cli.go +++ b/crane/cli.go @@ -487,12 +487,20 @@ func runCli() { case amLogsCommand.FullCommand(): cfg = NewConfig(*configFlag, *prefixFlag, *tagFlag) var logsTarget string + configuredAcceleratedMounts := cfg.AcceleratedMountNames() + container := cfg.Container(*amLogsTargetArg) if container != nil { - bindMounts := container.BindMounts(cfg.VolumeNames()) - am := &acceleratedMount{RawVolume: bindMounts[0], configPath: cfg.Path()} + allBindMounts := container.BindMounts(cfg.VolumeNames()) + acceleratedBindMounts := []string{} + for _, name := range allBindMounts { + if includes(configuredAcceleratedMounts, name) { + acceleratedBindMounts = append(acceleratedBindMounts, name) + } + } + am := &acceleratedMount{RawVolume: acceleratedBindMounts[0], configPath: cfg.Path()} logsTarget = am.Volume() - if len(bindMounts) > 1 { + if len(acceleratedBindMounts) > 1 { printNoticef("WARNING: %s has more than one bind-mount configured. The first one will be selected. To select a different bind-mount, pass it directly.\n", *amLogsTargetArg) } } else { @@ -507,9 +515,8 @@ func runCli() { printInfof("%s logs of accelerated mount %s ...\n", kind, *amLogsTargetArg) am.Logs(*amFollowFlag) } else { - amNames := cfg.AcceleratedMountNames() - if len(amNames) > 0 { - printErrorf("ERROR: No such accelerated mount. Configured mounts: %s\n", strings.Join(amNames, ", ")) + if len(configuredAcceleratedMounts) > 0 { + printErrorf("ERROR: No such accelerated mount. Configured mounts: %s\n", strings.Join(configuredAcceleratedMounts, ", ")) } else { printErrorf("ERROR: No accelerated mounts configured.\n") }