From 1e0c2ea90db325746df1e1a1c9bd8ead31e80de3 Mon Sep 17 00:00:00 2001 From: cuishuang Date: Thu, 26 Sep 2024 14:55:33 +0800 Subject: [PATCH] fix: fix slice init issue Signed-off-by: cuishuang --- cloud/pkg/cloudstream/iptables/iptables.go | 4 ++-- keadm/cmd/keadm/app/cmd/helm/installer.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud/pkg/cloudstream/iptables/iptables.go b/cloud/pkg/cloudstream/iptables/iptables.go index dc814cdde4e..75155aa3b2c 100644 --- a/cloud/pkg/cloudstream/iptables/iptables.go +++ b/cloud/pkg/cloudstream/iptables/iptables.go @@ -140,7 +140,7 @@ func (im *Manager) reconcile() { for _, ipports := range addedIPPort { ipport := strings.Split(ipports, ":") ip, port := ipport[0], ipport[1] - args := append([]string{"-p", "tcp", "-j", "DNAT", "--dport", port, "--to", ip + ":" + strconv.Itoa(im.streamPort)}) + args := []string{"-p", "tcp", "-j", "DNAT", "--dport", port, "--to", ip + ":" + strconv.Itoa(im.streamPort)} if _, err := im.iptables.EnsureRule(utiliptables.Append, utiliptables.TableNAT, tunnelPortChain, args...); err != nil { klog.ErrorS(err, "Failed to ensure rules", "table", utiliptables.TableNAT, "chain", tunnelPortChain) return @@ -150,7 +150,7 @@ func (im *Manager) reconcile() { for _, ipports := range deletedIPPort { ipport := strings.Split(ipports, ":") ip, port := ipport[0], ipport[1] - args := append([]string{"-p", "tcp", "-j", "DNAT", "--dport", port, "--to", ip + ":" + strconv.Itoa(im.streamPort)}) + args := []string{"-p", "tcp", "-j", "DNAT", "--dport", port, "--to", ip + ":" + strconv.Itoa(im.streamPort)} if err := im.iptables.DeleteRule(utiliptables.TableNAT, tunnelPortChain, args...); err != nil { klog.ErrorS(err, "Failed to delete rules", "table", utiliptables.TableNAT, "chain", tunnelPortChain) return diff --git a/keadm/cmd/keadm/app/cmd/helm/installer.go b/keadm/cmd/keadm/app/cmd/helm/installer.go index ee29fdaa283..246c0c8a573 100644 --- a/keadm/cmd/keadm/app/cmd/helm/installer.go +++ b/keadm/cmd/keadm/app/cmd/helm/installer.go @@ -341,7 +341,7 @@ func (cu *KubeCloudHelmInstTool) checkProfile(baseHelmRoot string) error { validProfiles[IptablesMgrProfileKey] = true validProfiles[ControllerManagerProfileKey] = true if ok := validProfiles[cu.ProfileKey]; !ok { - validKeys := make([]string, len(validProfiles)) + validKeys := make([]string, 0, len(validProfiles)) for k := range validProfiles { validKeys = append(validKeys, k) }