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

daemon: Add wildcard support to --devices ("eth+") #15697

Merged
merged 1 commit into from Apr 28, 2021

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Apr 14, 2021

This adds support for device name wildcards to the "--devices"
option, e.g. if user specifies "--devices=eth+,en+" the agent
will match devices eth0, eth1, en0, etc.

Fixes: #15693

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 14, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.10.0 Apr 14, 2021
@joamaki joamaki requested a review from brb April 14, 2021 17:18
@joamaki joamaki added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Apr 14, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 14, 2021
@joamaki
Copy link
Contributor Author

joamaki commented Apr 14, 2021

test-me-please

c.Assert(detectDevices(true, true), IsNil)
c.Assert(option.Config.Devices, checker.DeepEquals, []string{"dummy1"})
c.Assert(option.Config.DirectRoutingDevice, Equals, "dummy1")
act()
Copy link
Member

Choose a reason for hiding this comment

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

Is it leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which one? act()? This function abstracted the namespace setup and act is the actual test function invoked in the new fresh namespace. Perhaps it could use a better name?

Copy link
Member

Choose a reason for hiding this comment

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

Where is it defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The diff looks a bit funny as I moved a chunk of code around. Perhaps have a look at the whole file? I added withFreshNetNS function that takes a function as argument and it takes care of setting up and tearing down the namespace around the act() function call.

Copy link
Member

Choose a reason for hiding this comment

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

Aha, I see it now. Maybe s/act/test/?

@joamaki joamaki force-pushed the pr/joamaki/devices-wildcard branch from 3d09b54 to 7e2bb90 Compare April 20, 2021 08:54
@joamaki
Copy link
Contributor Author

joamaki commented Apr 20, 2021

test-me-please

@joamaki joamaki marked this pull request as ready for review April 20, 2021 13:03
@joamaki joamaki requested a review from a team April 20, 2021 13:03
@joamaki joamaki force-pushed the pr/joamaki/devices-wildcard branch from 7e2bb90 to ff3261e Compare April 21, 2021 08:08
@joamaki joamaki force-pushed the pr/joamaki/devices-wildcard branch from ff3261e to a2fbd38 Compare April 22, 2021 08:25
Copy link
Member

@brb brb left a comment

Choose a reason for hiding this comment

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

The approach looks good!

A few things:

if err != nil {
log.WithError(err).Fatal("Cannot list network devices via netlink")
}
var expandedDevices []string
Copy link
Member

Choose a reason for hiding this comment

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

I'd use map (e.g. map[string]struct{}) instead to avoid duplicates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the deduplication and tests for it.

c.Assert(detectDevices(true, true), IsNil)
c.Assert(option.Config.Devices, checker.DeepEquals, []string{"dummy1"})
c.Assert(option.Config.DirectRoutingDevice, Equals, "dummy1")
act()
Copy link
Member

Choose a reason for hiding this comment

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

Where is it defined?

@joamaki joamaki force-pushed the pr/joamaki/devices-wildcard branch 2 times, most recently from 0b6b6c6 to 676ed2d Compare April 22, 2021 12:04
@joamaki joamaki requested a review from a team as a code owner April 22, 2021 12:04
@joamaki joamaki requested review from a team and qmonnet April 22, 2021 12:04
@joamaki joamaki force-pushed the pr/joamaki/devices-wildcard branch from 676ed2d to 7238631 Compare April 22, 2021 13:00
listed device has to be named the same on all Cilium managed nodes. Alternatively
if the devices do not match across different nodes, the wildcard option can be
used, e.g. ``devices=eth+``, which would match any device starting with prefix
``eth``.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add that if no device can be matched, then cilium-agent will try to perform the auto detection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@qmonnet qmonnet removed their assignment Apr 22, 2021
@joamaki joamaki force-pushed the pr/joamaki/devices-wildcard branch from 7238631 to 868a007 Compare April 26, 2021 08:14
@joamaki
Copy link
Contributor Author

joamaki commented Apr 26, 2021

test-me-please

@joamaki joamaki force-pushed the pr/joamaki/devices-wildcard branch from 868a007 to 524ed64 Compare April 27, 2021 07:02
@joamaki
Copy link
Contributor Author

joamaki commented Apr 27, 2021

test-net-next

Copy link
Member

@brb brb left a comment

Choose a reason for hiding this comment

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

🚀

This adds support for device name wildcards to the "--devices"
option, e.g. if user specifies "--devices=eth+,en+" the agent
will match devices eth0, eth1, en0, etc.

Fixes: cilium#15693

Signed-off-by: Jussi Maki <jussi@isovalent.com>
@aanm
Copy link
Member

aanm commented Apr 27, 2021

test-gke

@aanm
Copy link
Member

aanm commented Apr 27, 2021

test-runtime

@aanm
Copy link
Member

aanm commented Apr 27, 2021

test-1.20-4.19

@aanm
Copy link
Member

aanm commented Apr 27, 2021

test-1.21-4.9

@joamaki
Copy link
Contributor Author

joamaki commented Apr 28, 2021

test-net-next

@brb brb removed their assignment Apr 28, 2021
@joamaki
Copy link
Contributor Author

joamaki commented Apr 28, 2021

test-gke

@joamaki
Copy link
Contributor Author

joamaki commented Apr 28, 2021

test-runtime

@joamaki
Copy link
Contributor Author

joamaki commented Apr 28, 2021

test-1.21-4.9

@joamaki
Copy link
Contributor Author

joamaki commented Apr 28, 2021

test-1.20-4.19

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.

LGTM. An interesting followup would be to allow this to dynamically apply to new devices as they are attached (common in some cloud environments like EKS), but that's more of a "future wishlist" item. In the mean time if users are concerned about matching dynamic devices, they can restart the agent.

@joestringer joestringer merged commit efb3a72 into cilium:master Apr 28, 2021
1.10.0 automation moved this from In progress to Done Apr 28, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Backport pending to v1.10 in 1.10.0-rc2 Apr 28, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.10 to Backport done to v1.10 in 1.10.0-rc2 May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
No open projects
1.10.0-rc2
Backport done to v1.10
Development

Successfully merging this pull request may close these issues.

daemon: Make --devices to accept names with wildcards
6 participants