-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allocate tunnel IDs to pods attached to layer2 networks with interconnect #3673
Conversation
/cc |
d17c88d
to
7290144
Compare
/retest-failed |
5ac2f7c
to
6025ebd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do a really in depth review here, but looking at the gist of it I think it looks good. No major issues with this PR with regards to the layer 2 network commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good.
I just ask for some code to be squashed, and would rename the ID
attribute to something more explicit, because I worry ID
is too generic.
Thank you for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this commit maybe be squashed into the one where this struct is used ? If I have the usages, it becomes easier to understand how this is going to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What struct? What commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant commit 181cf96c14f1f354cca99b8f63d1cbf26c69bab5
- named Move ID allocator to allocator package
.
Like, I see this being moved from the clustermanager
package into a new allocator/id
package, but I don't see the new usage, thus I don't get why this is needed.
I guess that it will be used in commit 4d7e74b6444f68cde47583712e97fc63bd9bdb10
, whose title is Allocate an tunnel ID with the PodAnnotation
.
IMO it would still be IMO clearar if you squashed those, but this is just a nit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that you miss the reasoning and I added a commit message with an explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I read it. It makes sense, and is helpful.
I'm just saying actually seeing the usage from outside the package is more helpful than deriving meaning from a commit msg.
No need to follow-through, I've already understood what is happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that it would be easier to understand but that can lead to bigger commits. So I compromised here. I did that in the past restructuring packages, etc...
@@ -71,6 +71,9 @@ type PodAnnotation struct { | |||
Gateways []net.IP | |||
// Routes are additional routes to add to the pod's network namespace | |||
Routes []PodRoute | |||
|
|||
// ID assigned to each pod for L2 secondary networks | |||
ID int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this attribute is only useful for a particular type of network, I think its name should somehow reflect that. Maybe FlatL2TunnelID
?
Another question: here you specifically mean flatL2 topology, right ? Localnet does not require this, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to TunnelID
. I don't want to be more specific than that.
Reworded the comment as well. It's for layer2
topologies.
// derived from the allocator provided IPs. If the requested IPs cannot be | ||
// honored, a new set of IPs will be allocated unless reallocateIP is set to | ||
// false. | ||
func AllocatePodAnnotationWithID( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry ID is too generic. I think this should somehow hint it should be used from a particular topology type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to AllocatePodAnnotationWithTunnelID
. I don't really want to be more specific than that just in case is used for other things in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the purpose of this commit; isn't PodIPAllocator
more concrete / explicit than PodAllocator
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, but since we are going to be allocating IDs as well. I opted for the more generic name PodAllocator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ... But I would guess a PodAllocator
to allocate pods, not IPs for pods. On the other hand, I would expect a PodIPAllocator
to allocate IPs for pods - which is what this does.
Just saying I think there are advantages in being more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take suggestions for better names, but having globally good names is not always easy to come by. Naming has a context which does not require to come up with globally good names. The PodAllocator
has the context of operating within ovn-kubernets so it is obviously not allocating pods. It has documentation attached explaining what it does.
hasIDAllocation := util.DoesNetworkRequireIDs(a.netInfo) | ||
|
||
if !hasIPAM && !hasIDAllocation { | ||
// nothing to do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: redundant. I learn nothing from this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworded
@@ -26,7 +26,7 @@ type IDAllocator struct { | |||
|
|||
// NewIDAllocator returns an IDAllocator | |||
func NewIDAllocator(name string, maxIds int) (*IDAllocator, error) { | |||
idBitmap := bitmapallocator.NewContiguousAllocationMap(maxIds, name) | |||
idBitmap := bitmapallocator.NewRoundRobinAllocationMap(maxIds, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be squashed into the commit that introduced this code ?
Like, having this as a separate commit raises the question of what changed, and I guess nothing did: you could have created the ID allocator with this strategy directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't introduce this code. I will add to the commit message the reason I did this change.
6025ebd
to
89b6b81
Compare
Added commit messages that should hopefully give more clarity to the changes. @maiqueb PTAL |
89b6b81
to
5f6763e
Compare
releasedPodsMutex sync.Mutex | ||
} | ||
|
||
// NewPodAllocator builds a new PodIPAllocator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is outdated, isn't it ?
FWIW, I would still call this neat struct PodIPAllocator
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the doc attached with the PodAllocator
:
// PodAllocator acts on pods events handed off by the cluster network controller
// and allocates or releases resources (IPs and tunnel IDs at the time of this
// writing) to pods on behalf of cluster manager.
I don't think PodIPAllocator
fits. Can take other suggestions. I thought about PodResourceAllocator
but I didn't like it specially, as Resource can give the impression of referring to kubernetes resources, but I can bend here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Resource
is too generic and makes the reader think about kubernetes resources.
Let's leave it as is then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
30f5daa
to
e3d6369
Compare
@jcaamano I would almost merge the first 6 commits today... any chance you could split those out? (through |
2a880c0
to
41bf4bb
Compare
41bf4bb
to
fb78549
Compare
@@ -114,6 +114,8 @@ func (sncm *secondaryNetworkClusterManager) isTopologyManaged(nInfo util.NetInfo | |||
switch nInfo.TopologyType() { | |||
case ovntypes.Layer3Topology: | |||
return true | |||
case ovntypes.Layer2Topology: | |||
return config.OVNKubernetesFeature.EnableInterconnect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this decided based on if interconnect is enabled for not? If not IC, then allocation is handled somewhere else? where is that done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's done by ovnkube-master, in (bnc *BaseNetworkController) allocatePodAnnotationForSecondaryNetwork
. There we have a reciprocal check.
I will add comments here though.
why is layer2 network e2es enabled in this PR? going to be another PR? |
fb78549
to
6c3d49b
Compare
The ID allocator will be used form different packages. Lets add an interface to export its functionality and for easy mocking. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
So that it can be used to allocate tunnel IDs for pods from the clustermanager/pod package. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
Tunnel IDs will be allocated for a specific network from a context that should not affect allocation of other networks. Let's protect against this with an interface bounded to a specific network. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
Pods attached to secondary networks with layer2 topologies on interconnect require a tunnel ID allocated to be configured as tunnel keys on its logical switch ports of the transit switch. Allocate this tunnel Id in the PodAnnotation as it shares the same lifecycle as the other data stored there. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
Since it will now allocate tunnel IDs as well and not just IPs. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
Pods attached to secondary networks with layer2 topologies on interconnect require a tunnel ID allocated to be configured as tunnel keys on its logical switch ports of the transit switch. This add support to allocate such IDs from cluster manager. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
Tunnel IDs allocated to pods have a more dynamic lifecycle than IDs allocated to networks. Lets change the allocation strategy to round robin to reduce the posibility of potential collisions when a de-allocated tunnel ID is allocated to a pod while still being used by one of the zones that might have not yet process the original pod termination event. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
6c3d49b
to
a36b754
Compare
This will enable cluster manager to allocate the PodAnnotation to pods on interconnect instead of the zone controllers. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
a36b754
to
fd07c04
Compare
Layer 2 networks on interconnect require that we set a tunnel ID to the logical switch ports attached to the network switch that effectively becomes a transit switch.
This ID is allocated by cluster manager with the same life cycle of the IP allocation that we already had for localnet networks, now also for layer2 networks, so it makes sense to make this ID part of the PodAnnotation.