Skip to content
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

nat: Create SNAT maps only if BPF NodePort is enabled #15175

Merged
merged 3 commits into from
Mar 10, 2021

Conversation

pchaigno
Copy link
Member

@pchaigno pchaigno commented Mar 2, 2021

The IPv4 and IPv6 SNAT maps are only used if BPF NodePort is enabled. #14721 removed the maps on startup if BPF NodePort is disabled.

We were however still creating them regardless of the BPF NodePort status. The creation started a controller which then fails once the actual map is removed. This commit fixes the issue by not creating the userspace object, including the controller, for the SNAT maps when BPF NodePort is disabled.

See commits for details.

Fixes: #14721
Fixes: #15141

Fix failing `bpf-map-sync-cilium_snat_v{4,6}_external` controllers when BPF NodePort is disabled

@pchaigno pchaigno added kind/bug This is a bug in the Cilium logic. release-note/bug This PR fixes an issue in a previous release of Cilium. needs-backport/1.8 labels Mar 2, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.10.0 Mar 2, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.9.5 Mar 2, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.8.8 Mar 2, 2021
@pchaigno pchaigno marked this pull request as ready for review March 9, 2021 10:48
@pchaigno pchaigno requested review from a team and jibi March 9, 2021 10:48
@pchaigno pchaigno requested a review from tklauser March 9, 2021 10:48
Copy link
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

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

Thanks!

@tklauser tklauser removed their assignment Mar 9, 2021
pkg/maps/ctmap/ctmap.go Outdated Show resolved Hide resolved
pkg/maps/nat/nat.go Outdated Show resolved Hide resolved
daemon/cmd/datapath.go Show resolved Hide resolved
Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

This seems fairly straightforward to me, just need to check & resolve the one outstanding thread

Copy link
Member

@christarazi christarazi left a comment

Choose a reason for hiding this comment

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

LGTM. Since this PR moves around daemon initialization order, we'll need to be careful when backporting this.

Using the NatMap interface was causing issues when trying to check if
the natMap attribute is nil. We don't need the NatMap interface and can
simply use *nat.Map directly.

Suggested-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Paul Chaignon <paul@cilium.io>
Initialize the kube-proxy replacement options earlier in the agent
startup, to ensure all options have reach their final state (based on
kernel probes and option conflict) when we initialize the BPF map
information (e.g., create or not NAT maps based on whether BPF NodePort
is enabled).

