Skip to content

feat(snapshot): add snapshot tasks and volume CreateSnapshot - #17

Merged
jymaire merged 1 commit into
kestra-io:mainfrom
PedroHenrique0713:feat/snapshots
Oct 9, 2026
Merged

jymaire merged 1 commit into
kestra-io:mainfrom
PedroHenrique0713:feat/snapshots

Conversation

@PedroHenrique0713

@PedroHenrique0713 PedroHenrique0713 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What changes are being made and why?

Closes #19 (part of #10). This is the Snapshots slice we agreed on in the issue.

The plugin could already take a droplet snapshot through the droplet SNAPSHOT action, but there was no way to snapshot a volume, list snapshots, look one up or clean them up. This adds:

  • volume.CreateSnapshot, which snapshots a block storage volume (name and optional tags)
  • snapshot.List, with an optional resourceType filter (DROPLET or VOLUME)
  • snapshot.Get and snapshot.Delete

Get and CreateSnapshot share a SnapshotOutput. I kept the snapshot ID as a string because DigitalOcean returns an integer for droplet snapshots and a UUID for volume snapshots, so a numeric type would break on volumes.

Everything follows the patterns already in the repo (AbstractDigitalOceanTask, AbstractDigitalOceanListTask, WireMock tests) and the endpoints in DigitalOcean's OpenAPI spec. I also added the metadata, icon and docs entries for the new subgroup.


How the changes have been QAed?

  • 15 new WireMock tests: the resource_type query param, numeric vs UUID IDs, tags left out when empty, 404 and 429, plus one per task rendering its properties from Pebble expressions. The full suite passes (127/127).
  • Built the jar and ran it on Kestra 2.0.4 against a small local mock of the DigitalOcean API, with this flow (baseUrl points to the mock; drop it to hit the real API):
id: digitalocean_volume_snapshot
namespace: company.team

tasks:
  - id: snapshot_volume
    type: io.kestra.plugin.digitalocean.volume.CreateSnapshot
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    baseUrl: http://host.docker.internal:18996
    volumeId: 82a48a18-873f-11e6-96bf-000f53315a41
    name: "data-volume-{{ now() | date('yyyyMMddHHmm') }}"
    tags:
      - backup

  - id: list_volume_snapshots
    type: io.kestra.plugin.digitalocean.snapshot.List
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    baseUrl: http://host.docker.internal:18996
    resourceType: VOLUME

  - id: get_snapshot
    type: io.kestra.plugin.digitalocean.snapshot.Get
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    baseUrl: http://host.docker.internal:18996
    snapshotId: "{{ outputs.snapshot_volume.id }}"

  - id: delete_snapshot
    type: io.kestra.plugin.digitalocean.snapshot.Delete
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    baseUrl: http://host.docker.internal:18996
    snapshotId: "{{ outputs.snapshot_volume.id }}"

  - id: log_result
    type: io.kestra.plugin.core.log.Log
    message: >
      Created {{ outputs.get_snapshot.name }} ({{ outputs.get_snapshot.id }}) from volume
      {{ outputs.get_snapshot.resourceId }}, tags {{ outputs.get_snapshot.tags }};
      {{ outputs.list_volume_snapshots.total }} volume snapshot(s) listed before deleting it.

Before / after

Plugin list: the new Snapshots group shows up, and Volume goes from 6 to 7 tasks.

Before: plugin list After: plugin list

Editor: the released plugin rejects volume.CreateSnapshot, this branch validates it.

Before: the editor rejects volume.CreateSnapshot After: the flow validates

The demo flow running end to end.

After: demo flow execution

Setup Instructions

A DigitalOcean API token in a DIGITALOCEAN_TOKEN secret, with read and write access to volumes and snapshots.


Contributor Checklist ✅

@PedroHenrique0713 PedroHenrique0713 changed the title feat(snapshot): add snapshot List, Get, Delete and volume CreateSnapshot feat(snapshot): add snapshot tasks and volume CreateSnapshot Oct 6, 2026

