diff --git a/pkg/controller/component/graphd_cluster.go b/pkg/controller/component/graphd_cluster.go index 42bc7e81..25751ae2 100644 --- a/pkg/controller/component/graphd_cluster.go +++ b/pkg/controller/component/graphd_cluster.go @@ -140,7 +140,7 @@ func (c *graphdCluster) syncGraphdWorkload(nc *v1alpha1.NebulaCluster) error { if nc.GraphdComponent().IsReady() { endpoints := nc.GetGraphdEndpoints(v1alpha1.GraphdPortNameHTTP) - if err := updateDynamicFlags(endpoints, newWorkload.GetAnnotations(), oldWorkload.GetAnnotations()); err != nil { + if err := updateDynamicFlags(endpoints, newWorkload.GetAnnotations()); err != nil { return fmt.Errorf("update graphd cluster %s dynamic flags failed: %v", newWorkload.GetName(), err) } } diff --git a/pkg/controller/component/helper.go b/pkg/controller/component/helper.go index fd702c68..48dbad82 100644 --- a/pkg/controller/component/helper.go +++ b/pkg/controller/component/helper.go @@ -19,7 +19,6 @@ package component import ( "encoding/json" "fmt" - "reflect" "strings" "time" @@ -218,7 +217,7 @@ func staticFlags(config map[string]string) map[string]string { return static } -func updateDynamicFlags(endpoints []string, newAnnotations, oldAnnotations map[string]string) error { +func updateDynamicFlags(endpoints []string, newAnnotations map[string]string) error { newFlags := make(map[string]string) newFlagsVal, ok := newAnnotations[annotation.AnnLastAppliedDynamicFlagsKey] if ok { @@ -226,23 +225,11 @@ func updateDynamicFlags(endpoints []string, newAnnotations, oldAnnotations map[s return err } } - oldFlags := make(map[string]string) - oldFlagsVal, ok := oldAnnotations[annotation.AnnLastAppliedDynamicFlagsKey] - if ok { - if err := json.Unmarshal([]byte(oldFlagsVal), &oldFlags); err != nil { - return err - } - } - if reflect.DeepEqual(newFlags, oldFlags) { + if len(newFlags) == 0 { return nil } - - updated, removed := maputil.IntersectionDifference(oldFlags, newFlags) - _, added := maputil.IntersectionDifference(newFlags, oldFlags) - maputil.ResetMap(removed, v1alpha1.DynamicFlags) - merged := maputil.MergeStringMaps(true, updated, added, removed) - klog.Infof("merged dynamic flags: %v", merged) - str, err := codec.Encode(merged) + klog.Infof("dynamic flags: %v", newFlags) + str, err := codec.Encode(newFlags) if err != nil { return err } diff --git a/pkg/controller/component/metad_cluster.go b/pkg/controller/component/metad_cluster.go index c4041eb2..eb34e2d7 100644 --- a/pkg/controller/component/metad_cluster.go +++ b/pkg/controller/component/metad_cluster.go @@ -141,7 +141,7 @@ func (c *metadCluster) syncMetadWorkload(nc *v1alpha1.NebulaCluster) error { } endpoints := nc.GetMetadEndpoints(v1alpha1.MetadPortNameHTTP) - if err := updateDynamicFlags(endpoints, newWorkload.GetAnnotations(), oldWorkload.GetAnnotations()); err != nil { + if err := updateDynamicFlags(endpoints, newWorkload.GetAnnotations()); err != nil { return fmt.Errorf("update metad cluster %s dynamic flags failed: %v", newWorkload.GetName(), err) } } diff --git a/pkg/controller/component/storaged_cluster.go b/pkg/controller/component/storaged_cluster.go index 6a20c3c5..b1161101 100644 --- a/pkg/controller/component/storaged_cluster.go +++ b/pkg/controller/component/storaged_cluster.go @@ -184,7 +184,7 @@ func (c *storagedCluster) syncStoragedWorkload(nc *v1alpha1.NebulaCluster) error if nc.StoragedComponent().IsReady() { endpoints := nc.GetStoragedEndpoints(v1alpha1.StoragedPortNameHTTP) - if err := updateDynamicFlags(endpoints, newWorkload.GetAnnotations(), oldWorkload.GetAnnotations()); err != nil { + if err := updateDynamicFlags(endpoints, newWorkload.GetAnnotations()); err != nil { return fmt.Errorf("update storaged cluster %s dynamic flags failed: %v", newWorkload.GetName(), err) } diff --git a/pkg/util/http/http.go b/pkg/util/http/http.go index 1b2bf65a..08993abf 100644 --- a/pkg/util/http/http.go +++ b/pkg/util/http/http.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "net/http" "time" @@ -44,7 +44,7 @@ func request(url, method string, jsonData []byte) ([]byte, error) { } }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("io read error: %v", err) }