Signed-off-by: Paul Chaignon <paul@cilium.io>
The IPv4 and IPv6 SNAT maps are only used if BPF NodePort is enabled.
Commit cac5218 ("datapath: remove SNAT maps entries when kube-proxy is
enabled") removed the maps on startup if BPF NodePort is disabled.

We were however still creating them regardless of the BPF NodePort
status. The creation started a controller which then fails once the
actual map is removed. This commit fixes the issue by not creating the
userspace object, including the controller, for the SNAT maps when BPF
NodePort is disabled.

Fixes: cac5218 ("datapath: remove SNAT maps entries when kube-proxy is
enabled")
Fixes: cilium#15141
Signed-off-by: Paul Chaignon <paul@cilium.io>
@pchaigno pchaigno requested a review from a team as a code owner March 9, 2021 23:14
@pchaigno
Copy link
Member Author

pchaigno commented Mar 9, 2021

test-me-please

@joestringer joestringer added this to Needs backport from master in 1.8.9 Mar 9, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.9 in 1.9.5 Mar 10, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.9 in 1.9.5 Mar 10, 2021
@christarazi christarazi added this to Backport pending to v1.9 in 1.9.6 Mar 10, 2021
@christarazi christarazi removed this from Backport pending to v1.9 in 1.9.5 Mar 10, 2021
@joestringer joestringer removed this from Backport pending to v1.9 in 1.9.6 Mar 10, 2021
@joestringer joestringer added this to Backport done to v1.9 in 1.9.5 Mar 10, 2021
kkourt added a commit that referenced this pull request Apr 8, 2021
PR #14721 introduced changes that removed the
cilium_snat_v{4,6}_external maps if NodePort is not enabled.

Issue #15141 was attributed to the above PR, where controllers were
failing with:
> error=Unable to get object /sys/fs/bpf/tc/globals/cilium_snat_v4_external: no such file or directory  name=bpf-map-sync-cilium_snat_v4_external

In an attempt to fix #15141, #15175 added a nodeport argument to
InitMapInfo() so that the cilium_snat_v{4,6}_external maps are not
created if NodePort is not enabled.

PR #15141 did not fix the issue: #15337 (comment)

This PR takes another shot at fixing #15141 by removing a call of
InitMapInfo from init(), where the (new) nodeport argument is always
true.

Not that in init(), option.Config.EnableNodePort is not properly set
yet, so we cannot pass the config option because it would always be
false.

For this change to properly work, this patch also adds explicit
InitMapInfo() calls since removing init() means that this function is
called in contexts such as tests and the cli.

Fixes: cac5218
Fixes: d639905
Fixes: #15141
Fixes: #15337

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
pchaigno pushed a commit that referenced this pull request Apr 9, 2021
PR #14721 introduced changes that removed the
cilium_snat_v{4,6}_external maps if NodePort is not enabled.

Issue #15141 was attributed to the above PR, where controllers were
failing with:
> error=Unable to get object /sys/fs/bpf/tc/globals/cilium_snat_v4_external: no such file or directory  name=bpf-map-sync-cilium_snat_v4_external

In an attempt to fix #15141, #15175 added a nodeport argument to
InitMapInfo() so that the cilium_snat_v{4,6}_external maps are not
created if NodePort is not enabled.

PR #15141 did not fix the issue: #15337 (comment)

This PR takes another shot at fixing #15141 by removing a call of
InitMapInfo from init(), where the (new) nodeport argument is always
true.

Not that in init(), option.Config.EnableNodePort is not properly set
yet, so we cannot pass the config option because it would always be
false.

For this change to properly work, this patch also adds explicit
InitMapInfo() calls since removing init() means that this function is
called in contexts such as tests and the cli.

Fixes: cac5218
Fixes: d639905
Fixes: #15141
Fixes: #15337

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
jibi pushed a commit that referenced this pull request Apr 13, 2021
[ upstream commit e83dd53 ]

PR #14721 introduced changes that removed the
cilium_snat_v{4,6}_external maps if NodePort is not enabled.

Issue #15141 was attributed to the above PR, where controllers were
failing with:
> error=Unable to get object /sys/fs/bpf/tc/globals/cilium_snat_v4_external: no such file or directory  name=bpf-map-sync-cilium_snat_v4_external

In an attempt to fix #15141, #15175 added a nodeport argument to
InitMapInfo() so that the cilium_snat_v{4,6}_external maps are not
created if NodePort is not enabled.

PR #15141 did not fix the issue: #15337 (comment)

This PR takes another shot at fixing #15141 by removing a call of
InitMapInfo from init(), where the (new) nodeport argument is always
true.

Not that in init(), option.Config.EnableNodePort is not properly set
yet, so we cannot pass the config option because it would always be
false.

For this change to properly work, this patch also adds explicit
InitMapInfo() calls since removing init() means that this function is
called in contexts such as tests and the cli.

Fixes: cac5218
Fixes: d639905
Fixes: #15141
Fixes: #15337

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Signed-off-by: Gilberto Bertin <gilberto@isovalent.com>
qmonnet pushed a commit that referenced this pull request Apr 14, 2021
[ upstream commit e83dd53 ]

PR #14721 introduced changes that removed the
cilium_snat_v{4,6}_external maps if NodePort is not enabled.

Issue #15141 was attributed to the above PR, where controllers were
failing with:
> error=Unable to get object /sys/fs/bpf/tc/globals/cilium_snat_v4_external: no such file or directory  name=bpf-map-sync-cilium_snat_v4_external

In an attempt to fix #15141, #15175 added a nodeport argument to
InitMapInfo() so that the cilium_snat_v{4,6}_external maps are not
created if NodePort is not enabled.

PR #15141 did not fix the issue: #15337 (comment)

This PR takes another shot at fixing #15141 by removing a call of
InitMapInfo from init(), where the (new) nodeport argument is always
true.

Not that in init(), option.Config.EnableNodePort is not properly set
yet, so we cannot pass the config option because it would always be
false.

For this change to properly work, this patch also adds explicit
InitMapInfo() calls since removing init() means that this function is
called in contexts such as tests and the cli.

Fixes: cac5218
Fixes: d639905
Fixes: #15141
Fixes: #15337

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Signed-off-by: Gilberto Bertin <gilberto@isovalent.com>
christarazi pushed a commit to christarazi/cilium that referenced this pull request Apr 28, 2021
[ upstream commit e83dd53 ]

PR cilium#14721 introduced changes that removed the
cilium_snat_v{4,6}_external maps if NodePort is not enabled.

Issue cilium#15141 was attributed to the above PR, where controllers were
failing with:
> error=Unable to get object /sys/fs/bpf/tc/globals/cilium_snat_v4_external: no such file or directory  name=bpf-map-sync-cilium_snat_v4_external

In an attempt to fix cilium#15141, cilium#15175 added a nodeport argument to
InitMapInfo() so that the cilium_snat_v{4,6}_external maps are not
created if NodePort is not enabled.

PR cilium#15141 did not fix the issue: cilium#15337 (comment)

This PR takes another shot at fixing cilium#15141 by removing a call of
InitMapInfo from init(), where the (new) nodeport argument is always
true.

Not that in init(), option.Config.EnableNodePort is not properly set
yet, so we cannot pass the config option because it would always be
false.

For this change to properly work, this patch also adds explicit
InitMapInfo() calls since removing init() means that this function is
called in contexts such as tests and the cli.

Fixes: cac5218
Fixes: d639905
Fixes: cilium#15141
Fixes: cilium#15337

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Signed-off-by: Chris Tarazi <chris@isovalent.com>
ti-mo pushed a commit that referenced this pull request May 4, 2021
[ upstream commit e83dd53 ]

PR #14721 introduced changes that removed the
cilium_snat_v{4,6}_external maps if NodePort is not enabled.

Issue #15141 was attributed to the above PR, where controllers were
failing with:
> error=Unable to get object /sys/fs/bpf/tc/globals/cilium_snat_v4_external: no such file or directory  name=bpf-map-sync-cilium_snat_v4_external

In an attempt to fix #15141, #15175 added a nodeport argument to
InitMapInfo() so that the cilium_snat_v{4,6}_external maps are not
created if NodePort is not enabled.

PR #15141 did not fix the issue: #15337 (comment)

This PR takes another shot at fixing #15141 by removing a call of
InitMapInfo from init(), where the (new) nodeport argument is always
true.

Not that in init(), option.Config.EnableNodePort is not properly set
yet, so we cannot pass the config option because it would always be
false.

For this change to properly work, this patch also adds explicit
InitMapInfo() calls since removing init() means that this function is
called in contexts such as tests and the cli.

Fixes: cac5218
Fixes: d639905
Fixes: #15141
Fixes: #15337

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Signed-off-by: Chris Tarazi <chris@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is a bug in the Cilium logic. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
No open projects
1.8.8
Backport done to v1.8
1.9.5
Backport done to v1.9
Development

Successfully merging this pull request may close these issues.

Removing disabled maps causes controllers to fail
6 participants