Fix sdewan reconcile trigger 88/2288/1
authorchengli3 <cheng1.li@intel.com>
Fri, 6 Mar 2020 08:38:06 +0000 (08:38 +0000)
committerchengli3 <cheng1.li@intel.com>
Fri, 6 Mar 2020 08:38:06 +0000 (08:38 +0000)
When mwan3Conf changes, the mwan3Conf controller update the sdewan
instance status to trigger the sdewan reconcile. Before this patch, we
update only the status field `IsApplied=false`. It could happen that the
field `IsApplied` was already false, if this is the case sdewan
reconcile will not be triggered. Because the sdewan CR is not changed.
This patch is to add another field in sdewan status, to make sure sdewan
reconcile is triggered once the mwan3Conf changes.

Signed-off-by: chengli3 <cheng1.li@intel.com>
Change-Id: I8f01733c373326b9167342118fd166834a7a8c45

api/v1alpha1/sdewan_types.go
config/crd/bases/batch.sdewan.akraino.org_sdewans.yaml
controllers/mwan3conf_controller.go

index 8b39bc4..8909092 100644 (file)
@@ -63,6 +63,7 @@ type SdewanStatus struct {
        // Important: Run "make" to regenerate code after modifying this file
        // +optional
        Mwan3Status Mwan3Status `json:"mwan3Status"`
+       Msg         string      `json:"msg"`
 }
 
 // +kubebuilder:object:root=true
index 991b8cc..2fe38ef 100644 (file)
@@ -64,6 +64,8 @@ spec:
         status:
           description: SdewanStatus defines the observed state of Sdewan
           properties:
+            msg:
+              type: string
             mwan3Status:
               description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
                 of cluster Important: Run "make" to regenerate code after modifying
@@ -81,6 +83,8 @@ spec:
               - isApplied
               - name
               type: object
+          required:
+          - msg
           type: object
       type: object
   version: v1alpha1
index 8a92e3d..bf612ab 100644 (file)
@@ -17,6 +17,7 @@ package controllers
 
 import (
        "context"
+       "time"
 
        "github.com/go-logr/logr"
        "k8s.io/apimachinery/pkg/api/errors"
@@ -68,6 +69,7 @@ func (r *Mwan3ConfReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
                        // Updating sdewan to set status isapplied = false
                        // this will trigger sdewan controller to apply the new conf
                        sdewan.Status.Mwan3Status = batchv1alpha1.Mwan3Status{Name: instance.Name, IsApplied: false}
+                       sdewan.Status.Msg = "triggered by mwan3Conf update at " + time.Now().String()
                        err := r.Status().Update(ctx, &sdewan)
                        if err != nil {
                                log.Error(err, "Failed to update the sdewan instance status", "sdewan", sdewan.Name)