Skip to content

Avoid panics when cleaning up a deleted EKS cluster - #8873

Open
nbaliyan260 wants to merge 1 commit into
eksctl-io:mainfrom
nbaliyan260:fix/deleted-cluster-cleanup
Open

nbaliyan260 wants to merge 1 commit into
eksctl-io:mainfrom
nbaliyan260:fix/deleted-cluster-cleanup

Conversation

@nbaliyan260

@nbaliyan260 nbaliyan260 commented Sep 19, 2026

Copy link
Copy Markdown

Description

Fixes #7450.

When an EKS control plane has already been deleted but its CloudFormation stack remains, cluster status has no ClusterInfo. Cleanup currently panics while constructing the cluster action or passing cluster state to the stack deletion tasks. Auto Mode role cleanup also assumes that cluster state is available.

Guard those three accesses so cleanup can continue through the existing inoperable-cluster path. Preserve the missing cluster state, allowing Kubernetes operations to remain skipped, and retain the normal error when neither the EKS cluster nor its stack exists.

Regression tests cover both missing-cluster constructor outcomes, continued execution of stack cleanup without Kubernetes access, and absent cluster state in Auto Mode role cleanup. The constructor tests also cover existing owned and unowned clusters.

Validation

  • Reproduced four nil-pointer panics with the new missing-cluster regression tests against the original production files from f131ac5 (using a Go overlay).
  • CGO_ENABLED=0 go test ./pkg/actions/cluster ./pkg/automode passes with the fix.
  • make unit-test-no-generate passes: 87 test packages, using Go 1.27.1. OIDC certificate fixtures were generated first with make -C pkg/iam/oidc/testdata all to avoid its existing three-second setup timeout under local host load.
  • CGO_ENABLED=0 go build ./cmd/eksctl and the resulting binary's version command pass.
  • CGO_ENABLED=0 go test -tags integration -run='^$' ./integration/... passes (compile-only).
  • GOTOOLCHAIN=go1.26.5 golangci-lint run --concurrency=2 --timeout=30m passes with the repository's pinned linter: zero issues.

No live AWS integration tests were run.

Checklist

  • Added tests that cover your change
  • Reviewed documentation requirements; no configuration or CLI interface changes
  • Manually tested against AWS (not run)
  • Made sure the title of the PR is a good description that can go into the release notes
  • (Core team) Added labels for change area and kind

BONUS POINTS checklist

  • Backfilled missing tests for code in the same general area

ClusterInfo is unavailable once an EKS control plane has been removed.
Guard cluster-state access in the action constructor and stack cleanup,
and skip Auto Mode role cleanup when that state is unavailable.

Add regression coverage for missing clusters and preserve existing
owned/unowned cluster selection.

Fixes eksctl-io#7450
Copilot AI lite review requested due to automatic review settings September 19, 2026 02:45
@github-actions

Copy link
Copy Markdown
Contributor

Hello nbaliyan260 👋 Thank you for opening a Pull Request in eksctl project. The team will review the Pull Request and aim to respond within 1-10 business days. Meanwhile, please read about the Contribution and Code of Conduct guidelines here. You can find out more information about eksctl on our website

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The nil-state paths are guarded and covered by focused regression tests without introducing unresolved issues.

Review effort: Lite
Findings: None

What changed in this PR

Fixes nil-pointer panics during cleanup when the EKS control plane is deleted but CloudFormation resources remain.

Changes:

  • Safely handle missing cluster state in constructors and cleanup.
  • Skip Auto Mode role cleanup when cluster state is unavailable.
  • Add regression coverage for deleted, owned, unowned, and existing clusters.
File Description
pkg/​automode/​role_deleter.go Guards absent cluster state.
pkg/​automode/​role_deleter_test.go Tests missing cluster behavior.
pkg/​actions/​cluster/​owned.go Passes nil cluster state safely to cleanup tasks.
pkg/​actions/​cluster/​owned_test.go Verifies cleanup continues without Kubernetes access.
pkg/​actions/​cluster/​cluster.go Safely initializes Auto Mode cleanup.
pkg/​actions/​cluster/​cluster_test.go Covers constructor outcomes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
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.

[Bug] SIGSEGV when trying to clean up a deleted eks cluster

2 participants