@@ -266,6 +266,10 @@ func engineRunnerPod(runnerPod *podEngineRunner) error {
266
266
if err := runnerPod .r .Client .Get (context .TODO (), types.NamespacedName {Name : runnerPod .engineRunner .Name , Namespace : runnerPod .engineRunner .Namespace }, runnerPod .pod ); err != nil && k8serrors .IsNotFound (err ) {
267
267
runnerPod .reqLogger .Info ("Creating a new engineRunner Pod" , "Pod.Namespace" , runnerPod .engineRunner .Namespace , "Pod.Name" , runnerPod .engineRunner .Name )
268
268
if err = runnerPod .r .Client .Create (context .TODO (), runnerPod .engineRunner ); err != nil {
269
+ if k8serrors .IsAlreadyExists (err ) {
270
+ runnerPod .reqLogger .Info ("Skip reconcile: engineRunner Pod already exists" , "Pod.Namespace" , runnerPod .pod .Namespace , "Pod.Name" , runnerPod .pod .Name )
271
+ return nil
272
+ }
269
273
return err
270
274
}
271
275
@@ -595,7 +599,7 @@ func (r *ChaosEngineReconciler) initEngine(engine *chaosTypes.EngineInfo) error
595
599
596
600
// reconcileForCreationAndRunning reconciles for Chaos execution of Chaos Engine
597
601
func (r * ChaosEngineReconciler ) reconcileForCreationAndRunning (engine * chaosTypes.EngineInfo , reqLogger logr.Logger ) (reconcile.Result , error ) {
598
- if err := r .validateAnnontatedApplication (engine ); err != nil {
602
+ if err := r .validateAnnotatedApplication (engine ); err != nil {
599
603
if stopEngineWithAnnotationErrorMessage := r .updateEngineState (engine , litmuschaosv1alpha1 .EngineStateStop ); stopEngineWithAnnotationErrorMessage != nil {
600
604
r .Recorder .Eventf (engine .Instance , corev1 .EventTypeWarning , "ChaosResourcesOperationFailed" , "(chaos stop) Unable to update chaosengine" )
601
605
return reconcile.Result {}, fmt .Errorf ("unable to Update Engine State: %v" , err )
@@ -611,6 +615,9 @@ func (r *ChaosEngineReconciler) reconcileForCreationAndRunning(engine *chaosType
611
615
612
616
isCompleted , err := r .checkRunnerContainerCompletedStatus (engine )
613
617
if err != nil {
618
+ if k8serrors .IsNotFound (err ) {
619
+ return reconcile.Result {Requeue : true }, nil
620
+ }
614
621
r .Recorder .Eventf (engine .Instance , corev1 .EventTypeWarning , "ChaosResourcesOperationFailed" , "(chaos running) Unable to check chaos status" )
615
622
return reconcile.Result {}, err
616
623
}
@@ -643,7 +650,7 @@ func startReqLogger(request reconcile.Request) logr.Logger {
643
650
return reqLogger
644
651
}
645
652
646
- func (r * ChaosEngineReconciler ) validateAnnontatedApplication (engine * chaosTypes.EngineInfo ) error {
653
+ func (r * ChaosEngineReconciler ) validateAnnotatedApplication (engine * chaosTypes.EngineInfo ) error {
647
654
// Get the image for runner pod from chaosengine spec,operator env or default values.
648
655
setChaosResourceImage (engine )
649
656
@@ -746,6 +753,9 @@ func (r *ChaosEngineReconciler) updateChaosResult(engine *chaosTypes.EngineInfo,
746
753
747
754
for _ , result := range chaosresultList .Items {
748
755
if result .Labels ["chaosUID" ] == string (engine .Instance .UID ) {
756
+ if len (result .ObjectMeta .Annotations ) == 0 {
757
+ return nil
758
+ }
749
759
targetsList , annotations := getChaosStatus (result )
750
760
result .Status .History .Targets = targetsList
751
761
result .ObjectMeta .Annotations = annotations
0 commit comments