Skip to content

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Oct 25, 2024

cilium-dbg: Replace the statedb command with "shell db" commands

    The "cilium-dbg statedb" command now returns a deprecated text that shows
    how to use the "cilium-dbg shell -- db" commands. We'll remove it fully in
    next release. The "cilium-dbg statedb dump" will probably need to be kept as
    a hidden command for bugtool compatibility.

    This removes the need to list all tables we want to inspect in statedb.go
    and the need to import bunch of agent packages to pull in the object types.

    Signed-off-by: Jussi Maki <jussi@isovalent.com>

daemon: Add FromString to StateDB table indexes

    To support queries using a string with the "db" script commands, add
    "FromString" implementation to all StateDB indexes.

    Signed-off-by: Jussi Maki <jussi@isovalent.com>

tl;dr: cilium-dbg statedb <table> commands now becomes cilium-dbg shell -- db show <table>. cilium-dbg statedb shows a deprecated disclaimer and example usage of shell -- db.

@joamaki joamaki requested review from a team as code owners October 25, 2024 13:20
@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 Oct 25, 2024
@joamaki joamaki force-pushed the pr/joamaki/simplify-statedb-dbg branch from 21a22dc to 26419af Compare October 25, 2024 13:22
@joamaki joamaki added the release-note/misc This PR makes changes that have no direct user impact. label Oct 25, 2024
@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 Oct 25, 2024
@joamaki
Copy link
Contributor Author

joamaki commented Oct 25, 2024

Hmm, since this is completely changing how "cilium-dbg statedb" command works, we could also just change the command to "cilium-dbg db". This way it'll also match the script command, and the help matches as well.

Or another option would be to kill the statedb command completely and instead just invoke these with cilium-dbg shell db ....

Also one annoying thing with this wrapper is that flag parsing will get mixed and requires quotes:

root@kind-worker:/home/cilium# cilium-dbg statedb "prefix -index=name devices cilium"
Name           Index   Selected   Type    MTU    HWAddr              Flags                    Addresses
cilium_host    3       false      veth    1500   c2:f6:99:50:af:71   up|broadcast|multicast   10.244.1.105, fe80::c0f6:99ff:fe50:af71
cilium_net     2       false      veth    1500   5e:70:20:4d:8a:bc   up|broadcast|multicast   fe80::5c70:20ff:fe4d:8abc
cilium_vxlan   4       false      vxlan   1500   b2:c6:10:14:48:47   up|broadcast|multicast   fe80::b0c6:10ff:fe14:4847

Not quite sure what to do about this. One option I guess is to not use flags in the "db" command and instead do some sort of query language. The flags are convenient to implement though and provide some command line usage help without much extra work.

I'm somewhat starting to lean towards just killing the "cilium-dbg statedb" command completely and exposing these via "cilium-dbg shell" only. If one is interested in poking at the database then you'll likely anyway want to go via cilium-dbg shell and run multiple commands in row. This way there's less confusion with mixing up the "cilium-dbg" pflag parsing with the script command parsing.

@tklauser
Copy link
Member

Hmm, since this is completely changing how "cilium-dbg statedb" command works, we could also just change the command to "cilium-dbg db". This way it'll also match the script command, and the help matches as well.

Or another option would be to kill the statedb command completely and instead just invoke these with cilium-dbg shell db ....

Also one annoying thing with this wrapper is that flag parsing will get mixed and requires quotes:

root@kind-worker:/home/cilium# cilium-dbg statedb "prefix -index=name devices cilium"
Name           Index   Selected   Type    MTU    HWAddr              Flags                    Addresses
cilium_host    3       false      veth    1500   c2:f6:99:50:af:71   up|broadcast|multicast   10.244.1.105, fe80::c0f6:99ff:fe50:af71
cilium_net     2       false      veth    1500   5e:70:20:4d:8a:bc   up|broadcast|multicast   fe80::5c70:20ff:fe4d:8abc
cilium_vxlan   4       false      vxlan   1500   b2:c6:10:14:48:47   up|broadcast|multicast   fe80::b0c6:10ff:fe14:4847

