Skip to content

fix(cli): pass --root and --node on to the decomposedfs metadata subcommands - #4087

Merged
asaah262 merged 1 commit into
opencloud-eu:mainfrom
asaah262:fix/4083-decomposedfs-metadata-flags
Nov 24, 2026
Merged

asaah262 merged 1 commit into
opencloud-eu:mainfrom
asaah262:fix/4083-decomposedfs-metadata-flags

Conversation

@asaah262

Copy link
Copy Markdown
Contributor

Description

opencloud decomposedfs metadata dump|get|set rejected --root and --node with unknown flag, so the commands couldn't be used at all. The flags are now persistent flags of metadata, so the subcommands inherit them.

  • --root and --node are defined with PersistentFlags() and marked required with MarkPersistentFlagRequired(), instead of Flags() / MarkFlagRequired(), which only applied to metadata itself.
  • New test TestMetadataCommands runs dump, get and set with the flags after and before the subcommand, with the short flags -r / -n, and without --root or --node.

Related Issue

Motivation and Context

The commands broke with the migration from urfave/cli to cobra in 56324ca: urfave/cli let subcommands read the flags of their parent, cobra's Flags() doesn't. See #4083 for the details.

How Has This Been Tested?

  • test environment: macOS, Go tests and the built opencloud binary
  • go test -race ./opencloud/pkg/command/: the 15 new cases fail without the fix (unknown flag: --root) and pass with it
  • built binary on a small decomposed storage with one node: dump prints its metadata, get -a user.demo prints one attribute, set changes it
  • without --root: required flag(s) "root" not set

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the code, the tests and this description; I reviewed and adjusted them.

…ommands

Assisted-by: Claude Code:claude-opus-5-5
@codacy-production

codacy-production Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 10 complexity

Metric Results
Complexity 10

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.05% coverage variation

Metric Results
Coverage variation ✅ +0.05% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (43211c1) 94312 28356 30.07%
Head commit (4f92565) 94313 (+1) 28403 (+47) 30.12% (+0.05%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4087) 5 5 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@pbleser-oc pbleser-oc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Sara, the fix is right: cobra only hands persistent flags on to subcommands, and dump, get and set are the ones that read --root and --node. The tests cover it well. With the old flag definitions, 19 of the subtests fail with unknown flag: --root and unknown shorthand flag: 'r', and with your change they all pass. Checking the error of getBackend with the path of --root is a neat way to see that the value arrives, without having to set up a storage.

One thing I noticed while reading, not for this PR: the help of --node says "Path to or ID of the node", but as far as I can see, getNode only accepts an ID (storagespace.ParseID). Maybe something for a follow-up, either in the help text or in getNode.

@asaah262

asaah262 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@pbleser-oc Thanks for the review and for running the tests against the old flags!

Good catch on --node. You're right: getNode only takes an ID (storagespace.ParseID, then NodeFromID). A path isn't even rejected, it's taken as a space ID. The help text was like that before the cobra migration, so I left it out of this PR and opened #4110 with both options: fix the help text, or let getNode accept a path.

@asaah262
asaah262 merged commit aa83ea9 into opencloud-eu:main Nov 24, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: opencloud decomposedfs metadata dump|get|set reject --root and --node

2 participants