Skip to content

Commit

Permalink
Revert "Don't block waiting for individual deployments"
Browse files Browse the repository at this point in the history
This reverts commit 35d642e.
  • Loading branch information
daniel-ac-martin committed Jun 12, 2018
1 parent 35d642e commit 5f43bcb
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func run(c *cli.Context) error {
}
}

watch := []*ObjectResource{}
for _, r := range resources {
if c.Bool("debug-templates") {
logInfo.Printf("Template:\n" + string(r.Template[:]))
Expand All @@ -200,17 +199,7 @@ func run(c *cli.Context) error {
if err := deploy(c, r); err != nil {
return err
}
if isWatchableResouce(r) {
watch = append(watch, r)
}
}

for _, r := range watch {
if err := watchResource(c, r); err != nil {
return err
}
}

return nil
}

Expand Down Expand Up @@ -270,17 +259,20 @@ func deploy(c *cli.Context, r *ObjectResource) error {
return err
}
logInfo.Print(outbuf.String())
if isWatchableResouce(r) {
return watchResource(c, r)
}
return nil
}

func isWatchableResouce(r *ObjectResource) bool {
included := false
watchable := []string{"Deployment", "StatefulSet", "DaemonSet", "Job"}
for _, item := range watchable {
if item == r.Kind {
included = true
break
}
if item == r.Kind {
included = true
break
}
}
return included
}
Expand Down Expand Up @@ -330,33 +322,33 @@ func watchResource(c *cli.Context, r *ObjectResource) error {

switch r.Kind {
case "Deployment":
if (r.DeploymentStatus.UnavailableReplicas == 0 && r.DeploymentStatus.AvailableReplicas == r.DeploymentStatus.Replicas) &&
r.DeploymentStatus.Replicas == r.DeploymentStatus.UpdatedReplicas {
if (r.DeploymentStatus.UnavailableReplicas == 0 && r.DeploymentStatus.AvailableReplicas == r.DeploymentStatus.Replicas) &&
r.DeploymentStatus.Replicas == r.DeploymentStatus.UpdatedReplicas {
ready = true
}
availableResourceCount = r.DeploymentStatus.AvailableReplicas
unavailableResourceCount = r.DeploymentStatus.UnavailableReplicas

case "StatefulSet":
if (r.DeploymentStatus.ReadyReplicas == r.ObjectSpec.Replicas) &&
r.DeploymentStatus.CurrentRevision == r.DeploymentStatus.UpdateRevision {
if (r.DeploymentStatus.ReadyReplicas == r.ObjectSpec.Replicas) &&
r.DeploymentStatus.CurrentRevision == r.DeploymentStatus.UpdateRevision {
ready = true
}
availableResourceCount = r.DeploymentStatus.ReadyReplicas
unavailableResourceCount = r.ObjectSpec.Replicas - r.DeploymentStatus.ReadyReplicas
unavailableResourceCount = r.ObjectSpec.Replicas-r.DeploymentStatus.ReadyReplicas

case "DaemonSet":
if (r.DeploymentStatus.DesiredNumberScheduled == r.DeploymentStatus.NumberAvailable) &&
(r.DeploymentStatus.UpdatedNumberScheduled == r.DeploymentStatus.DesiredNumberScheduled) {
if (r.DeploymentStatus.DesiredNumberScheduled == r.DeploymentStatus.NumberAvailable) &&
(r.DeploymentStatus.UpdatedNumberScheduled == r.DeploymentStatus.DesiredNumberScheduled) {
ready = true
}
availableResourceCount = r.DeploymentStatus.NumberAvailable
unavailableResourceCount = r.DeploymentStatus.DesiredNumberScheduled - r.DeploymentStatus.UpdatedNumberScheduled
unavailableResourceCount = r.DeploymentStatus.DesiredNumberScheduled-r.DeploymentStatus.UpdatedNumberScheduled

case "Job":
if r.DeploymentStatus.Succeeded == 1 {
availableResourceCount = 1
ready = true
ready = true
}
unavailableResourceCount = 1
}
Expand Down

0 comments on commit 5f43bcb

Please sign in to comment.