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

Pull message #93

Merged
merged 2 commits into from
Sep 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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