From 13ef78ce205f415de616ed4adf734e22ee076a40 Mon Sep 17 00:00:00 2001 From: Moto Ishizawa Date: Mon, 3 Feb 2020 17:25:38 +0900 Subject: [PATCH] Sync runner status with pod status --- controllers/runner_controller.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/controllers/runner_controller.go b/controllers/runner_controller.go index fba3259d..40ec8af8 100644 --- a/controllers/runner_controller.go +++ b/controllers/runner_controller.go @@ -106,6 +106,20 @@ func (r *RunnerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { log.Info("Created a runner pod", "repository", runner.Spec.Repository) } else { + if runner.Status.Phase != string(pod.Status.Phase) { + updated := runner.DeepCopy() + updated.Status.Phase = string(pod.Status.Phase) + updated.Status.Reason = pod.Status.Reason + updated.Status.Message = pod.Status.Message + + if err := r.Status().Update(ctx, updated); err != nil { + log.Error(err, "Unable to update Runner status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, nil + } + if !pod.ObjectMeta.DeletionTimestamp.IsZero() { return ctrl.Result{}, err }