helm upgrade with --wait support jobs in manifest to be completed

Signed-off-by: zh168654 <zhangye15@baidu.com>
pull/8363/head
zh168654 4 years ago committed by zh168654
parent 9aa0fbee6c
commit 5825112a8b

@ -67,6 +67,11 @@ func (w *waiter) waitForResources(created ResourceList) error {
if err != nil || !w.isPodReady(pod) {
return false, err
}
case *batchv1.Job:
job, err := w.c.BatchV1().Jobs(v.Namespace).Get(context.Background(), v.Name, metav1.GetOptions{})
if err != nil || !w.jobReady(job) {
return false, err
}
case *appsv1.Deployment, *appsv1beta1.Deployment, *appsv1beta2.Deployment, *extensionsv1beta1.Deployment:
currentDeployment, err := w.c.AppsV1().Deployments(v.Namespace).Get(context.Background(), v.Name, metav1.GetOptions{})
if err != nil {
@ -182,6 +187,18 @@ func (w *waiter) isPodReady(pod *corev1.Pod) bool {
return false
}
func (w *waiter) jobReady(job *batchv1.Job) bool {
if job.Status.Failed >= *job.Spec.BackoffLimit {
w.log("Job is failed: %s/%s", job.GetNamespace(), job.GetName())
return false
}
if job.Status.Succeeded < *job.Spec.Completions {
w.log("Job is not completed: %s/%s", job.GetNamespace(), job.GetName())
return false
}
return true
}
func (w *waiter) serviceReady(s *corev1.Service) bool {
// ExternalName Services are external to cluster so helm shouldn't be checking to see if they're 'ready' (i.e. have an IP Set)
if s.Spec.Type == corev1.ServiceTypeExternalName {

Loading…
Cancel
Save