Skip to content
This repository has been archived by the owner on Jun 14, 2019. It is now read-only.

Commit

Permalink
template: wait for pod to teardown (if container is present) during d…
Browse files Browse the repository at this point in the history
…elete

Pod teardown may take longer than 5 mins (default ci-operator timeout). 
This commit would ensure the same timeout is applied to the teardown 
container - and then applied to the pod again.

This is useful for rehearse jobs, which reuse the namespace when testing 
a new commit
  • Loading branch information
vrutkovs committed May 28, 2019
1 parent fc24891 commit 3e3d553
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/steps/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ func waitForPodDeletion(podClient coreclientset.PodInterface, name string, uid t
if pod.UID != uid {
return nil
}
for j := 0; j < timeout; j += 2 {
runningContainers := podRunningContainers(pod)
if sort.SearchStrings(runningContainers, "teardown") < len(runningContainers) {
break
} else {
log.Printf("Waiting for pod %s to complete teardown ... (%ds/%d)", name, j, timeout)
time.Sleep(2 * time.Second)
}
}
log.Printf("Waiting for pod %s to be deleted ... (%ds/%d)", name, i, timeout)
time.Sleep(2 * time.Second)
}
Expand Down Expand Up @@ -628,6 +637,7 @@ func podRunningContainers(pod *coreapi.Pod) []string {
}
names = append(names, status.Name)
}
sort.Strings(names)
return names
}

Expand Down

0 comments on commit 3e3d553

Please sign in to comment.