Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #93 from ibuildthecloud/pull-message
Browse files Browse the repository at this point in the history
Pull message
  • Loading branch information
ibuildthecloud committed Sep 21, 2015
2 parents 2ed6009 + d745fe5 commit f350419
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 36 additions & 1 deletion rancher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,10 +835,11 @@ func (r *RancherService) Pull() error {
return err
}

printed := map[string]string{}
lastMessage := ""
r.WaitFor(&task.Resource, task, func() string {
if task.TransitioningMessage != "" && task.TransitioningMessage != "In Progress" && task.TransitioningMessage != lastMessage {
logrus.Info(task.TransitioningMessage)
printStatus(task.Image, printed, task.Status)
lastMessage = task.TransitioningMessage
}

Expand All @@ -849,9 +850,43 @@ func (r *RancherService) Pull() error {
return errors.New(task.TransitioningMessage)
}

if !printStatus(task.Image, printed, task.Status) {
return errors.New("Pull failed on one of the hosts")
}

return nil
}

func printStatus(image string, printed map[string]string, current map[string]interface{}) bool {
good := true
for host, objStatus := range current {
status, ok := objStatus.(string)
if !ok {
continue
}

v := printed[host]
if status != "Done" {
fmt.Printf("Bad...., " + status + "\n")
good = false
}

if v == "" {
logrus.Infof("Pulling %s on %s", image, host)
v = "start"
} else if printed[host] == "start" && status == "Done" {
logrus.Infof("Finished pulling %s on %s", image, host)
v = "done"
} else if printed[host] == "start" && status != "Pulling" && status != v {
logrus.Infof("Pulling %s on %s: %s", image, host, status)
v = status
}
printed[host] = v
}

return good
}

func TrimSplit(str, sep string, count int) []string {
result := []string{}
for _, i := range strings.SplitN(strings.TrimSpace(str), sep, count) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-cattle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

URL=https://github.com/rancher/cattle/releases/download/v0.92.0/cattle.jar
URL=https://github.com/rancher/cattle/releases/download/v0.93.0/cattle.jar

cd $(dirname $0)/..

Expand Down

0 comments on commit f350419

Please sign in to comment.