@jymaire jymaire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Kestra Plugin Code Review

Business Requirements — partial (by design)

Issue #10 is a broad umbrella request (Spaces, Volumes, Snapshots, Security, Monitoring, Billing...). This PR delivers the Snapshots slice agreed in the issue: volume.CreateSnapshot, snapshot.List / Get / Delete. The slice is complete and in scope; the other areas of #10 remain for follow-up PRs, so the issue should not be auto-closed by this PR.

Kestra Guidelines — 0 findings

✅ No violations. Checked against the existing tasks: new tasks extend AbstractDigitalOceanTask / AbstractDigitalOceanListTask (token already @PluginProperty(secret = true) + @ToString.Exclude, HTTP through the shared Kestra HttpClient helper with actionable non-2xx messages, list pagination and fetchType inherited), all properties are Property<T> with groups and @Schema, Delete returns null for VoidOutput, examples are full flows with secret(), and the subgroup has package-info, icon, snapshot.yaml, volume.yaml / index.yaml updates, package doc and AGENTS.md. kestraVersion=1.3.39: no core API changed in 2.0 is used (no Ion file reads, no ForEach in examples); the PR reports a run on Kestra 2.0.4. volumes/{id}/snapshots is synchronous (returns the snapshot), so no async-action wait or kill() is needed.

Security (OWASP Top 10:2025 + KPS) — 0 findings

✅ No issues found. IDs go through encodePathSegment (no path injection / SSRF beyond the user-chosen baseUrl, same as the rest of the plugin); no secrets in outputs or logs; no new dependencies.

Performance — 0 findings

✅ No issues found. List uses the paginated, capped fetch helper; no unbounded reads.

Notes

  • CI (check / main) is still pending on this head, so readiness cannot be confirmed yet.
  • 15 new unconditional WireMock tests cover the happy path, numeric vs UUID ids, empty tags, 404/429 and Pebble rendering for all four tasks.

Verdict: APPROVE (recommendation only, pending green CI)

@jymaire

jymaire commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

QA report — head 290883d

Edition: OSS | Docker tags: v1.3.42 (latest 1.3.x, kestraVersion=1.3.39) and v2.0.5 (latest 2.0.x), same shadow JAR, one instance at a time
Instance: http://localhost:28117 (Kestra v2.0.5, left running for manual review: docker rm -f qa-digitalocean17-kestra-v205 && docker network rm qa-digitalocean17-net to stop)
Screenshots: https://claude.ai/artifact/6gZUXSnpHbGwsr5GbrSEDp

Setup: the DigitalOcean API was mocked by a small local HTTP server (/v2/snapshots, /v2/snapshots/{id}, /v2/volumes/{id}/snapshots, with page-based links.pages.next pagination, 401 / 404 / 429 + Retry-After / slow-response modes). Every task pointed baseUrl at the mock. No real DigitalOcean account was used, so real-cloud behaviour is not testable here. Fake tokens came from Kestra secrets.

Summary

Flow v1.3.42 v2.0.5
Example snapshot.List ✅ SUCCESS ✅ SUCCESS
Example snapshot.Get ✅ SUCCESS ✅ SUCCESS
Example snapshot.Delete ✅ SUCCESS ✅ SUCCESS
Example volume.CreateSnapshot ✅ SUCCESS ✅ SUCCESS
do_snapshot_variants (pagination, fetchTypes, chaining) ✅ SUCCESS ✅ SUCCESS
do_snapshot_errors (404 / 401 / 429 / timeout / bad input, allowFailure) ✅ WARNING (each task failed as expected) ✅ WARNING (each task failed as expected)
Validation (/flows/validate) of all examples + invalid flow ✅ ✅
options.timeout on a task ⚠️ 401, pre-existing, see below ✅ Read timed out

The 4 @Example flows validate unchanged on both versions. On 2.0 they were run with baseUrl set inline, because 2.0 no longer accepts flow-level pluginDefaults. The 1.3 run used pluginDefaults with the same value. The plugin UI is fine on both versions: the new Snapshots (3) subgroup shows its icon, and volume.CreateSnapshot appears under Volumes. Docs pages render properties and examples, and the editor reports the examples as valid.

