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