Skip to content

Commit

Permalink
Select first accelerated bind mount
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsauter committed Dec 3, 2017
1 parent ad3aa2d commit e9c43ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 13 additions & 6 deletions crane/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
}
Expand Down

0 comments on commit e9c43ce

Please sign in to comment.