Flow 1: digitalocean_list_snapshots (example, ✅ SUCCESS on both)

Flow YAML
id: digitalocean_list_snapshots
namespace: company.team

tasks:
  - id: list_snapshots
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    resourceType: VOLUME
  - id: log_total
    type: io.kestra.plugin.core.log.Log
    message: "Found {{ outputs.list_snapshots.total }} volume snapshot(s)"

Gantt (1.3, 2.0)

Task v1.3.42 v2.0.5
list_snapshots SUCCESS 0.82s SUCCESS 0.04s
log_total SUCCESS 0.04s SUCCESS 0.03s

Logs synthesis: GET /v2/snapshots?resource_type=volume&per_page=200, logs Found 4 snapshot(s). The Log task prints Found 4 volume snapshot(s).
Outputs synthesis: rows holds 4 raw snapshot maps, size: 4, total: 4.

Flow 2: digitalocean_get_snapshot (example, ✅ SUCCESS on both)

Flow YAML
id: digitalocean_get_snapshot
namespace: company.team

tasks:
  - id: get_snapshot
    type: io.kestra.plugin.digitalocean.snapshot.Get
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    snapshotId: "fbe805e8-866b-11e6-96bf-000f53315a41"
  - id: log_size
    type: io.kestra.plugin.core.log.Log
    message: "Snapshot {{ outputs.get_snapshot.name }} takes {{ outputs.get_snapshot.sizeGigabytes }} GB"

Gantt (1.3): get_snapshot SUCCESS 0.04s / 0.13s, log_size SUCCESS.
Logs synthesis: Fetching DigitalOcean snapshot fbe805e8-…, then Snapshot data-volume-snap takes 0.0 GB.
Outputs synthesis (1.3, 2.0): id, name: data-volume-snap, resourceType: volume, resourceId, regions: [nyc1], minDiskSize: 100, sizeGigabytes: 0.0, tags: [backup], createdAt: 2026-09-02T11:30:00Z. The fields are correctly mapped from the snake_case API body.

Flow 3: digitalocean_delete_snapshot (example, ✅ SUCCESS on both)

Flow YAML
id: digitalocean_delete_snapshot
namespace: company.team

tasks:
  - id: delete_snapshot
    type: io.kestra.plugin.digitalocean.snapshot.Delete
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    snapshotId: "fbe805e8-866b-11e6-96bf-000f53315a41"

Gantt (1.3, 2.0): delete_snapshot SUCCESS 0.06s / 0.04s.
Logs synthesis: DELETE /v2/snapshots/fbe805e8-… returned 204. Outputs: none (VoidOutput).

Flow 4: digitalocean_snapshot_volume (example, ✅ SUCCESS on both)

Flow YAML
id: digitalocean_snapshot_volume
namespace: company.team

tasks:
  - id: snapshot_volume
    type: io.kestra.plugin.digitalocean.volume.CreateSnapshot
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    volumeId: "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    name: "data-volume-{{ now() | date('yyyyMMddHHmm') }}"
    tags:
      - backup
  - id: log_snapshot
    type: io.kestra.plugin.core.log.Log
    message: "Created snapshot {{ outputs.snapshot_volume.id }}"

Gantt (1.3): snapshot_volume SUCCESS 0.08s / 0.04s, log_snapshot SUCCESS.
Logs synthesis: Creating snapshot 'data-volume-202610090924' of DigitalOcean volume 3fa85f64-…. POST /v2/volumes/3fa85f64-…/snapshots returned 201, and the request body was {"name":…,"tags":["backup"]}.
Outputs synthesis (1.3, 2.0): id: 8fa70202-…, rendered name, resourceType: volume, tags: [backup], createdAt.

Flow 5: do_snapshot_variants (✅ SUCCESS on both)

