Skip to content

Conversation

gandro
Copy link
Member

@gandro gandro commented Mar 10, 2021

A VPC on EC2 can have secondary CIDRs which are routable within the VPC.
Subnets which are used in Cilium's ENI IPAM mode might be derived from
these secondary CIDRs, therefore we must also install routes for these
secondary CIDRs.

This commit ensures that we populate the
CiliumNode.Status.ENI.ENIS[].VPC.CIDRs field with these secondary
CIDRs if present. The IPAM code on the agent is already set up to
install routes for these additional CIDRs [1], but since this field was
never populated, the rules were also missing. Therefore, this fixes a
bug where routes were missing in ENI IPAM mode, causing arbitrary
connecitivty issues.

With this commit, routes are only added for CIDRs which are present when
the IP is allocated. A subsequent PR will add the functionality to
update the routes dynamically in case CIDRs are added or removed from a
VPC.

[1]

result.CIDRs = append(result.CIDRs, eni.VPC.CIDRs...)

@gandro gandro added the release-note/bug This PR fixes an issue in a previous release of Cilium. label Mar 10, 2021
@gandro gandro force-pushed the pr/gandro/eni-add-vpc-cidrs branch from 69158d6 to 75f668b Compare March 10, 2021 15:47
@gandro gandro force-pushed the pr/gandro/eni-add-vpc-cidrs branch from 75f668b to 4628a4e Compare March 10, 2021 17:02
@gandro gandro changed the title ipam: Populate AWS VPC CIDRs ipam: Fix ENI routing for secondary CIDRs Mar 10, 2021
@gandro gandro added area/eni Impacts ENI based IPAM. needs-backport/1.8 labels Mar 10, 2021
A VPC on EC2 can have secondary CIDRs which are routable within the VPC.
Subnets which are used in Cilium's ENI IPAM mode might be derived from
these secondary CIDRs, therefore we must also install routes for these
secondary CIDRs.

This commit ensures that we populate the
`CiliumNode.Status.ENI.ENIS[].VPC.CIDRs` field with these secondary
CIDRs if present. The IPAM code on the agent is already set up to
install routes for these additional CIDRs [1], but since this field was
never populated, the rules were also missing. Therefore, this fixes a
bug where routes were missing in ENI IPAM mode, causing arbitrary
connecitivty issues.

With this commit, routes are only added for CIDRs which are present when
the IP is allocated. A subsequent PR will add the functionality to
update the routes dynamically in case CIDRs are added or removed from a
VPC.

[1] https://github.com/cilium/cilium/blob/2110b11c989fe7ef8c7d9c5510c53a55cdaaa54c/pkg/ipam/crd.go#L488

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
@gandro gandro force-pushed the pr/gandro/eni-add-vpc-cidrs branch from 4628a4e to 40c5066 Compare March 10, 2021 17:05
@gandro gandro marked this pull request as ready for review March 10, 2021 17:06
@gandro gandro requested a review from a team as a code owner March 10, 2021 17:06
@gandro gandro requested review from a team and tgraf March 10, 2021 17:06
@gandro
Copy link
Member Author

gandro commented Mar 10, 2021

test-me-please

Copy link
Contributor

@twpayne twpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@twpayne
Copy link
Contributor

twpayne commented Mar 10, 2021

Note that the ConformanceKind1.9 / installation-and-connectivity failure is a known flake.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Mar 11, 2021
@tgraf
Copy link
Member

tgraf commented Mar 11, 2021

Great work!

@aanm aanm added dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs and removed dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs labels Mar 11, 2021
@kkourt kkourt merged commit b447fde into cilium:master Mar 12, 2021
gandro added a commit to gandro/cilium that referenced this pull request Apr 12, 2021
When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. cilium#15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
aanm pushed a commit that referenced this pull request Apr 15, 2021
When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. #15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
jrfastab pushed a commit to jrfastab/cilium that referenced this pull request Apr 15, 2021
[ upstream commit 793d45a ]

When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. cilium#15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
jrfastab pushed a commit that referenced this pull request Apr 15, 2021
[ upstream commit 793d45a ]

When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. #15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
aanm pushed a commit that referenced this pull request Apr 16, 2021
[ upstream commit 793d45a ]

When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. #15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
joestringer pushed a commit that referenced this pull request Apr 24, 2021
[ upstream commit 793d45a ]

When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. #15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
joestringer pushed a commit to joestringer/cilium that referenced this pull request Apr 26, 2021
[ upstream commit 793d45a ]

When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. cilium#15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
joestringer pushed a commit that referenced this pull request May 5, 2021
[ upstream commit 793d45a ]

When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. #15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
jrajahalme pushed a commit that referenced this pull request May 6, 2021
[ upstream commit 793d45a ]

When taking a reference of the iterated value in Golang, one needs to
take care to copy the value before taking a reference.

In the case of EKS (where we can have multiple VPC CIDRs, c.f. #15303)
this meant that we only the last routing CIDR was appended to
`IPv4PodSubnets`.

Fixes: a42d442 ("cilium: auto-discovery pod subnets for ENI IPAM")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/eni Impacts ENI based IPAM. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants