Do a few less updates
This commit is contained in:
@@ -19,6 +19,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@@ -111,6 +112,7 @@ func (r *NetworkconfigurationReconciler) Reconcile(ctx context.Context, req ctrl
|
|||||||
Vlan: int64(unifinetwork.VLAN),
|
Vlan: int64(unifinetwork.VLAN),
|
||||||
VlanEnabled: unifinetwork.VLANEnabled,
|
VlanEnabled: unifinetwork.VLANEnabled,
|
||||||
}
|
}
|
||||||
|
if !reflect.DeepEqual(networkObj.Spec, networkSpec) {
|
||||||
networkObj.Spec = networkSpec
|
networkObj.Spec = networkSpec
|
||||||
err := r.Update(ctx, &networkObj)
|
err := r.Update(ctx, &networkObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -118,6 +120,7 @@ func (r *NetworkconfigurationReconciler) Reconcile(ctx context.Context, req ctrl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !found {
|
if !found {
|
||||||
err := r.Delete(ctx, &networkObj)
|
err := r.Delete(ctx, &networkObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -210,12 +213,15 @@ func (r *NetworkconfigurationReconciler) Reconcile(ctx context.Context, req ctrl
|
|||||||
} else {
|
} else {
|
||||||
for _, networkCRD := range networkCRDs.Items {
|
for _, networkCRD := range networkCRDs.Items {
|
||||||
if networkCRD.Spec.Name == unifinetwork.Name {
|
if networkCRD.Spec.Name == unifinetwork.Name {
|
||||||
|
if !reflect.DeepEqual(networkCRD.Spec, networkSpec) {
|
||||||
networkCRD.Spec = networkSpec
|
networkCRD.Spec = networkSpec
|
||||||
}
|
|
||||||
err := r.Update(ctx, &networkCRD)
|
err := r.Update(ctx, &networkCRD)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(networkCRD.Status, networkStatus) {
|
||||||
|
networkCRD.Status = networkStatus
|
||||||
if err = r.Status().Update(ctx, &networkCRD); err != nil {
|
if err = r.Status().Update(ctx, &networkCRD); err != nil {
|
||||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
return ctrl.Result{RequeueAfter: 10 * time.Minute}, err
|
||||||
}
|
}
|
||||||
@@ -223,6 +229,8 @@ func (r *NetworkconfigurationReconciler) Reconcile(ctx context.Context, req ctrl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ctrl.Result{RequeueAfter: 10 * time.Minute}, nil
|
return ctrl.Result{RequeueAfter: 10 * time.Minute}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user