moomman commented on code in PR #316:
URL: 
https://github.com/apache/shardingsphere-on-cloud/pull/316#discussion_r1173514757


##########
shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go:
##########
@@ -213,10 +246,137 @@ func (r *ShardingSphereChaosReconciler) 
reconcileStatus(ctx context.Context, nam
        if err != nil {
                return err
        }
-       rt.Status = ssChaos.Status
+       setRtStatus(rt, ssChaos)
        return r.Status().Update(ctx, rt)
 }
 
+func SetDefault(ssChaos *sschaosv1alpha1.ShardingSphereChaos) {
+       if ssChaos.Status.Phase == "" {
+               ssChaos.Status.Phase = sschaosv1alpha1.PhaseBeforeExperiment
+       }
+       if len(ssChaos.Status.Result) <= 0 || ssChaos.Status.Result == nil {
+               ssChaos.Status.Result = []sschaosv1alpha1.Result{}
+       }
+}
+
+func setRtStatus(rt *sschaosv1alpha1.ShardingSphereChaos, ssChaos 
*sschaosv1alpha1.ShardingSphereChaos) {
+       rt.Status.Result = []sschaosv1alpha1.Result{}
+       for i := range ssChaos.Status.Result {
+               rt.Status.Result = append(rt.Status.Result, 
sschaosv1alpha1.Result{
+                       Success: ssChaos.Status.Result[i].Success,
+                       Details: sschaosv1alpha1.Details{
+                               Time: metav1.Time{Time: time.Now()},
+                               Msg:  ssChaos.Status.Result[i].Details.Msg,
+                       },
+               })
+       }
+       rt.Status.Phase = ssChaos.Status.Phase
+       rt.Status.ChaosCondition = ssChaos.Status.ChaosCondition
+}
+
+func (r *ShardingSphereChaosReconciler) updateRecoveredJob(ctx 
context.Context, ssChaos *sschaosv1alpha1.ShardingSphereChaos, rJob 
*batchV1.Job) error {
+       if checkResultExist(rJob) {
+               return nil
+       }
+       check := "Verify"
+       for i := range ssChaos.Status.Result {
+               if len(ssChaos.Status.Result[i].Details.Msg) >= len(check) && 
ssChaos.Status.Result[i].Details.Msg[:len(check)] == check {
+                       return nil
+               }
+       }
+       logOpts := &v1.PodLogOptions{}
+       pod, err := r.getPodHaveLog(ctx, rJob)
+       if err != nil {
+               return err
+       }
+       containerNamespacedname := types.NamespacedName{

Review Comment:
   yes,i will 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]

Reply via email to