Skip to content

chore: IP auto-detection fix#422

Closed
GabriellePoncey wants to merge 2 commits into
mainfrom
chore/PLAT-669/ip-autodetection-fix
Closed

chore: IP auto-detection fix#422
GabriellePoncey wants to merge 2 commits into
mainfrom
chore/PLAT-669/ip-autodetection-fix

Conversation

@GabriellePoncey

Copy link
Copy Markdown
Contributor

Summary

If no IPv4 address is found, fall back to the first available IPv6 address rather than returning an error.

Changes

  • Updated getFirstIP to scan all interfaces for both IPv4 and IPv6 addresses, returning IPv4 if found, otherwise IPv6, otherwise an error

Testing

  • Manual verification on an EC2 instance configured with IPv6-only networking

When a task is cancelled, ApplyEvent now detects it via an etcd watch
and cancels its own context, interrupting long-running operations rather than running to completion.

PLAT-583
If no IPv4 address is found, fall back to the first available
IPv6 address rather than returning an error.

PLAT-669
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e534e4c8-3137-43d6-953d-81462d11d51c

📥 Commits

Reviewing files that changed from the base of the PR and between fea3b6a and 297f58f.

📒 Files selected for processing (5)
  • server/internal/config/config.go
  • server/internal/task/service.go
  • server/internal/task/task_store.go
  • server/internal/task/watcher.go
  • server/internal/workflows/activities/apply_event.go

📝 Walkthrough

Walkthrough

Adds a task watcher subsystem in the task package (Watcher, sharedWatcher, watcherRegistry) backed by a new TaskStore.Watch method, wired into Service.NewWatcher and used by ApplyEvent to cancel activities on task terminal state. Separately, getFirstIP is updated to prefer IPv4 with IPv6 fallback.

Changes

Task Watcher Subsystem

Layer / File(s) Summary
Watcher core types and lifecycle
server/internal/task/watcher.go
Adds ErrTaskCanceled/ErrTaskFailed, the Watcher type (Done, Err, Close, Error), sharedWatcher fan-out, propagateErrors, release/shutdown lifecycle, and watcherRegistry.acquire to share a single watch stream per task.
Service and TaskStore wiring
server/internal/task/service.go, server/internal/task/task_store.go
Service gains a registry field and NewWatcher method; TaskStore.Watch builds the etcd key and returns a storage.WatchOp[*StoredTask].
ApplyEvent activity cancellation
server/internal/workflows/activities/apply_event.go
ApplyEvent creates a cancellable context and starts a watcher goroutine that cancels the activity when the task reaches a terminal state; watcher errors/failures are logged without cancellation.

getFirstIP IPv4/IPv6 Preference Fix

Layer / File(s) Summary
getFirstIP fallback logic
server/internal/config/config.go
Iteration logic now returns immediately on the first valid non-loopback IPv4 address, caches the first IPv6 address, and falls back to it if no IPv4 is found before returning the existing error.

Compact metadata: 5 files changed · +291/-11 · Go

Related issues: None found

Related PRs: None found

Suggested labels: enhancement, backend

Suggested reviewers: None found

Poem

A rabbit watched a task turn done,
Through shared streams, watchers run as one. 🐇
IPv4 first, IPv6 in tow,
No more lost hops, just steady flow.
Hooray, the burrow's code compiles clean!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/PLAT-669/ip-autodetection-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 1 medium

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 35 complexity · 0 duplication

Metric Results
Complexity 35
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@GabriellePoncey GabriellePoncey deleted the chore/PLAT-669/ip-autodetection-fix branch July 2, 2026 18:25
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