Skip to content

fix(dgraphtest): give Zero the admin whitelist the Alpha already gets - #9818

Closed
matthewmcneely wants to merge 1 commit into
mainfrom
matthewmcneely/dgraphtest-zero-admin-whitelist
Closed

fix(dgraphtest): give Zero the admin whitelist the Alpha already gets#9818
matthewmcneely wants to merge 1 commit into
mainfrom
matthewmcneely/dgraphtest-zero-admin-whitelist

Conversation

@matthewmcneely

@matthewmcneely matthewmcneely commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description

Zero guards /moveTablet and /removeNode with adminAuthHandler(strict=true), so they are
protected whether or not --security is configured: with neither a token nor a whitelist, only a
loopback caller is admitted. dgraphtest passes --security to the Alpha and never to Zero, so a
test process reaching Zero through a published container port cannot call those endpoints at all.

Pre-v21 is deliberately excluded: those binaries predate both the --security superflag and the
admin guard, so passing it there would fail an upgrade test with an unknown-flag error while fixing
nothing. The Alpha's command makes the same split for the same reason.

Testing

Asserted on the command rather than end to end, on purpose. An integration test that calls
MoveTablet passes on Docker Desktop no matter what the harness passes, because loopback is
admitted unconditionally — I wrote that test first, it passed without this fix, and a test that
cannot fail is worse than no test.

adminAuthHandler's own behaviour is already covered by the unit tests in dgraph/cmd/zero,
including the loopback and remote cases. What was untested is the harness configuring Zero, so
that is what these three tests pin. Two of them fail without this change; the third (pre-v21)
passes either way by design, guarding against over-applying the flag.

Checklist

  • The PR title follows Conventional Commits
  • Code compiles correctly and linting (via trunk) passes locally
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

Zero guards /moveTablet and /removeNode with adminAuthHandler(strict=true), so they
are protected whether or not --security is configured: with neither a token nor a
whitelist, only a loopback caller is admitted. dgraphtest passes --security to the
Alpha and never to Zero, so a test process reaching Zero through a published container
port cannot call those endpoints at all.

TestUniqueMultipleGroups is the visible casualty. It fails on

    move tablet failed with status 401: ... Request is not from a whitelisted IP

against an assertion about tablet placement, so the reported failure looks nothing
like the cause.

Two things hid it. The test only reaches MoveTablet when tablet placement happens to
put email_group_1 and email_group_2 in the same group, which is not deterministic. And
whether the guard fires at all depends on the host's Docker networking: on Linux a
published port arrives from the bridge gateway and the request is refused, while on
Docker Desktop it can arrive as loopback and be admitted. So the same commit passes CI
on one runner and fails on another, and passes on a developer's Mac either way.

The fix is the flag the Alpha has always had, with the token threaded through for the
same reason: Zero authorizes an admin request on the token OR the whitelist, so a
cluster where only the Alpha knows the token is incoherent rather than merely stricter.

Pre-v21 is deliberately excluded. Those binaries predate both the --security superflag
and the admin guard, so passing it there would fail an upgrade test with an
unknown-flag error while fixing nothing. The Alpha's command makes the same split.

Tested on the command rather than end to end, on purpose. An integration test that
calls MoveTablet passes on Docker Desktop no matter what the harness passes, because
loopback is admitted unconditionally — I wrote that test first and it passed without
this fix, which makes it worse than no test. adminAuthHandler's own behaviour is
already covered by the unit tests in dgraph/cmd/zero, including the loopback and
remote cases; what was untested is the harness configuring Zero. Two of the three new
tests fail without this change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@matthewmcneely
matthewmcneely requested a review from a team as a code owner August 27, 2026 19:47
@blacksmith-sh

blacksmith-sh Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
github.com/dgraph-io/dgraph/v25/check_upgrade/TestCheckUpgrade View Logs
github.com/dgraph-io/dgraph/v25/systest/integration2/TestDuplicateUserWithLiveLoader View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@matthewmcneely

Copy link
Copy Markdown
Contributor Author

Closing this — the premise was wrong, and I want the record to say so rather than leave a
plausible-looking fix lying around.

Zero already gets its admin whitelist, via DGRAPH_ZERO_SECURITY=whitelist=0.0.0.0/0 in
zero.env() (#9788), and deliberately by environment rather than by flag because an older zero
binary in an upgrade test would fail to start on an unrecognized one. The comment sitting eight
lines from where I made this change says exactly that. Adding --security on top duplicated the
setting and Zero began exiting 1 within half a second, which is what broke TestCheckUpgrade and
TestDuplicateUserWithLiveLoader here.

The 401 I was chasing was self-inflicted. #9813 had overwritten three dgraphtest files wholesale
from another tree instead of patching them, silently reverting zero.env(), alpha.env(), the
env method on the dnode interface, and the Env: dc.env(c) wiring. DGRAPH_ZERO_SECURITY
appears 3 times in the log of the run that passed and 0 times in the run that failed.

Fixed in #9813 by restoring those files to main and re-applying only the two lines it means to
change. Verified by auditing every deleted line on that branch, not by checking it builds.

For anyone who lands here from a search: /moveTablet and /removeNode are guarded with
strict=true, so they are protected whether or not --security is set — with neither a token nor a
whitelist, only a loopback caller is admitted. If a test cannot reach them, check that Zero actually
received DGRAPH_ZERO_SECURITY.

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.

1 participant