Skip to content

Commit

Permalink
persistentips, util: add AllowsPersistentIPs helper
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <[email protected]>
  • Loading branch information
maiqueb authored and jcaamano committed Sep 12, 2024
1 parent 725eb87 commit 8fae3ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ func (ncc *networkClusterController) hasNodeAllocation() bool {

func (ncc *networkClusterController) allowPersistentIPs() bool {
return config.OVNKubernetesFeature.EnablePersistentIPs &&
ncc.NetInfo.AllowsPersistentIPs() &&
util.DoesNetworkRequireIPAM(ncc.NetInfo) &&
(ncc.NetInfo.TopologyType() == types.Layer2Topology || ncc.NetInfo.TopologyType() == types.LocalnetTopology)
util.AllowsPersistentIPs(ncc.NetInfo)
}

func (ncc *networkClusterController) init() error {
Expand Down
3 changes: 1 addition & 2 deletions go-controller/pkg/ovn/base_network_controller_secondary.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,8 @@ func (bsnc *BaseSecondaryNetworkController) WatchIPAMClaims() error {

func (oc *BaseSecondaryNetworkController) allowPersistentIPs() bool {
return config.OVNKubernetesFeature.EnablePersistentIPs &&
oc.NetInfo.AllowsPersistentIPs() &&
util.DoesNetworkRequireIPAM(oc.NetInfo) &&
(oc.NetInfo.TopologyType() == types.Layer2Topology || oc.NetInfo.TopologyType() == types.LocalnetTopology)
util.AllowsPersistentIPs(oc.NetInfo)
}

func (oc *BaseSecondaryNetworkController) getNetworkID() (int, error) {
Expand Down
18 changes: 15 additions & 3 deletions go-controller/pkg/util/multi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,7 @@ func GetPodNADToNetworkMappingWithActiveNetwork(pod *kapi.Pod, nInfo NetInfo, ac
Name: activeNetworkNADKey[1],
}

if nInfo.IsPrimaryNetwork() &&
nInfo.TopologyType() == types.Layer2Topology &&
nInfo.AllowsPersistentIPs() {
if nInfo.IsPrimaryNetwork() && AllowsPersistentIPs(nInfo) {
ipamClaimName, wasPersistentIPRequested := pod.Annotations[OvnUDNIPAMClaimName]
if wasPersistentIPRequested {
networkSelections[activeNetworkNADs[0]].IPAMClaimReference = ipamClaimName
Expand All @@ -982,3 +980,17 @@ func DoesNetworkRequireTunnelIDs(netInfo NetInfo) bool {
// Layer2Topology with IC require that we allocate tunnel IDs for each pod
return netInfo.TopologyType() == types.Layer2Topology && config.OVNKubernetesFeature.EnableInterconnect
}

func AllowsPersistentIPs(netInfo NetInfo) bool {
switch {
case netInfo.IsPrimaryNetwork():
return netInfo.TopologyType() == types.Layer2Topology && netInfo.AllowsPersistentIPs()

case netInfo.IsSecondary():
return (netInfo.TopologyType() == types.Layer2Topology || netInfo.TopologyType() == types.LocalnetTopology) &&
netInfo.AllowsPersistentIPs()

default:
return false
}
}

0 comments on commit 8fae3ea

Please sign in to comment.