Skip to content

3.27.x backport: getopt_long optstring fixes (#6262) - #6363

Open
claude[bot] wants to merge 11 commits into
3.27.xfrom
pr-getopt-optstring-backport-3.27
Open

claude[bot] wants to merge 11 commits into
3.27.xfrom
pr-getopt-optstring-backport-3.27

Conversation

@claude

@claude claude Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Requested by Ole Herman · Slack thread

Backport of the getopt_long optstring fixes to 3.27.x. All 10 commits cherry-picked with -x from the original PR: #6262

🤖 Generated with Claude Code

https://claude.ai/code/session_01QBeMeG8RBD7KoaQchhpCGq

The --version long option worked, but the advertised -V short form
was rejected as an unknown option because 'V' was missing from the
getopt option string. The case 'V' handler already existed.

Changelog: Fixed cf-check -V (--version) short option
(cherry picked from commit 89d8d81)
'1' had no option table entry and no switch case, so -1 fell through
to the generic usage error. It is a leftover from a removed
undocumented alias for -F; --once/-O supersedes it.

Changelog: none
(cherry picked from commit da0c3f6)
'S' had no option table entry and no switch case, so -S fell through
to the generic usage error. It is a leftover from the --syntax option
removed in 2008.

Changelog: none
(cherry picked from commit fa793f5)
The long options --tls-version and --ciphers worked, but their
advertised short forms -t and -c were rejected as unknown options
because they were missing from the getopt option string. Both take
a required argument and both already have switch case handlers.

Changelog: Fixed cf-net -t (--tls-version) and -c (--ciphers) short options
(cherry picked from commit 8f1f652)
…tring

Neither had an option table entry or a switch case: -S fell through
to the generic usage error (leftover from the removed --syntax
option), and -i silently swallowed an argument before erroring out.
The deliberate deprecated -r error shim is left untouched.

Changelog: none
(cherry picked from commit 2d43475)
…tring

Neither had an option table entry or a switch case: -q silently
swallowed an argument before failing with the generic usage error
(leftover from --query, which moved to cf-hub in 2013), and -S fell
through to the same error (vestigial since 2008).

Changelog: none
(cherry picked from commit f7817a3)
The -K short option already worked (it sets ignore_locks) but had no
option table entry, so it had no long form and was missing from
--help and man output. This adds the --no-lock long option and hint,
matching cf-agent, cf-execd, cf-serverd and cf-monitord.

Changelog: Added --no-lock long option to cf-runagent, matching the existing -K short option
(cherry picked from commit 4fd98b4)
The --verbose, --inform and --log-level long options worked and their
short forms are advertised in help and man output, but -v, -I and -g
were rejected as unknown options because they were missing from the
getopt option string. Also removed the stray 'e' left over from the
removed --encrypt option.

Changelog: Fixed cf-secret -v (--verbose), -g (--log-level) and -I (--inform) short options
(cherry picked from commit 443c911)
The option table declares --ld-library-path as required_argument, but
the option string had a bare 'L', so '-L <path>' left optarg NULL
(dereferenced unconditionally) and the path behind as a stray
positional argument. Also removed the stray 'S' left over from the
--syntax option removed in 2008.

Changelog: Fixed cf-serverd -L (--ld-library-path) to accept its argument
(cherry picked from commit 660af3c)
The --report long option worked and -r is advertised in help output,
but the short form was rejected because 'r' was missing from the
getopt option string. Also removed the orphan 'f:' left behind when
--file/-f was renamed to --report/-r.

Changelog: none
(cherry picked from commit 9bad591)
@CLAassistant

CLAassistant commented Sep 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ victormlg
❌ claude
You have signed the CLA already but the status is still pending? Let us recheck it.

Changelog: title
Signed-off-by: Victor Moene <victor.moene@northern.tech>

As of LMDB 1.0.0, MDB_MAXKEYSIZE defaults to 0 (computed from the page size) instead of the fixed compile-time 511 used by LMDB <1.0.0, and mdb_env_get_maxkeysize() only returns the correct value once the environment has actually been opened (env->me_maxkey is populated by mdb_env_open()). So this can only be checked after a successful open, not beforehand like it could with older LMDB versions.

The assertion breaks on macos because the environement there uses a newer lmdb package.

(cherry picked from commit 0e31cc1)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBeMeG8RBD7KoaQchhpCGq
@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Author

CI note: macos_unit_tests / macos_unit_tests failed on 130582c — pre-existing 3.27.x breakage, not caused by this PR.

The job failed in the Run unit tests step (make -C tests/unit check, exit code 2). All other checks on the same SHA passed, including the Linux unit tests, ASAN unit tests, and valgrind — so the getopt optstring changes themselves are not breaking the test suite.

Why this is not this PR's failure:

  • The same failure hit master in mid-September: GitHub's macos-latest runners now get LMDB >= 1.0.0 from Homebrew, where mdb_env_get_maxkeysize() no longer returns the fixed 511 before mdb_env_open(). That trips assert(mdb_env_get_maxkeysize(env) == 511) in libpromises/dbm_lmdb.c:LmdbEnvOpen() in --enable-debug builds, aborting every unit test that opens an LMDB database.
  • master fixed this in ENT-14470: Fixed lmdb maxkeysize assertion for macos #6356 (commit 0e31cc1, "Fixed lmdb maxkeysize assertion for macos", merged 2026-09-16); master PR CI runs have been green on macOS since (e.g. runs 35838128825, 35707244641).
  • 3.27.x never got that fix, and no 3.27.x-based PR has run CI since 2026-09-03 (CFE-4714: Added the parameters of the remaining variadic functions to the syntax description (3.27.x) #6342) — before the runner/Homebrew drift — so this PR is simply the first 3.27.x branch to hit it. This PR's diff only touches getopt_long short-option strings in the daemons' main option parsing, nothing LMDB- or macOS-related.

Fix ported: cherry-picked 0e31cc1 from master onto this branch as 6ed5868, which moves the maxkeysize assertion to after a successful mdb_env_open() and relaxes it to >= 511. The push has kicked off a fresh CI run.

Related but not needed for CI: master also carries 9ae3c4f ("Fix DBPrivClean() for LMDB 1.0.0 mdb_drop() semantics"), another LMDB 1.0.0 compatibility fix missing from 3.27.x. It is only exercised via cf-agent's package module (no unit test covers it), so it is left as a possible separate backport.


Generated by Claude Code

@olehermanse

Copy link
Copy Markdown
Member

@cf-bottom jenkins, please

@cf-bottom

Copy link
Copy Markdown

@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Author

CI note: ci/FR-tests failed on 6ed5868 (fr-tests #809); ci/sequential-tests is still running. This PR only changes getopt_long short-option strings in the daemons (plus the LMDB assertion fix already on 3.27.x via #6364), and every other check is green — all 27 Jenkins package builds, bootstrap-tests, asan/valgrind/static checks, and all 8 GitHub Actions suites (unit, ASAN, valgrind, acceptance, macOS, static, lint, shellcheck). ci/FR-tests fails intermittently on unrelated PRs in this repo — it was also red on the heads of #6367 and #6358, both merged this week despite it, and it failed on the original #6262 as well — so the failure doesn't look diff-specific. I can't re-trigger Jenkins from this environment; a maintainer can re-run it with @cf-bottom jenkins, please.


Generated by Claude Code

@cf-bottom

Copy link
Copy Markdown

@claude[bot] : I'm sorry, I cannot do that. @olehermanse please help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants