Repository navigation
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
conditions.remote was validated and never evaluated, so a plugin's remote platform or command pre-flight check was silently ignored. - pkg/plugin: one condition evaluator (CheckConditions/CheckCondition) shared by the controller and spored, with a case for every type Validate accepts and a failure for any other. Platform os matching is case/space-insensitive. Condition commands are rendered (shell-escaped) like run steps. - spored: InstallWithProvenance checks conditions.remote before the install phase; a failure marks the plugin failed with the condition's message. A new POST /v1/plugins/preflight evaluates them without installing anything. - spawn plugin install: calls preflight before running local provision steps and reports a failed condition; an older spored (405/404) gets a warning. Local conditions use the shared evaluator, rendered with resolved config.
Merged
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.
Fixes #1040
What was wrong
conditions.remote(spore-plugins AUTHORING.md: "Pre-flight checks before install") was read only byValidate. spored's runtime never evaluated it, and neither didspawn plugin install, so a remotetype: platformortype: commandcheck was silently skipped.conditions.localwas evaluated (spawn plugin install→CheckLocalConditions), but it had no tests and three smaller gaps, which this PR fixes too: condition commands were never rendered even thoughValidatescans them for{{ config.* }}references, platformosmatching was case-sensitive, and an emptyrunpassed becausesh -c ""exits 0.What changes
pkg/plugin/conditions.go:CheckConditions/CheckCondition). It has a case for every typeValidateaccepts and fails on any other type instead of skipping it. That matters because spored's launch-time declarations reachInstallwithout going through the push API'sValidate. The two sides differ only in how they run commands (ConditionHost):test -n "$GITHUB_TOKEN").runstep.Runtime.InstallWithProvenance): checksconditions.remotebefore the install phase, with a 10s budget. A failure marks the pluginfailed, and the condition'smessageleadsstate.Error. This covers bothPOST /v1/plugins/installand launch-time declarations.POST /v1/plugins/preflight: evaluatesconditions.remotesynchronously and installs nothing. It returns200 {"status":"ok"}or412 {"status":"failed","error":"<message>: <detail>"}. A condition that references{{ pushed.* }}can't be evaluated yet at this point, so it is deferred to the install-time check rather than failed.spawn plugin installcalls preflight before running local provision steps. A spore that fails a remote condition is reported before the controller mints a Tailscale key or creates a Globus endpoint for an install that can't succeed. An older spored answers 405 (the path matchesDELETE /v1/plugins/{name}) or 404. In that case spawn warns and continues, and the install-time check (on a new spored) still catches the failure throughwaitForPluginReady. The readiness wait moves earlier along with it.Agreement with #1041 (
plugin.CheckSporeOS)hostGOOS. That is the variable Refuse plugins on Windows spores, up front and with the reason (#1001) #1041 adds and its Windows refusal reads, declared byte-for-byte the same, so the two PRs merge cleanly in either order and leave one declaration.MatchesOS/NormalizeOSuse the same normalisation asCheckSporeOS: trimmed, case-insensitive, and empty meaning Linux.platform os: linuxcondition would also refuse.origin/fix/1001: it auto-merges, builds,pkg/plugin,pkg/pluginruntimeandcmdtests pass, and an ad-hoc agreement check passes. For everygoosin {windows, Windows, " windows ", linux, LINUX, darwin, ""}, CheckSporeOS refuses ⇒os: linuxfails, and a Linux spore ⇒ both pass. That gate can't live in this PR becauseCheckSporeOSisn't on main yet. Follow-up gate: plugin: gate that platform conditions agree with CheckSporeOS once #1041 and #1054 are both on main #1055.Tests
pkg/plugin/conditions_test.go: the pass/fail gate discovers the types from the validator (plugin.ConditionTypes()). It fails when discovery finds nothing, and also when a validated type has no case or a case names an unvalidated type. Also covered: unknown types fail and run nothing, message-less failures name the type, evaluation stops at the first failure, rendering is shell-escaped and an unresolved reference is a failure, an empty command fails, the platform normalisation table, and real-shlocal conditions (inherited env, platform, unknown type).pkg/pluginruntime/conditions_test.go: for each discovered type, a passing condition lets the install step run and reachrunning, and a failing one leaves the pluginfailedwith the message and no install step run. Also covered: an unknown type fails the install, the registry'sos: linuxfollows the spore OS (linux/windows/darwin), the preflight API returns 200/412 per type and records no state, and pushed references are deferred at preflight but enforced at install.cmd/plugin_preflight_test.go:postPluginPreflightmaps 200 → nil, 412 →errRemoteConditioncarrying the message, and an older spored's real mux 405 →errPreflightUnsupported.Each test was watched failing against a revert that compiles (each revert vetted before running). The reverts:
if false &&on the runtime checkMatchesOSdeferPusheddisabledCheckLocalConditions→ nilvalidConditionTypeswith no evaluator casemake check: fmt, vet and staticcheck are clean for the touched files. Hermetic tests all pass except the known Docker-daemon-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker(no daemon locally; unrelated).check-nested(9 modules) andcheck-tidypass, andGOOS=windows go vetis clean for the touched packages. Semgrep (--config=auto, files staged so they're scanned) reports 0 findings on the changed files.Caveats
type: commandcondition (the issue suggested some do). All 12 declare onlyplatform os: linux, and the command conditions in the registry are all local. So in practice the new behaviour for registry plugins is the Linux check, which matters for a Windows spore, and Refuse plugins on Windows spores, up front and with the reason (#1001) #1041 covers that.runPluginInstall(preflight and readiness wait before local provision) isn't unit-tested end to end, because the function needs SSH. The pieces it calls are tested.platformcondition with noosstill passes (the field is optional andValidateaccepts its absence).