Sync runner status with pod status

This commit is contained in:
Moto Ishizawa
2020-02-03 17:25:38 +09:00
parent 0061979e3e
commit 13ef78ce20

View File

@@ -106,6 +106,20 @@ func (r *RunnerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
log.Info("Created a runner pod", "repository", runner.Spec.Repository) log.Info("Created a runner pod", "repository", runner.Spec.Repository)
} else { } 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() { if !pod.ObjectMeta.DeletionTimestamp.IsZero() {
return ctrl.Result{}, err return ctrl.Result{}, err
} }