Repository navigation
fix(api): report public address in schema state and state dump - #75
Merged
Merged
Conversation
… dump
The platform takes an instance's metadata from two places. For an
on-demand challenge it stores the launch response, which is
GetInstanceMetadata. For a persistent one it copies each instance out of
GET /schemas/<name> when it syncs. With dynamic_public_hostname set, it
resolves {{port}} from that metadata's `ports` and {{server}} and
{{http_base}} from its `hostname`, and strips any token it cannot
resolve.
Only GetInstanceMetadata filled in `worker_public` and `hostname`.
GetSchemaState and DumpState returned the database rows as they were,
and both fields are read-time and omitempty, so the keys were simply
absent. A persistent challenge's `nc {{server}} {{port}}` therefore
rendered as `nc <port>`: the port resolved, and the server token was
silently removed. Reproduced on the e2e fleet: for the same persistent
instance, /instances/<id> said `"hostname": "worker-a"` while
/schemas/<name> and /state had no such key.
The lookup is now resolvePublicAddr. GetInstanceMetadata,
GetSchemaState and dumpChallenge call it. dumpChallenge covers GET /state
and also the hand-over response (PUT /challenges/<id>), which returned
its instances without the address for the same reason. GET
/challenges/<id> carries no instances, so it needs nothing. The API spec
now documents worker, worker_public and hostname on InstanceMetadata,
which it had never listed.
TestInstanceReadsReportThePublicAddress reads instances through
GetInstanceMetadata, GetSchemaState and DumpState. It checks all three
address keys in the JSON: `worker` is the private address,
`worker_public` and `hostname` are the worker's public name or its ip
when it has none, and neither of those two is present on the local
daemon. Before the fix the schema-state and state-dump subtests fail
and the instance read passes. It replaces TestHostnameMirrorsWorkerPublic, which assigned the
two fields itself and so never exercised cork's code. The e2e
persistent-instance step now also checks the schema state's `hostname`.
Until now it read the address only through /instances/<id>, which is
how this got through.
After deploying, re-sync the affected challenge servers on the platform.
It stores persistent instances' metadata at sync time, so instances
synced before the fix keep their metadata without `hostname` until then.
hi-liang
added a commit
that referenced
this pull request
Nov 25, 2026
Covers what landed since v1.3.0: preloading (#55), difficulty in problem.md (#62), single-certificate re-issue (#54), the module path rename (#60), worker-down across a restart (#63), the public address in the schema state (#75) and root-owned COPY (#68). Dependency bumps and CI/e2e upkeep are left out, as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A persistent challenge whose description uses
nc {{server}} {{port}}renders asnc <port>on the platform: the port resolves, the host is blank.The platform gets an instance's metadata from two places: the launch response (
GET /instances/<id>shape) for on-demand challenges, andGET /schemas/<name>for persistent ones. Withdynamic_public_hostnameon, it resolves{{server}}from that metadata'shostnameand silently strips any token it can't resolve.Only
GetInstanceMetadatafilled inworker_publicandhostname.GetSchemaStateanddumpChallengereturned database rows as-is, and both fields are read-time andomitempty, so the keys were missing.Fix
resolvePublicAddr, called fromGetInstanceMetadata,GetSchemaStateanddumpChallenge. That coversGET /instances/<id>,GET /schemas/<name>,GET /state, and the hand-over response (PUT /challenges/<id>).swagger.yamlnow documentsworker,worker_publicandhostnameonInstanceMetadata.Tests
TestInstanceReadsReportThePublicAddressreads instances through all three paths and checks the JSON keys: a worker's public name, its IP when it has none, and no address keys on the local daemon. Before the fix, the schema-state and state-dump subtests fail. It replacesTestHostnameMirrorsWorkerPublic, which set the fields itself and never called cork's code.hostname; it had only read/instances/<id>. Regular-mode e2e passes./instances/<id>hadhostnameand/schemas/<name>didn't.Deploying
dynamic_public_hostnameon. The platform stores persistent instances' metadata at sync time, so they keep the old, hostname-less copy until then. Player assignment is unaffected, because instance ids don't change.