hashicorp / hashicorp/nomad

Purging a parameterized job does not purge or unlink children jobs

Open
#6,970 3 comments 7 reactions 0 assignees View on GitHub
theme/batch type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version

0.10.2

### Operating system and Environment details

MacOS, dev agent

### Issue

When purging a parameterized job, all children jobs of the parameterized job will still maintain parent references to the now purged job. This creates broken references which complicates any time of job traversal.

### Reproduction steps

1. Run any ol' parameterized job.
2. Dispatch some instances (children) of the parameterized job
3. Purge the parameterized job (`nomad stop -purge my-parameterized-job`)
4. Observe that the child job is still there in the CLI and API responses.

```
ID Type Priority Status
geocoder batch/parameterized 50 running
geocoder/dispatch-1579658083-5adaf751 batch 50 dead
```

becomes
```
ID Type Priority Status
geocoder/dispatch-1579658083-5adaf751 batch 50 dead
```

with an API response including

```
"ID": "geocoder/dispatch-1579658083-5adaf751",
"ParentID": "geocoder",
"Name": "geocoder/dispatch-1579658083-5adaf751",
```

### What was expected

One of two things should have happened.

**1. The child job should have also been purged**

Since the job was already in a terminal state, this would have been the same effect as a GC and it would have kept the job graph tidy.

This gets more complicated when there are running instances of the parameterized job, but hey, purge means purge, right?

**2. The child job should have been unreferenced from the parent**

As part of the purge, the children of a job can be walked and unlinked from the parent. This is just a change in metadata. Child jobs are still just jobs as far as the scheduler is concerned, but in this way, the job graph isn't left in a broken state.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with a parameterized job, dispatched child jobs, and `nomad stop -purge`; inspect the CLI listing and API response shown in the report. Trace the purge handling and child-job relationship traversal, then confirm that purging leaves no broken parent reference, either by removing terminal children or unlinking them as the chosen behavior requires.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.