Flow YAML
id: do_snapshot_variants
namespace: qa.digitalocean17

tasks:
  - id: list_all_paginated
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    perPage: 2
  - id: list_droplet_fetch_one
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    resourceType: DROPLET
    fetchType: FETCH_ONE
  - id: list_store
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    fetchType: STORE
  - id: read_stored
    type: io.kestra.plugin.core.log.Log
    message: "{{ read(outputs.list_store.uri) }}"
  - id: list_none
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    fetchType: NONE
  - id: get_droplet_snapshot
    type: io.kestra.plugin.digitalocean.snapshot.Get
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    snapshotId: "{{ outputs.list_droplet_fetch_one.row.id }}"
  - id: create_snapshot_no_tags
    type: io.kestra.plugin.digitalocean.volume.CreateSnapshot
    baseUrl: http://qa-digitalocean17-mock:8080
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    volumeId: "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    name: "nightly-{{ execution.id }}"
  - id: delete_droplet_snapshot
    type: io.kestra.plugin.digitalocean.snapshot.Delete
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    snapshotId: "{{ outputs.get_droplet_snapshot.id }}"
    baseUrl: http://qa-digitalocean17-mock:8080///

Gantt (1.3, 2.0): all 8 tasks SUCCESS, each under 0.11s.

Logs / outputs synthesis

  • list_all_paginated (perPage: 2): followed links.pages.next over 3 pages and returned size: 5, total: 5.
  • list_droplet_fetch_one: ?resource_type=droplet, row is the droplet snapshot 6372321, size: 1.
  • list_store: uri: kestra:///…/list-store/….ion, total: 5. read() of the stored file prints readable Ion text on both 1.3 and 2.0, so the 2.0 binary-Ion trap does not apply.
  • list_none: size: 0, total: 5.
  • get_droplet_snapshot: a numeric id chained from the list works. sizeGigabytes: 2.34, regions: [nyc3, ams3].
  • create_snapshot_no_tags: the payload has no tags key, and the output omits tags.
  • delete_droplet_snapshot: a baseUrl with trailing /// is normalised to a single slash.

Flow 6: do_snapshot_errors (✅ every task failed as expected on both, execution WARNING)

Flow YAML
id: do_snapshot_errors
namespace: qa.digitalocean17

tasks:
  - id: get_404
    type: io.kestra.plugin.digitalocean.snapshot.Get
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    snapshotId: "does-not-exist"
  - id: delete_404
    type: io.kestra.plugin.digitalocean.snapshot.Delete
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    snapshotId: "does-not-exist"
  - id: create_snapshot_404_volume
    type: io.kestra.plugin.digitalocean.volume.CreateSnapshot
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    volumeId: "00000000-0000-0000-0000-000000000000"
    name: "orphan"
  - id: list_401
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DO_BAD_TOKEN') }}"
  - id: create_snapshot_401
    type: io.kestra.plugin.digitalocean.volume.CreateSnapshot
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DO_BAD_TOKEN') }}"
    volumeId: "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    name: "x"
  - id: get_429
    type: io.kestra.plugin.digitalocean.snapshot.Get
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DO_RATE_TOKEN') }}"
    snapshotId: "6372321"
  - id: delete_429
    type: io.kestra.plugin.digitalocean.snapshot.Delete
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DO_RATE_TOKEN') }}"
    snapshotId: "6372321"
  - id: get_read_timeout
    type: io.kestra.plugin.digitalocean.snapshot.Get
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DO_SLOW_TOKEN') }}"
    snapshotId: "6372321"
    options:
      timeout:
        readIdleTimeout: PT2S
  - id: list_task_timeout
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    timeout: PT3S
    apiToken: "{{ secret('DO_SLOW_TOKEN') }}"
  - id: list_bad_enum
    type: io.kestra.plugin.digitalocean.snapshot.List
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    resourceType: "{{ 'IMAGE' }}"
  - id: get_empty_id
    type: io.kestra.plugin.digitalocean.snapshot.Get
    baseUrl: http://qa-digitalocean17-mock:8080
    allowFailure: true
    apiToken: "{{ secret('DIGITALOCEAN_TOKEN') }}"
    snapshotId: "{{ null }}"

