mirror of
https://github.com/actions-runner-controller/actions-runner-controller.git
synced 2026-09-30 17:09:50 +02:00
wip
This commit is contained in:
@@ -62,10 +62,10 @@ type AutoscalingListenerReconciler struct {
|
||||
|
||||
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=core,resources=pods/status,verbs=get
|
||||
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update
|
||||
// +kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;create;update
|
||||
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=roles,verbs=create;delete;get;list;watch;update
|
||||
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=rolebindings,verbs=create;delete;get;list;watch;update
|
||||
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;patch
|
||||
// +kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;create;patch
|
||||
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=roles,verbs=create;delete;get;list;watch;patch
|
||||
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=rolebindings,verbs=create;delete;get;list;watch;patch
|
||||
// +kubebuilder:rbac:groups=actions.github.com,resources=autoscalinglisteners,verbs=get;list;watch;create;update;patch;delete
|
||||
// +kubebuilder:rbac:groups=actions.github.com,resources=autoscalinglisteners/status,verbs=get;update;patch
|
||||
// +kubebuilder:rbac:groups=actions.github.com,resources=autoscalinglisteners/finalizers,verbs=update
|
||||
@@ -178,7 +178,7 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
|
||||
if shouldUpdate {
|
||||
log.Info("Updating listener service account")
|
||||
|
||||
if err := r.Update(ctx, updatedServiceAccount); err != nil {
|
||||
if err := r.Patch(ctx, updatedServiceAccount, client.MergeFrom(&serviceAccount)); err != nil {
|
||||
log.Error(err, "Failed to update listener service account")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
@@ -225,7 +225,7 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
|
||||
}
|
||||
if shouldUpdate {
|
||||
log.Info("Updating listener role")
|
||||
if err := r.Update(ctx, updatedRole); err != nil {
|
||||
if err := r.Patch(ctx, updatedRole, client.MergeFrom(&listenerRole)); err != nil {
|
||||
log.Error(err, "Failed to update listener role")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
@@ -264,7 +264,7 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
|
||||
}
|
||||
if shouldUpdate {
|
||||
log.Info("Updating listener role binding")
|
||||
if err := r.Update(ctx, updatedRoleBinding); err != nil {
|
||||
if err := r.Patch(ctx, updatedRoleBinding, client.MergeFrom(&listenerRoleBinding)); err != nil {
|
||||
log.Error(err, "Failed to update listener role binding")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
@@ -320,7 +320,7 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
|
||||
}
|
||||
if shouldUpdate {
|
||||
log.Info("Updating listener proxy secret")
|
||||
if err := r.Update(ctx, updatedProxySecret); err != nil {
|
||||
if err := r.Patch(ctx, updatedProxySecret, client.MergeFrom(&proxySecret)); err != nil {
|
||||
log.Error(err, "Failed to update listener proxy secret")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
@@ -408,7 +408,7 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
|
||||
|
||||
if shouldUpdate {
|
||||
log.Info("Updating listener config secret", "namespace", updatedSecret.Namespace, "name", updatedSecret.Name)
|
||||
if err := r.Update(ctx, updatedSecret); err != nil {
|
||||
if err := r.Patch(ctx, updatedSecret, client.MergeFrom(&listenerConfigSecret)); err != nil {
|
||||
return ctrl.Result{}, fmt.Errorf("failed to update listener config secret: %w", err)
|
||||
}
|
||||
return ctrl.Result{Requeue: true}, nil
|
||||
@@ -501,7 +501,7 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
|
||||
|
||||
if shouldUpdate {
|
||||
log.Info("Updating listener pod", "namespace", updatedPod.Namespace, "name", updatedPod.Name)
|
||||
if err := r.Update(ctx, updatedPod); err != nil {
|
||||
if err := r.Patch(ctx, updatedPod, client.MergeFrom(&listenerPod)); err != nil {
|
||||
log.Error(err, "Unable to update listener pod", "namespace", updatedPod.Namespace, "name", updatedPod.Name)
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ var _ = Describe("Test AutoScalingListener controller", func() {
|
||||
},
|
||||
},
|
||||
}
|
||||
err := k8sClient.Status().Update(ctx, updated)
|
||||
err := k8sClient.Status().Patch(ctx, updated, client.MergeFrom(pod))
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to update test pod")
|
||||
|
||||
// Waiting for the new pod is created
|
||||
@@ -785,7 +785,7 @@ var _ = Describe("Test AutoScalingListener customization", func() {
|
||||
},
|
||||
},
|
||||
}
|
||||
err := k8sClient.Status().Update(ctx, updated)
|
||||
err := k8sClient.Status().Patch(ctx, updated, client.MergeFrom(pod))
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to update pod status")
|
||||
|
||||
pod = new(corev1.Pod)
|
||||
@@ -831,7 +831,7 @@ var _ = Describe("Test AutoScalingListener customization", func() {
|
||||
updated := pod.DeepCopy()
|
||||
oldPodUID := string(pod.UID)
|
||||
updated.Status.Reason = "Evicted"
|
||||
err := k8sClient.Status().Update(ctx, updated)
|
||||
err := k8sClient.Status().Patch(ctx, updated, client.MergeFrom(pod))
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to update pod status")
|
||||
|
||||
pod = new(corev1.Pod)
|
||||
|
||||
@@ -361,10 +361,11 @@ func (r *AutoscalingRunnerSetReconciler) Reconcile(ctx context.Context, req ctrl
|
||||
!maps.Equal(listener.Labels, desired.Labels) ||
|
||||
!r.annotationsEqual(listener.Annotations, desired.Annotations) {
|
||||
log.Info("Updating listener")
|
||||
original := listener.DeepCopy()
|
||||
listener.Spec = desired.Spec
|
||||
listener.Annotations = r.filterAndMergeAnnotations(listener.Annotations, desired.Annotations)
|
||||
listener.Labels = r.filterAndMergeLabels(listener.Labels, desired.Labels)
|
||||
if err := r.Update(ctx, &listener); err != nil {
|
||||
if err := r.Patch(ctx, &listener, client.MergeFrom(original)); err != nil {
|
||||
log.Error(err, "Failed to update AutoscalingListener with new spec")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
@@ -1220,8 +1220,9 @@ var _ = Describe("Test AutoscalingController creation failures", Ordered, func()
|
||||
autoscalingRunnerSetTestInterval,
|
||||
).Should(BeEquivalentTo(autoscalingRunnerSetFinalizerName), "AutoScalingRunnerSet should have a finalizer")
|
||||
|
||||
ars.Annotations = make(map[string]string)
|
||||
err = k8sClient.Update(ctx, ars)
|
||||
updated := ars.DeepCopy()
|
||||
updated.Annotations = make(map[string]string)
|
||||
err = k8sClient.Patch(ctx, updated, client.MergeFrom(ars))
|
||||
Expect(err).NotTo(HaveOccurred(), "Update autoscaling runner set without annotation should be successful")
|
||||
|
||||
Eventually(
|
||||
|
||||
@@ -223,8 +223,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
).Should(Succeed(), "failed to get ephemeral runner")
|
||||
|
||||
// update job id to simulate job assigned
|
||||
er.Status.JobID = "1"
|
||||
err := k8sClient.Status().Update(ctx, er)
|
||||
updatedER := er.DeepCopy()
|
||||
updatedER.Status.JobID = "1"
|
||||
err := k8sClient.Status().Patch(ctx, updatedER, client.MergeFrom(er))
|
||||
Expect(err).To(BeNil(), "failed to update ephemeral runner status")
|
||||
|
||||
er = new(v1alpha1.EphemeralRunner)
|
||||
@@ -249,7 +250,8 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
}).Should(BeEquivalentTo(true))
|
||||
|
||||
// delete pod to simulate failure
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{
|
||||
Terminated: &corev1.ContainerStateTerminated{
|
||||
@@ -257,7 +259,7 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
})
|
||||
err = k8sClient.Status().Update(ctx, pod)
|
||||
err = k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
er = new(v1alpha1.EphemeralRunner)
|
||||
@@ -277,8 +279,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
return k8sClient.Get(ctx, client.ObjectKey{Name: ephemeralRunner.Name, Namespace: ephemeralRunner.Namespace}, er)
|
||||
}, ephemeralRunnerTimeout, ephemeralRunnerInterval).Should(Succeed(), "failed to get ephemeral runner")
|
||||
|
||||
er.Status.JobID = "1"
|
||||
err := k8sClient.Status().Update(ctx, er)
|
||||
updatedER := er.DeepCopy()
|
||||
updatedER.Status.JobID = "1"
|
||||
err := k8sClient.Status().Patch(ctx, updatedER, client.MergeFrom(er))
|
||||
Expect(err).To(BeNil(), "failed to update ephemeral runner status")
|
||||
|
||||
Eventually(func() (string, error) {
|
||||
@@ -297,9 +300,10 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
return true, nil
|
||||
}, ephemeralRunnerTimeout, ephemeralRunnerInterval).Should(BeEquivalentTo(true))
|
||||
|
||||
pod.Status.Phase = corev1.PodFailed
|
||||
pod.Status.ContainerStatuses = nil
|
||||
err = k8sClient.Status().Update(ctx, pod)
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodFailed
|
||||
updatedPod.Status.ContainerStatuses = nil
|
||||
err = k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
Eventually(func() bool {
|
||||
@@ -320,9 +324,10 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
|
||||
oldPodUID := pod.UID
|
||||
|
||||
pod.Status.Phase = corev1.PodFailed
|
||||
pod.Status.ContainerStatuses = nil
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodFailed
|
||||
updatedPod.Status.ContainerStatuses = nil
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
Eventually(
|
||||
@@ -369,8 +374,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
|
||||
// Simulate init container failure without PodFailed phase.
|
||||
// This can happen when the kubelet has not yet transitioned the pod phase.
|
||||
pod.Status.Phase = corev1.PodPending
|
||||
pod.Status.InitContainerStatuses = []corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodPending
|
||||
updatedPod.Status.InitContainerStatuses = []corev1.ContainerStatus{
|
||||
{
|
||||
Name: "setup",
|
||||
State: corev1.ContainerState{
|
||||
@@ -382,7 +388,7 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
}
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
Eventually(
|
||||
@@ -422,8 +428,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
return k8sClient.Get(ctx, client.ObjectKey{Name: ephemeralRunner.Name, Namespace: ephemeralRunner.Namespace}, er)
|
||||
}, ephemeralRunnerTimeout, ephemeralRunnerInterval).Should(Succeed(), "failed to get ephemeral runner")
|
||||
|
||||
er.Status.JobID = "1"
|
||||
err := k8sClient.Status().Update(ctx, er)
|
||||
updatedER := er.DeepCopy()
|
||||
updatedER.Status.JobID = "1"
|
||||
err := k8sClient.Status().Patch(ctx, updatedER, client.MergeFrom(er))
|
||||
Expect(err).To(BeNil(), "failed to update ephemeral runner status")
|
||||
|
||||
Eventually(func() (string, error) {
|
||||
@@ -443,8 +450,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
}, ephemeralRunnerTimeout, ephemeralRunnerInterval).Should(BeEquivalentTo(true))
|
||||
|
||||
// Simulate init container failure with job assigned
|
||||
pod.Status.Phase = corev1.PodPending
|
||||
pod.Status.InitContainerStatuses = []corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodPending
|
||||
updatedPod.Status.InitContainerStatuses = []corev1.ContainerStatus{
|
||||
{
|
||||
Name: "setup",
|
||||
State: corev1.ContainerState{
|
||||
@@ -455,7 +463,7 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
}
|
||||
err = k8sClient.Status().Update(ctx, pod)
|
||||
err = k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
Eventually(func() bool {
|
||||
@@ -471,8 +479,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
return k8sClient.Get(ctx, client.ObjectKey{Name: ephemeralRunner.Name, Namespace: ephemeralRunner.Namespace}, er)
|
||||
}, ephemeralRunnerTimeout, ephemeralRunnerInterval).Should(Succeed(), "failed to get ephemeral runner")
|
||||
|
||||
er.Status.JobID = "1"
|
||||
err := k8sClient.Status().Update(ctx, er)
|
||||
updatedER := er.DeepCopy()
|
||||
updatedER.Status.JobID = "1"
|
||||
err := k8sClient.Status().Patch(ctx, updatedER, client.MergeFrom(er))
|
||||
Expect(err).To(BeNil(), "failed to update ephemeral runner status")
|
||||
|
||||
pod := new(corev1.Pod)
|
||||
@@ -487,8 +496,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
ephemeralRunnerInterval,
|
||||
).Should(Succeed(), "failed to get pod")
|
||||
|
||||
pod.Status.Phase = corev1.PodFailed
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodFailed
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{
|
||||
Terminated: &corev1.ContainerStateTerminated{
|
||||
@@ -496,7 +506,7 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
})
|
||||
err = k8sClient.Status().Update(ctx, pod)
|
||||
err = k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
Eventually(
|
||||
@@ -523,8 +533,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
ephemeralRunnerInterval,
|
||||
).Should(Succeed(), "failed to get pod")
|
||||
|
||||
pod.Status.Phase = corev1.PodFailed
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodFailed
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{
|
||||
Terminated: &corev1.ContainerStateTerminated{
|
||||
@@ -532,7 +543,7 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
})
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
Eventually(
|
||||
@@ -568,9 +579,10 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
ephemeralRunnerInterval,
|
||||
).Should(Succeed(), "failed to get pod")
|
||||
|
||||
pod.Status.Phase = corev1.PodFailed
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodFailed
|
||||
oldPodUID := pod.UID
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{
|
||||
Terminated: &corev1.ContainerStateTerminated{
|
||||
@@ -579,7 +591,7 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
})
|
||||
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
Eventually(
|
||||
@@ -939,8 +951,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
ephemeralRunnerInterval,
|
||||
).Should(BeEquivalentTo(true))
|
||||
|
||||
pod.Status.Phase = corev1.PodRunning
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodRunning
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "failed to patch pod status")
|
||||
|
||||
Consistently(
|
||||
@@ -975,7 +988,8 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
ephemeralRunnerInterval,
|
||||
).Should(Succeed(), "failed to get ephemeral runner pod")
|
||||
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{
|
||||
Terminated: &corev1.ContainerStateTerminated{
|
||||
@@ -983,10 +997,10 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
})
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "Failed to update pod status")
|
||||
|
||||
return pod
|
||||
return updatedPod
|
||||
}
|
||||
|
||||
for i := range 5 {
|
||||
@@ -1065,13 +1079,14 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
ephemeralRunnerInterval,
|
||||
).Should(BeEquivalentTo(true))
|
||||
|
||||
pod.Status.Phase = corev1.PodFailed
|
||||
pod.Status.Reason = "Evicted"
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodFailed
|
||||
updatedPod.Status.Reason = "Evicted"
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{},
|
||||
})
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "failed to patch pod status")
|
||||
|
||||
updated := new(v1alpha1.EphemeralRunner)
|
||||
@@ -1111,13 +1126,14 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
ephemeralRunnerInterval,
|
||||
).Should(BeEquivalentTo(true))
|
||||
|
||||
pod.Status.Phase = corev1.PodFailed
|
||||
pod.Status.Reason = "OutOfpods"
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.Phase = corev1.PodFailed
|
||||
updatedPod.Status.Reason = "OutOfpods"
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{},
|
||||
})
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "failed to patch pod status")
|
||||
|
||||
updated := new(v1alpha1.EphemeralRunner)
|
||||
@@ -1157,7 +1173,8 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
).Should(BeEquivalentTo(true))
|
||||
|
||||
// first set phase to running
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{
|
||||
Running: &corev1.ContainerStateRunning{
|
||||
@@ -1165,8 +1182,8 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
})
|
||||
pod.Status.Phase = corev1.PodRunning
|
||||
err := k8sClient.Status().Update(ctx, pod)
|
||||
updatedPod.Status.Phase = corev1.PodRunning
|
||||
err := k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
Eventually(
|
||||
@@ -1182,8 +1199,9 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
).Should(BeEquivalentTo(v1alpha1.EphemeralRunnerPhaseRunning))
|
||||
|
||||
// set phase to succeeded
|
||||
pod.Status.Phase = corev1.PodSucceeded
|
||||
err = k8sClient.Status().Update(ctx, pod)
|
||||
nextPod := updatedPod.DeepCopy()
|
||||
nextPod.Status.Phase = corev1.PodSucceeded
|
||||
err = k8sClient.Status().Patch(ctx, nextPod, client.MergeFrom(updatedPod))
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
Consistently(
|
||||
@@ -1258,7 +1276,8 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
return true, nil
|
||||
}, ephemeralRunnerTimeout, ephemeralRunnerInterval).Should(BeEquivalentTo(true))
|
||||
|
||||
pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
updatedPod := pod.DeepCopy()
|
||||
updatedPod.Status.ContainerStatuses = append(updatedPod.Status.ContainerStatuses, corev1.ContainerStatus{
|
||||
Name: v1alpha1.EphemeralRunnerContainerName,
|
||||
State: corev1.ContainerState{
|
||||
Terminated: &corev1.ContainerStateTerminated{
|
||||
@@ -1266,7 +1285,7 @@ var _ = Describe("EphemeralRunner", func() {
|
||||
},
|
||||
},
|
||||
})
|
||||
err = k8sClient.Status().Update(ctx, pod)
|
||||
err = k8sClient.Status().Patch(ctx, updatedPod, client.MergeFrom(pod))
|
||||
Expect(err).To(BeNil(), "failed to update pod status")
|
||||
|
||||
updated := new(v1alpha1.EphemeralRunner)
|
||||
|
||||
@@ -260,12 +260,13 @@ func (r *EphemeralRunnerSetReconciler) updateStatus(ctx context.Context, ephemer
|
||||
|
||||
// Update the status if needed.
|
||||
if ephemeralRunnerSet.Status != desiredStatus {
|
||||
ephemeralRunnerSet.Status = desiredStatus
|
||||
if err := r.Status().Update(ctx, ephemeralRunnerSet); err != nil {
|
||||
updated := ephemeralRunnerSet.DeepCopy()
|
||||
updated.Status = desiredStatus
|
||||
if err := r.Status().Patch(ctx, updated, client.MergeFrom(ephemeralRunnerSet)); err != nil {
|
||||
log.Error(err, "Failed to update EphemeralRunnerSet status")
|
||||
return err
|
||||
}
|
||||
log.Info("Updated EphemeralRunnerSet status", "status", ephemeralRunnerSet.Status)
|
||||
log.Info("Updated EphemeralRunnerSet status", "status", updated.Status)
|
||||
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -240,7 +240,7 @@ var _ = Describe("Test EphemeralRunnerSet controller", func() {
|
||||
// Scaling up the EphemeralRunnerSet
|
||||
updated := created.DeepCopy()
|
||||
updated.Spec.Replicas = 5
|
||||
err := k8sClient.Update(ctx, updated)
|
||||
err := k8sClient.Patch(ctx, updated, client.MergeFrom(created))
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to update EphemeralRunnerSet")
|
||||
|
||||
// Check if the number of ephemeral runners are created
|
||||
@@ -302,7 +302,7 @@ var _ = Describe("Test EphemeralRunnerSet controller", func() {
|
||||
// Scale up the EphemeralRunnerSet
|
||||
updated := created.DeepCopy()
|
||||
updated.Spec.Replicas = 5
|
||||
err = k8sClient.Update(ctx, updated)
|
||||
err = k8sClient.Patch(ctx, updated, client.MergeFrom(created))
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to update EphemeralRunnerSet")
|
||||
|
||||
// Wait for the EphemeralRunnerSet to be scaled up
|
||||
@@ -1190,7 +1190,7 @@ var _ = Describe("Test EphemeralRunnerSet controller", func() {
|
||||
// Scale up the EphemeralRunnerSet
|
||||
updated := created.DeepCopy()
|
||||
updated.Spec.Replicas = 3
|
||||
err := k8sClient.Update(ctx, updated)
|
||||
err := k8sClient.Patch(ctx, updated, client.MergeFrom(created))
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to update EphemeralRunnerSet replica count")
|
||||
|
||||
runnerList := new(v1alpha1.EphemeralRunnerList)
|
||||
|
||||
Reference in New Issue
Block a user