operator: reliability and simplification (#968)

* operator: make tests more reliable

* operator: simplify RetryOnConflict statements
This commit is contained in:
3u13r 2023-01-13 16:49:41 +01:00 committed by GitHub
parent c36a009188
commit 67f8336b9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 23 deletions

View File

@ -216,9 +216,6 @@ func (r *AutoscalingStrategyReconciler) tryUpdateStatus(ctx context.Context, nam
return err
}
autoscalingStrategy.Status = *status.DeepCopy()
if err := r.Status().Update(ctx, &autoscalingStrategy); err != nil {
return err
}
return nil
return r.Status().Update(ctx, &autoscalingStrategy)
})
}

View File

@ -743,10 +743,7 @@ func (r *NodeVersionReconciler) tryUpdateStatus(ctx context.Context, name types.
return err
}
nodeVersion.Status = *status.DeepCopy()
if err := r.Status().Update(ctx, &nodeVersion); err != nil {
return err
}
return nil
return r.Status().Update(ctx, &nodeVersion)
})
}

View File

@ -246,7 +246,7 @@ var _ = Describe("NodeVersion controller", func() {
Eventually(func() int {
err := k8sClient.Get(ctx, nodeVersionLookupKey, nodeVersion)
if err != nil {
return 0
return 1
}
return len(nodeVersion.Status.AwaitingAnnotation)
}, timeout, interval).Should(Equal(0))
@ -300,13 +300,18 @@ var _ = Describe("NodeVersion controller", func() {
}, timeout, interval).Should(HaveKeyWithValue("custom-node-label", "custom-node-label-value"))
By("marking the new node as ready")
secondNode.Status.Conditions = []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
}
Expect(k8sClient.Status().Update(ctx, secondNode)).Should(Succeed())
Eventually(func() error {
if err := k8sClient.Get(ctx, secondNodeLookupKey, secondNode); err != nil {
return err
}
secondNode.Status.Conditions = []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
}
return k8sClient.Status().Update(ctx, secondNode)
}, timeout, interval).Should(Succeed())
By("waiting for a NodeMaintenance resource to be created")
nodeMaintenance := &nodemaintenancev1beta1.NodeMaintenance{}
@ -316,10 +321,12 @@ var _ = Describe("NodeVersion controller", func() {
By("marking the NodeMaintenance as successful")
fakes.nodeStateGetter.setNodeState(updatev1alpha1.NodeStateTerminated)
nodeMaintenance.Status.Phase = nodemaintenancev1beta1.MaintenanceSucceeded
Expect(k8sClient.Status().Update(ctx, nodeMaintenance)).Should(Succeed())
Eventually(func() error {
return k8sClient.Get(ctx, nodeMaintenanceLookupKey, nodeMaintenance)
if err := k8sClient.Get(ctx, nodeMaintenanceLookupKey, nodeMaintenance); err != nil {
return err
}
nodeMaintenance.Status.Phase = nodemaintenancev1beta1.MaintenanceSucceeded
return k8sClient.Status().Update(ctx, nodeMaintenance)
}, timeout, interval).Should(Succeed())
By("checking that the outdated node is removed")

View File

@ -240,10 +240,7 @@ func (r *PendingNodeReconciler) tryUpdateStatus(ctx context.Context, name types.
return err
}
pendingNode.Status = *status.DeepCopy()
if err := r.Status().Update(ctx, pendingNode); err != nil {
return err
}
return nil
return r.Status().Update(ctx, pendingNode)
})
}