Skip to content

Commit

Permalink
remove podIP patch
Browse files Browse the repository at this point in the history
podIP is only need if user use calico network policy

Signed-off-by: l1b0k <[email protected]>
  • Loading branch information
l1b0k committed Jan 9, 2025
1 parent 4ab7a38 commit e065445
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
22 changes: 22 additions & 0 deletions daemon/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/AliyunContainerService/terway/pkg/storage"
"github.com/AliyunContainerService/terway/pkg/tracing"
"github.com/AliyunContainerService/terway/pkg/utils"
"github.com/AliyunContainerService/terway/pkg/utils/nodecap"
vswpool "github.com/AliyunContainerService/terway/pkg/vswitch"
"github.com/AliyunContainerService/terway/types"
"github.com/AliyunContainerService/terway/types/daemon"
Expand Down Expand Up @@ -100,6 +101,27 @@ func (b *NetworkServiceBuilder) LoadGlobalConfig() *NetworkServiceBuilder {

b.service.ipamType = globalConfig.IPAMType

if nodecap.GetNodeCapabilities(nodecap.NodeCapabilityNetworkPolicyProvider) != "ebpf" &&
(nodecap.GetNodeCapabilities(nodecap.NodeCapabilityDataPath) == "veth" || nodecap.GetNodeCapabilities(nodecap.NodeCapabilityDataPath) == "") {
var np bool
out, err := os.ReadFile("/etc/eni/disable_network_policy")
if err != nil {
if !os.IsNotExist(err) {
b.err = err
return b
}
}
switch string(out) {
case "false", "0", "":
np = false
default:
np = true
}
if np {
b.service.enablePatchPodIPs = true
}
}

return b
}

Expand Down
10 changes: 7 additions & 3 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ type networkService struct {

gcRulesOnce sync.Once

enablePatchPodIPs bool

rpc.UnimplementedTerwayBackendServer
}

Expand Down Expand Up @@ -267,9 +269,11 @@ func (n *networkService) AllocIP(ctx context.Context, r *rpc.AllocIPRequest) (*r
}
}

ips := getPodIPs(netConf)
if len(ips) > 0 {
_ = n.k8s.PatchPodIPInfo(pod, strings.Join(ips, ","))
if n.enablePatchPodIPs {
ips := getPodIPs(netConf)
if len(ips) > 0 {
_ = n.k8s.PatchPodIPInfo(pod, strings.Join(ips, ","))
}
}

// 4. Record resource info
Expand Down

0 comments on commit e065445

Please sign in to comment.