Skip to content

fix(droplet): detect monitoring/ipv6 drift via droplet.Features#67

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-droplet-diff-issue
Open

fix(droplet): detect monitoring/ipv6 drift via droplet.Features#67
Copilot wants to merge 3 commits intomainfrom
copilot/fix-droplet-diff-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

DropletDriver.Diff silently ignored changes to monitoring and ipv6 because the code assumed godo's Droplet.Get response had no read-side signal for them. The DO API does expose these via droplet.Features []string (e.g. ["monitoring", "ipv6"]) — no side-channel state file required.

Changes

  • dropletHasFeature(droplet, feature) — linear scan of droplet.Features to check if a feature string is present
  • dropletOutput() — adds "monitoring" and "ipv6" boolean keys to Outputs, derived from droplet.Features
  • Diff() — detects drift on monitoring and ipv6 with the same key-present guard used by vpc_uuid, enable_backups, and tags (absent key = no churn for legacy YAML)
  • Doc comments — narrows "NOT detected" section to only user_data and ssh_keys; moves monitoring/ipv6 into the detected list

user_data and ssh_keys remain undetectable — write-only and not returned by Droplet.Get respectively.

Example

// droplet.Features returned by DO API when both features are on:
// ["monitoring", "ipv6"]

// dropletOutput now sets:
outputs["monitoring"] = dropletHasFeature(droplet, "monitoring") // true
outputs["ipv6"]       = dropletHasFeature(droplet, "ipv6")       // true

// Diff then compares desired vs current, flagging ForceNew on mismatch:
if desiredMonitoring != curMonitoring {
    changes = append(changes, interfaces.FieldChange{
        Path: "monitoring", Old: curMonitoring, New: desiredMonitoring, ForceNew: true,
    })
}

Copilot AI requested review from Copilot and removed request for Copilot May 5, 2026 07:52
Copilot AI requested review from Copilot and removed request for Copilot May 5, 2026 08:12
Copilot AI changed the title [WIP] Fix Droplet Diff to detect missing user_data and ssh_keys fix(droplet): detect monitoring/ipv6 drift via droplet.Features May 5, 2026
Copilot AI requested a review from intel352 May 5, 2026 08:13
@intel352 intel352 marked this pull request as ready for review May 5, 2026 08:23
Copilot AI review requested due to automatic review settings May 5, 2026 08:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Droplet resource driver to detect drift for monitoring and ipv6 by reading the live droplet’s enabled features (droplet.Features) and comparing them against the desired spec when those keys are explicitly present in config.

Changes:

  • Add dropletHasFeature helper to check whether a feature string (e.g. "monitoring", "ipv6") is present in godo.Droplet.Features.
  • Extend dropletOutput to emit boolean Outputs["monitoring"] / Outputs["ipv6"] derived from droplet.Features.
  • Extend DropletDriver.Diff to detect monitoring / ipv6 drift (ForceNew) when those keys are present in desired config, and update doc comments accordingly.
  • Add unit tests covering read-side feature extraction and diff behavior (toggle vs absent-key).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/drivers/droplet.go Adds feature-based read outputs for monitoring/ipv6 and drift detection logic in Diff, plus updated doc comments.
internal/drivers/droplet_test.go Adds tests ensuring Read derives booleans from Features and Diff forces replace on mismatches while skipping absent keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/drivers/droplet.go Outdated
Comment thread internal/drivers/droplet.go Outdated
@intel352
Copy link
Copy Markdown
Contributor

intel352 commented May 5, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 5, 2026

@copilot apply changes based on the comments in this thread

Applied in edbcc99. Both monitoring and ipv6 Diff comparisons now guard on current.Outputs key presence before comparing. If the key is absent (state written by a version predating this PR), the comparison is skipped entirely — no spurious ForceNew. Two regression tests added: TestDropletDriver_Diff_MonitoringLegacyStateNoSpuriousReplace and TestDropletDriver_Diff_IPv6LegacyStateNoSpuriousReplace.

@intel352
Copy link
Copy Markdown
Contributor

intel352 commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 6, 2026

@copilot failing https://github.com/GoCodeAlone/workflow-plugin-digitalocean/actions/runs/25380804265/job/74428286170?pr=67

The failing job is codemod-report (not the CI/test suite). It fails at the "Comment summary on PR" step with a 403 Resource not accessible by integration error — this is a GitHub Actions token permissions issue when trying to post a codemod report comment. It's unrelated to our code changes. The actual CI workflow (build + tests) passed successfully on edbcc998.

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.

Droplet Diff misses user_data / ssh_keys / monitoring / ipv6 (godo Read limitation)

3 participants