moomman commented on code in PR #316:
URL:
https://github.com/apache/shardingsphere-on-cloud/pull/316#discussion_r1173503988
##########
shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go:
##########
@@ -178,33 +190,54 @@ func (r *ShardingSphereChaosReconciler) reconcileJob(ctx
context.Context, ssChao
if ssChaos.Status.Phase == "" || ssChaos.Status.Phase ==
sschaosv1alpha1.PhaseBeforeExperiment || ssChaos.Status.Phase ==
sschaosv1alpha1.PhaseAfterExperiment {
nowInjectRequirement = reconcile.Experimental
}
- if ssChaos.Status.Phase == sschaosv1alpha1.PhaseInChaos ||
ssChaos.Status.Phase == sschaosv1alpha1.PhaseRecoveredChaos {
+ if ssChaos.Status.Phase == sschaosv1alpha1.PhaseInChaos {
nowInjectRequirement = reconcile.Pressure
}
+ if ssChaos.Status.Phase == sschaosv1alpha1.PhaseRecoveredChaos {
+ nowInjectRequirement = reconcile.Verify
+ }
if isExist {
return r.updateJob(ctx, nowInjectRequirement, ssChaos, rJob)
}
- return r.createJob(ctx, nowInjectRequirement, ssChaos)
+ err = r.createJob(ctx, nowInjectRequirement, ssChaos)
+ if err != nil {
+ r.Events.Event(ssChaos, "Warning", "Created", fmt.Sprintf("job
created fail %s", err))
+ return err
+ }
+
+ r.Events.Event(ssChaos, "Normal", "Created", fmt.Sprintf("%s job
created successfully", string(nowInjectRequirement)))
+ return nil
}
func (r *ShardingSphereChaosReconciler) reconcileStatus(ctx context.Context,
namespacedName types.NamespacedName) error {
ssChaos, err := r.getRuntimeSSChaos(ctx, namespacedName)
if err != nil {
return err
}
- if ssChaos.Status.Phase == "" {
- ssChaos.Status.Phase = sschaosv1alpha1.PhaseBeforeExperiment
- }
- rJob := &batchV1.Job{}
- if err := r.Get(ctx, namespacedName, rJob); err != nil {
+
+ SetDefault(ssChaos)
+
+ rJob, found, err := r.getJobByNamespacedName(ctx, namespacedName)
+ if err != nil || !found || rJob == nil {
return err
}
if ssChaos.Status.Phase == sschaosv1alpha1.PhaseBeforeExperiment &&
rJob.Status.Succeeded == 1 {
ssChaos.Status.Phase = sschaosv1alpha1.PhaseAfterExperiment
}
+ if rJob.Status.Failed == 1 {
Review Comment:
rJob type is k8s batchV1.job,I can not change it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]