Skip to content

feat: add snapshot post server hook#3933

Draft
mfranczy wants to merge 1 commit into
loft-sh:mainfrom
mfranczy:snapshots-handler
Draft

feat: add snapshot post server hook#3933
mfranczy wants to merge 1 commit into
loft-sh:mainfrom
mfranczy:snapshots-handler

Conversation

@mfranczy
Copy link
Copy Markdown
Contributor

@mfranczy mfranczy commented May 14, 2026

What issue type does this pull request address? (keep at least one, remove the others)
/kind feature

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)
resolves #

Please provide a short message that should be published in the vcluster release notes
Fixed an issue where vcluster ...

What else do we need to know?
Implemented a vCluster snapshot HTTP hook that exposes snapshot operations without requiring command exec.
The API now uses a single /vcluster/snapshots* prefix:

  • HEAD /vcluster/snaphots - probe
  • POST /vcluster/snapshots - snapshot create
  • POST /vcluster/snapshots/list - snapshot list
  • POST /vcluster/snapshots/request - snapshot request create (async snapshot creation)
  • POST /vcluster/snapshots/request/delete - snapshot delete (async snapshot deletion)
  • GET /vcluster/snapshots/request/{name} - snapshot request get

Direct snapshot routes operate on storage immediately, while request routes create/read k8s request resources that are reconciled asynchronously by the snapshot controller.

E2E Tests

Default Test Execution

The mandatory PR suite runs automatically. Only specify additional test suites below if needed.

Adding New Test Suites

When adding a new ginkgo test suite:

  • Add labels to the test suite
  • Update label-filter section below to execute the new test suite
  • Verify test suite runs in CI/CD pipeline

Additional test suites

Additional test suite(s) that will be executed before the mandatory PR suite:

none

@mfranczy mfranczy requested review from a team as code owners May 14, 2026 10:04
@mfranczy mfranczy force-pushed the snapshots-handler branch from bd472f1 to acfab5c Compare May 14, 2026 10:08
Signed-off-by: Marcin Franczyk <marcin0franczyk@gmail.com>
@mfranczy mfranczy force-pushed the snapshots-handler branch from acfab5c to 3523740 Compare May 14, 2026 10:10
@mfranczy mfranczy marked this pull request as draft May 14, 2026 10:18
@mfranczy
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3523740390

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return
}
if err := client.Run(r.Context(), ctx.Config); err != nil {
fail(w, r, http.StatusInternalServerError, err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return 4xx for invalid snapshot options

This path converts client-side validation failures into 500 responses: client.Run/client.List validate user-provided snapshot options (for example, unsupported type or missing storage fields), but errors from that validation are currently returned as internal server errors. That makes malformed requests look like transient server faults and can trigger incorrect retry behavior in API clients. These validation errors should be mapped to a 4xx status (typically 400).

Useful? React with 👍 / 👎.

fail(w, r, http.StatusBadRequest, err)
return
}
if err := client.Run(r.Context(), ctx.Config); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid mutating shared config in request handler

Passing ctx.Config directly into client.Run introduces a concurrency hazard for the new HTTP endpoint: snapshot.Client.Run mutates the provided config in standalone mode (HostNamespace and standalone constants), and HTTP handlers are executed concurrently. Multiple snapshot POST requests can therefore race on shared process state and cause nondeterministic behavior. The handler should pass an isolated copy (or Run should stop mutating input config).

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant