Repository navigation
Feat/plugin down kubernetes required - #67
Conversation
ademboukabes
left a comment
There was a problem hiding this comment.
Overall solid work on extending plugin hooks to teardown and Kubernetes paths and adding required plugin support.
All automated checks pass locally (build, unit tests, race detector, lint, schema sync, sample-event validation).
Leaving a few inline comments on payload consistency, error-handling conventions, doc cleanup, and test coverage.
| p.Error = err.Error() | ||
| } | ||
| for _, u := range plan { | ||
| p.Units = append(p.Units, plugin.DeployUnit{ |
There was a problem hiding this comment.
In kubeDeployHookPayload, only Challenge is set. The fields Category, Slug, ProjectName, and ImageTag are left empty, unlike in deployHookPayload.
Please map the remaining fields from u so Kubernetes hook payloads remain consistent with Docker and SSH modes:
p.Units = append(p.Units, plugin.DeployUnit{
Challenge: u.Challenge,
Category: u.Category,
Slug: u.Slug,
ProjectName: u.Name,
ImageTag: u.Image,
})| } | ||
|
|
||
| pm.Dispatch(ctx, plugin.HookAfterBuild, buildHookPayload(cfg, opts, "after", flagBuildDryRun, plan, "success", nil)) | ||
| if err := pm.Dispatch(ctx, plugin.HookAfterBuild, buildHookPayload(cfg, opts, "after", flagBuildDryRun, plan, "success", nil)); err != nil { |
There was a problem hiding this comment.
There is an inconsistency in how after_* hook failures are handled across commands:
- In
cmd/build.go, an error returned by a required plugin duringafter_buildcauses the command to exit with an error. - In
cmd/deploy.go(lines 233, 423, 572), errors fromafter_deployandafter_downare discarded with_ =.
We should align the behavior across all commands:
- If
after_*hooks are non-blocking as stated indocs/spec/plugins.md("Failures in after_* hooks do not undo an operation that has already completed"), change this to_ = pm.Dispatch(...). - If failing
after_*hooks should report an error to CI, check and return the error incmd/deploy.goas well.
| // its own DispatchTimeout. Optional plugin failures are logged and dropped. | ||
| // Failures from required plugins are also returned so blocking hooks can veto | ||
| // the host operation. | ||
| func (m *Manager) Dispatch(ctx context.Context, hook string, payload any) error { |
There was a problem hiding this comment.
The doc comment directly above Dispatch is duplicated. The first paragraph ("It never returns an error.") is outdated and contradicts the updated comment and the new error return type. Please remove the first paragraph.
| } | ||
| if err := p.start(procCtx, opts.Dir); err != nil { | ||
| fmt.Fprintf(log, "warning: plugin %q failed to start: %v\n", c.Name, err) | ||
| if c.Required && m.loadErr == nil { |
There was a problem hiding this comment.
Two notes regarding initialization and error handling:
Loaddoc comment (lines 39-43) is now partially outdated since it claimsLoadnever aborts the host command and returns nil when no plugin is live. Withm.loadErr,Loadnow retains startup/handshake errors for required plugins. Please update the doc comment.- If
ParseConfigsfails on line 53,Loadreturnsniland the host command proceeds unblocked. If any raw plugin entry hadrequired: true, this creates a fail-open condition. If a required plugin cannot be parsed,Loadshould retain the error inm.loadErrsoDispatchcan block the operation.
| m.Close() | ||
| } | ||
|
|
||
| func TestManager_RequiredPluginCanVetoDeploy(t *testing.T) { |
There was a problem hiding this comment.
Please consider adding two test cases here:
- A test covering startup or handshake failure for a plugin with
required: true, verifying thatm.loadErrblocks subsequentDispatchcalls. - A test for
kubeDeployHookPayloadverifying that all fields inDeployUnit(Category,Slug,ProjectName,ImageTag) are correctly populated.
ademboukabes
left a comment
There was a problem hiding this comment.
Requesting changes based on the inline review comments:
- cmd/deploy.go: Populate the missing DeployUnit fields (Category, Slug, ProjectName, ImageTag) in kubeDeployHookPayload so Kubernetes payloads match Docker/SSH.
- cmd/build.go vs cmd/deploy.go: Harmonize error-handling conventions on after_* hooks across commands.
- internal/plugin/manager.go: Remove duplicated doc comment on Dispatch, update Load docstring, and avoid fail-open behavior if ParseConfigs fails when a required plugin is declared.
- internal/plugin/plugin_test.go: Add unit tests for required plugin startup/handshake failure and kubeDeployHookPayload mapping.
|
thank you for the review!! i'll make the changes right away |
|
all request changes done + added the corresponding tests, all tests pass |
What
Extend plugin hook dispatch to teardown and Kubernetes deployment paths, and add opt-in required plugins that can block operations when their hooks fail.
Closes #42
How
Verification
Notes