Gantt (1.3, 2.0) / Logs (1.3, 2.0)

Task Result (both versions unless noted)
get_404, delete_404, create_snapshot_404_volume FAILED: DigitalOcean API returned HTTP 404: resource not found. Verify baseUrl … and the id used in the request are correct. The resource you were accessing could not be found.
list_401, create_snapshot_401 FAILED: HTTP 401: invalid or missing API token … : Unable to authenticate you.
get_429, delete_429 FAILED: DigitalOcean API rate limit hit (HTTP 429). Retry after N second(s). API Rate limit exceeded. The core HTTP client retries once after Retry-After before failing, so 1.3 with Retry-After: 42 took 42s per task and 2.0 with Retry-After: 2 took 2s.
get_read_timeout (options.timeout.readIdleTimeout: PT2S) 2.0: FAILED java.net.SocketTimeoutException: Read timed out after 2s ✅. 1.3: FAILED with HTTP 401 (pre-existing, see below).
list_task_timeout (task timeout: PT3S, 20s response) FAILED Timeout after 00:00:03.000, but only after the 20s blocking HTTP call returned. This is core task-timeout behaviour.
list_bad_enum (resourceType: "{{ 'IMAGE' }}") FAILED with a raw Jackson message Unrecognized token 'IMAGE'. /flows/validate does not flag an invalid static value either (resourceType: IMAGE), as usual for Property<Enum>. A valid dynamic value ("{{ 'VOLUME' }}") works.
get_empty_id (snapshotId renders to empty) FAILED: sends GET /v2/snapshots/, which the mock answered 404.

Validation (POST /flows/validate) rejects missing snapshotId (Get/Delete), missing name/volumeId (CreateSnapshot) and missing apiToken with must not be null, and warns when apiToken is plain text.

Pre-existing issue, not introduced by this PR: options breaks authentication on Kestra 1.3.x

On v1.3.42, any DigitalOcean task that sets options (timeouts, proxy…) is sent with Authorization: Basic bnVsbDpudWxs, which is null:null, instead of the bearer token, so the API answers 401 (screenshot). The existing volume.Get with options.timeout fails the same way, so this is not specific to the new tasks. It works on v2.0.5 (screenshot).

  • Cause: AbstractDigitalOceanTask calls options.toBuilder(). In Kestra 1.3 core, HttpConfiguration.toBuilder() re-applies the deprecated basicAuthUser/basicAuthPassword builder methods with null, which creates a BasicAuthConfiguration(null, null). 2.0 removed those deprecated properties.
  • Repro (1.3.x): any task with options: {timeout: {readIdleTimeout: PT5S}} gets a 401 from a server that checks the bearer token.
  • This file is not part of the PR diff. I'd suggest a separate fix: pass options as-is when it is non-null, or clear auth after toBuilder(). That decision is left to the maintainers.

Low notes (no action needed for this PR)

  • fetchType: STORE reports size: 0 while total: 5. This comes from the shared PageOutput helper and is pre-existing.
  • An empty rendered snapshotId/volumeId is not rejected before the call (shared requireRendered pattern).

Timeout notes

No scenario was skipped. The 1.3 get_429 and delete_429 exceeded 30s only because the mock's Retry-After: 42 was honoured. With Retry-After: 2 on 2.0, they finished in 2s.

No HIGH/MEDIUM finding introduced by this PR. QA result: PASS, with the pre-existing 1.3 options caveat above.

@jymaire jymaire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All good for me, thanks for the contribution!

@jymaire

jymaire commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

The pre-existing options / HTTP 401 issue on Kestra 1.3.x from the QA report above is now tracked in #21, outside this PR.

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

Labels

area/plugin Plugin-related issue or feature request kind/external Pull requests raised by community contributors

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

DigitalOcean: add Snapshots tasks (part of #10)

3 participants