Fix runner pod to be cleaned up earlier regardless of the sync period (#1299)
Ref #1291
This commit is contained in:
parent
b614dcf54b
commit
631a70a35f
|
|
@ -181,6 +181,9 @@ func (rs *RunnerSpec) ValidateRepository() error {
|
||||||
|
|
||||||
// RunnerStatus defines the observed state of Runner
|
// RunnerStatus defines the observed state of Runner
|
||||||
type RunnerStatus struct {
|
type RunnerStatus struct {
|
||||||
|
// Turns true only if the runner pod is ready.
|
||||||
|
// +optional
|
||||||
|
Ready bool `json:"ready"`
|
||||||
// +optional
|
// +optional
|
||||||
Registration RunnerStatusRegistration `json:"registration"`
|
Registration RunnerStatusRegistration `json:"registration"`
|
||||||
// +optional
|
// +optional
|
||||||
|
|
|
||||||
|
|
@ -5126,6 +5126,9 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
phase:
|
phase:
|
||||||
type: string
|
type: string
|
||||||
|
ready:
|
||||||
|
description: Turns true only if the runner pod is ready.
|
||||||
|
type: boolean
|
||||||
reason:
|
reason:
|
||||||
type: string
|
type: string
|
||||||
registration:
|
registration:
|
||||||
|
|
|
||||||
|
|
@ -5126,6 +5126,9 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
phase:
|
phase:
|
||||||
type: string
|
type: string
|
||||||
|
ready:
|
||||||
|
description: Turns true only if the runner pod is ready.
|
||||||
|
type: boolean
|
||||||
reason:
|
reason:
|
||||||
type: string
|
type: string
|
||||||
registration:
|
registration:
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,9 @@ func (r *RunnerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
|
||||||
phase = "Created"
|
phase = "Created"
|
||||||
}
|
}
|
||||||
|
|
||||||
if runner.Status.Phase != phase {
|
ready := runnerPodReady(&pod)
|
||||||
|
|
||||||
|
if runner.Status.Phase != phase || runner.Status.Ready != ready {
|
||||||
if pod.Status.Phase == corev1.PodRunning {
|
if pod.Status.Phase == corev1.PodRunning {
|
||||||
// Seeing this message, you can expect the runner to become `Running` soon.
|
// Seeing this message, you can expect the runner to become `Running` soon.
|
||||||
log.V(1).Info(
|
log.V(1).Info(
|
||||||
|
|
@ -143,6 +145,7 @@ func (r *RunnerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
|
||||||
|
|
||||||
updated := runner.DeepCopy()
|
updated := runner.DeepCopy()
|
||||||
updated.Status.Phase = phase
|
updated.Status.Phase = phase
|
||||||
|
updated.Status.Ready = ready
|
||||||
updated.Status.Reason = pod.Status.Reason
|
updated.Status.Reason = pod.Status.Reason
|
||||||
updated.Status.Message = pod.Status.Message
|
updated.Status.Message = pod.Status.Message
|
||||||
|
|
||||||
|
|
@ -155,6 +158,18 @@ func (r *RunnerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
|
||||||
return ctrl.Result{}, nil
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runnerPodReady(pod *corev1.Pod) bool {
|
||||||
|
for _, c := range pod.Status.Conditions {
|
||||||
|
if c.Type != corev1.PodReady {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Status == corev1.ConditionTrue
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func runnerContainerExitCode(pod *corev1.Pod) *int32 {
|
func runnerContainerExitCode(pod *corev1.Pod) *int32 {
|
||||||
for _, status := range pod.Status.ContainerStatuses {
|
for _, status := range pod.Status.ContainerStatuses {
|
||||||
if status.Name != containerName {
|
if status.Name != containerName {
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,22 @@ var (
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Dockerfile: "../../runner/Dockerfile",
|
Dockerfile: "../../runner/Dockerfile",
|
||||||
Args: []testing.BuildArg{},
|
Args: []testing.BuildArg{
|
||||||
|
{
|
||||||
|
Name: "RUNNER_VERSION",
|
||||||
|
Value: "2.289.2",
|
||||||
|
},
|
||||||
|
},
|
||||||
Image: runnerImage,
|
Image: runnerImage,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Dockerfile: "../../runner/Dockerfile.dindrunner",
|
Dockerfile: "../../runner/Dockerfile.dindrunner",
|
||||||
Args: []testing.BuildArg{},
|
Args: []testing.BuildArg{
|
||||||
|
{
|
||||||
|
Name: "RUNNER_VERSION",
|
||||||
|
Value: "2.289.2",
|
||||||
|
},
|
||||||
|
},
|
||||||
Image: runnerDindImage,
|
Image: runnerDindImage,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +68,7 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
commonScriptEnv = []string{
|
commonScriptEnv = []string{
|
||||||
"SYNC_PERIOD=" + "10s",
|
"SYNC_PERIOD=" + "30m",
|
||||||
"NAME=" + controllerImageRepo,
|
"NAME=" + controllerImageRepo,
|
||||||
"VERSION=" + controllerImageTag,
|
"VERSION=" + controllerImageTag,
|
||||||
"RUNNER_TAG=" + runnerImageTag,
|
"RUNNER_TAG=" + runnerImageTag,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue