Skip to content

Commit

Permalink
Merge pull request #324 from moomman/fix-status
Browse files Browse the repository at this point in the history
feat(operator): fix status.result error
  • Loading branch information
mlycore authored Apr 28, 2023
2 parents a491745 + 62fd385 commit 1712e57
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,18 @@ func (r *ShardingSphereChaosReconciler) setDefaultStatus(chaos *v1alpha1.Shardin
}
}

func isRecoveredJobType(rJob *batchV1.Job, requirement reconcile.InjectRequirement) bool {
for i := range rJob.Spec.Template.Spec.Containers[0].Args {
r := rJob.Spec.Template.Spec.Containers[0].Args[i]
if strings.Contains(r, string(requirement)) {
return true
}
}
return false
}

func (r *ShardingSphereChaosReconciler) updateRecoveredJob(ctx context.Context, ssChaos *v1alpha1.ShardingSphereChaos, rJob *batchV1.Job) error {
if isResultExist(rJob) {
if !isRecoveredJobType(rJob, reconcile.Verify) {
return nil
}

Expand Down Expand Up @@ -433,6 +443,7 @@ func (r *ShardingSphereChaosReconciler) updateRecoveredJob(ctx context.Context,
Message: fmt.Sprintf("%s: %s", VerifyJobCheck, log),
}
}
ssChaos.Status.Results = updateResult(ssChaos.Status.Results, *result, VerifyJobCheck)
}

if condition == FailureJob {
Expand All @@ -445,15 +456,15 @@ func (r *ShardingSphereChaosReconciler) updateRecoveredJob(ctx context.Context,
Time: metav1.Time{Time: time.Now()},
Message: fmt.Sprintf("%s: %s", VerifyJobCheck, log),
}
ssChaos.Status.Results = updateResult(ssChaos.Status.Results, *result, VerifyJobCheck)
}

ssChaos.Status.Results = updateResult(ssChaos.Status.Results, *result, VerifyJobCheck)

return nil
}

func (r *ShardingSphereChaosReconciler) getPodHaveLog(ctx context.Context, rJob *batchV1.Job) (*corev1.Pod, error) {
pods := &corev1.PodList{}

if err := r.List(ctx, pods, client.MatchingLabels{"controller-uid": rJob.Spec.Template.Labels["controller-uid"]}); err != nil {
return nil, err
}
Expand Down

0 comments on commit 1712e57

Please sign in to comment.