Not quite sure what to do about this. One option I guess is to not use flags in the "db" command and instead do some sort of query language. The flags are convenient to implement though and provide some command line usage help without much extra work.

That's unfortunate but I agree that that having them as flags with easy usage documentation provides a lot of benefits. We should just make sure to document the fact that flags needs to be quoted.

If the need arises we could still switch to a query language.

I'm somewhat starting to lean towards just killing the "cilium-dbg statedb" command completely and exposing these via "cilium-dbg shell" only. If one is interested in poking at the database then you'll likely anyway want to go via cilium-dbg shell and run multiple commands in row. This way there's less confusion with mixing up the "cilium-dbg" pflag parsing with the script command parsing.

+1 IMO this way would provide a more streamlined to the user and it also makes it easier to "transfer" commands used during an interactive session to a single non-interactive cilium-dbg shell invocation.

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.

Looks good, nice and clean! Two nits inline.

I've left my comments wrt. killing the statedb subcommand in a separate reply and I'll let you decide on how you want to move forward with this.

Copy link
Contributor

@learnitall learnitall left a comment

Choose a reason for hiding this comment

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

Vendor changes LGTM 🚀

@joamaki
Copy link
Contributor Author

joamaki commented Nov 5, 2024

Looks good, nice and clean! Two nits inline.

I've left my comments wrt. killing the statedb subcommand in a separate reply and I'll let you decide on how you want to move forward with this.

Thanks! I think simplifying is the way to go, but I don't want to leave folks used to "cilium-dbg statedb" confused. I'll make the "cilium-dbg statedb" just spit out a "deprecated message" that tells how to do the same things with cilium-dbg shell -- db show <table> etc. so we have a smooth transition. And then kill the command in v1.17.

@joamaki joamaki force-pushed the pr/joamaki/simplify-statedb-dbg branch from 26419af to 216f6cc Compare November 5, 2024 15:42
@joamaki joamaki requested review from a team as code owners November 5, 2024 15:42
@joamaki joamaki changed the title cilium-dbg: Reimplement statedb command using "db" script command cilium-dbg: Replace statedb command with "shell -- db show" Nov 5, 2024
@joamaki joamaki force-pushed the pr/joamaki/simplify-statedb-dbg branch 3 times, most recently from 8c0f161 to 243b05a Compare November 6, 2024 08:28
@joamaki
Copy link
Contributor Author

joamaki commented Nov 6, 2024

/test

@joamaki joamaki removed the request for review from markpash November 6, 2024 08:30
The "cilium-dbg statedb" command now returns a deprecated text that shows
how to use the "cilium-dbg shell -- db" commands. We'll remove it fully in
next release. The "cilium-dbg statedb dump" will probably need to be kept
as a hidden command for bugtool compatibility.

This removes the need to list all tables we want to inspect in statedb.go
and the need to import bunch of agent packages to pull in the object types.

Signed-off-by: Jussi Maki <jussi@isovalent.com>
To support queries using a string with the "db" script commands,
add "FromString" implementation to all StateDB indexes.

Signed-off-by: Jussi Maki <jussi@isovalent.com>
@joamaki joamaki force-pushed the pr/joamaki/simplify-statedb-dbg branch from 243b05a to 4a06fff Compare November 6, 2024 08:33
@joamaki
Copy link
Contributor Author

joamaki commented Nov 6, 2024

/test

@joamaki joamaki enabled auto-merge November 6, 2024 19:16
Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

egress-gateway changes LGTM 💯

@joamaki joamaki added this pull request to the merge queue Nov 7, 2024
@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 Nov 7, 2024
Merged via the queue into cilium:main with commit 41e9284 Nov 7, 2024
64 checks passed
@joamaki joamaki deleted the pr/joamaki/simplify-statedb-dbg branch November 7, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants