From: chengli3 Date: Fri, 6 Mar 2020 08:38:06 +0000 (+0000) Subject: Fix sdewan reconcile trigger X-Git-Tag: v1.0~39^2 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=24d28f19e64cadb6fa587bb7da83b9ba68ca4016;p=icn%2Fsdwan.git Fix sdewan reconcile trigger 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 Change-Id: I8f01733c373326b9167342118fd166834a7a8c45 --- diff --git a/api/v1alpha1/sdewan_types.go b/api/v1alpha1/sdewan_types.go index 8b39bc4..8909092 100644 --- a/api/v1alpha1/sdewan_types.go +++ b/api/v1alpha1/sdewan_types.go @@ -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 diff --git a/config/crd/bases/batch.sdewan.akraino.org_sdewans.yaml b/config/crd/bases/batch.sdewan.akraino.org_sdewans.yaml index 991b8cc..2fe38ef 100644 --- a/config/crd/bases/batch.sdewan.akraino.org_sdewans.yaml +++ b/config/crd/bases/batch.sdewan.akraino.org_sdewans.yaml @@ -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 diff --git a/controllers/mwan3conf_controller.go b/controllers/mwan3conf_controller.go index 8a92e3d..bf612ab 100644 --- a/controllers/mwan3conf_controller.go +++ b/controllers/mwan3conf_controller.go @@ -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)