Skip to content

fix: do not submit a pod deleted while its volumes are resolved - #592

Open
NopeCharon wants to merge 1 commit into
interlink-hq:mainfrom
NopeCharon:fix/volume-wait-deleted-pod
Open

NopeCharon wants to merge 1 commit into
interlink-hq:mainfrom
NopeCharon:fix/volume-wait-deleted-pod

Conversation

@NopeCharon

Copy link
Copy Markdown

Summary

If a pod is deleted while the virtual kubelet is still waiting for one of its ConfigMap/Secret volumes, it still gets submitted to the plugin once the object shows up. The VK no longer tracks it, so the remote job (e.g. a Slurm allocation) keeps running and nothing deletes it. One way to hit this: a pod has a typo in a ConfigMap name and sits in Initializing. The user deletes it, creates the ConfigMap, and recreates the pod. That gives two jobs, one of them orphaned.

The volume wait in remoteExecutionHandleVolumes never checked whether the pod still existed. The check before the wait only logged Deleted Pod before actual creation and returned nil, so the deleted pod was submitted right away without its volumes. CreatePod was looking for an error string that nothing returns anymore.

This PR:

  • adds errPodDeletedBeforeCreation and matches it with errors.Is in CreatePod, in place of the string comparison. Such a pod is not submitted and is not marked failed. The warning log matches the one for kept init containers.
  • returns it from the initial lookup when the pod is NotFound. Any other error is logged, and the volumes are still resolved instead of being skipped.
  • returns it from the wait once the pod has left p.pods, the same check waitForKeptInitContainers uses. DeletePod drops a pod that is still waiting there: the remote delete is skipped for an Initializing pod, and a plugin delete for a pod it never received succeeds (the Slurm plugin just removes a missing directory).
  • turns the 2s retry delay into volumeRetryInterval so the tests can shorten it, like keptInitPollInterval and statusLoopInterval.

Tests:

  • TestRemoteExecutionHandleVolumesPodDeletedBeforeCreation: a pod that is gone from the API is reported as deleted.
  • TestRemoteExecutionHandleVolumesWaitingForConfigMap: a tracked pod is still submitted once its ConfigMap appears, and a pod removed from p.pods mid-wait stops waiting without its volume.

Without the change, the first test gets nil and the deleted-pod subtest is still waiting when its 2s timeout hits. go test -race ./pkg/... (the wait tests also with -count=30) and golangci-lint run (v2.14.0, as in CI) pass.


Related issue : #591

@netlify

netlify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for interlink-dev canceled.

Name Link
🔨 Latest commit 80c63c0
🔍 Latest deploy log https://app.netlify.com/projects/interlink-dev/deploys/6adddf88b576853642466292

remoteExecutionHandleVolumes waits up to 5 minutes for a missing
ConfigMap or Secret before the pod is submitted, with the pod in
Initializing. Deleting the pod meanwhile drops it from p.pods (DeletePod
has nothing to ask the plugin for), but the wait kept polling: once the
object showed up the deleted pod was submitted anyway, leaving a remote
job that nothing tracks or deletes, and otherwise a Failed status was
reported for it after 5 minutes.

The guard meant for this did not work either. The pod lookup before the
wait only logged "Deleted Pod before actual creation" and returned nil,
so RemoteExecution went on and submitted the deleted pod without its
volumes, while CreatePod compared the error string against a message
nothing returns anymore.

Introduce errPodDeletedBeforeCreation and use it for both cases:

- the initial lookup returns it when the pod is NotFound; other errors
  are logged and the volumes are still resolved instead of skipped;
- the wait returns it after a retry once the pod is no longer tracked in
  p.pods, the check waitForKeptInitContainers already relies on;
- CreatePod matches it with errors.Is, so such a pod is neither
  submitted nor marked failed.

The retry interval becomes volumeRetryInterval so the tests can shorten
it, as keptInitPollInterval and statusLoopInterval already are.

Fixes interlink-hq#591

Signed-off-by: NopeCharon <[email protected]>
@NopeCharon
NopeCharon force-pushed the fix/volume-wait-deleted-pod branch from 3d9311e to 80c63c0 Compare October 25, 2026 10:52

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.

1 participant