Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[teraslice] - Add ability to soft delete a job #3711

Merged
merged 41 commits into from
Sep 6, 2024
Merged

[teraslice] - Add ability to soft delete a job #3711

merged 41 commits into from
Sep 6, 2024

Conversation

busma13
Copy link
Contributor

@busma13 busma13 commented Aug 6, 2024

This PR makes the following changes:

  • Add v1routes.delete('/jobs/:jobId') endpoint
  • Update jobsService to throw when trying to start, update, or recover a deleted job
  • Update get /jobs, /txt/jobs, /ex, and /txt/ex endpoints to filter by deleted
  • Add teraslice-cli jobs delete and teraslice-cli tjm delete commands and necessary helper functions.
  • Updates teraslice-cli jobs list to add deleted and active flags
  • Updates teraslice-cli jobs ex to add deleted flag
  • Update teraslice-cli helpers.ts and teraslice-client-js Jobs.list() to remove status` query. Status inside a job was removed in job refactor #303. Fix Jobs.list in teraslice-client-js and remove jobs method #880 may also be relevant.
  • Update documentation
  • Add or update tests

ref: #3680

@busma13 busma13 marked this pull request as ready for review August 8, 2024 20:48
@busma13
Copy link
Contributor Author

busma13 commented Aug 8, 2024

➜  jobs-local git:(main) ✗ curl -XDELETE localhost:5678/jobs/65c01465-80be-4932-9c12-3a640e082c4b
{
    "name": "peter-datagen-to-kafka",
    "lifecycle": "persistent",
    "workers": 1,
    "assets": [
        "standard",
        "kafka"
    ],
    "operations": [
        {
            "_op": "data_generator",
            "size": 5000
        },
        {
            "_op": "kafka_sender",
            "topic": "rand-p-json-v1",
            "size": 5000
        }
    ],
    "job_id": "65c01465-80be-4932-9c12-3a640e082c4b",
    "_context": "job",
    "_created": "2024-08-08T22:22:26.519Z",
    "_updated": "2024-08-08T22:31:24.752Z",
    "_deleted": true,
    "_deleted_on": "2024-08-08T22:31:24.750Z",
    "active": false
}

@busma13
Copy link
Contributor Author

busma13 commented Aug 8, 2024

➜  teraslice git:(job-deletion) earl tjm delete peter-datagen-to-kafka.json
✔ Delete job 23b72801-857f-4457-b947-9ca8c59c5794 on http://localhost:5678 … yes
> peter-datagen-to-kafka has been deleted
--------
job: peter-datagen-to-es
id: 7636e71b-eda8-4a8d-8069-bc5201985271
cluster: http://localhost:5678
--------

➜  teraslice git:(job-deletion) earl jobs delete local 7636e71b-eda8-4a8d-8069-bc5201985271
✔ Delete job 7636e71b-eda8-4a8d-8069-bc5201985271 on local … yes
> peter-datagen-to-es has been deleted
--------
job: peter-datagen-to-kafka
id: 23b72801-857f-4457-b947-9ca8c59c5794
cluster: http://localhost:5678
--------

@busma13
Copy link
Contributor Author

busma13 commented Aug 8, 2024

➜  teraslice git:(job-deletion) ✗ earl jobs list local
 job_id                                name                 lifecycle   slicers  workers  _created                  _updated
 21963e57-4fa0-4cae-a1b9-304c2305f8bc  peter-datagen-to-s3  persistent           1        2024-08-08T22:51:40.220Z  2024-08-08T22:51:40.220Z

➜  teraslice git:(job-deletion) ✗ earl jobs list local --deleted only
 job_id                                name                    lifecycle   slicers  workers  _created                  _updated                  _deleted_on
 7636e71b-eda8-4a8d-8069-bc5201985271  peter-datagen-to-es     persistent           1        2024-08-08T22:39:16.225Z  2024-08-08T22:48:40.471Z  2024-08-08T22:48:40.458Z
 23b72801-857f-4457-b947-9ca8c59c5794  peter-datagen-to-kafka  persistent           1        2024-08-08T22:34:55.284Z  2024-08-08T22:36:03.203Z  2024-08-08T22:36:03.201Z

➜  teraslice git:(job-deletion) ✗ earl jobs list local --deleted include
 job_id                                name                    lifecycle   slicers  workers  _created                  _updated                  _deleted_on
 21963e57-4fa0-4cae-a1b9-304c2305f8bc  peter-datagen-to-s3     persistent           1        2024-08-08T22:51:40.220Z  2024-08-08T22:51:40.220Z
 7636e71b-eda8-4a8d-8069-bc5201985271  peter-datagen-to-es     persistent           1        2024-08-08T22:39:16.225Z  2024-08-08T22:48:40.471Z  2024-08-08T22:48:40.458Z
 23b72801-857f-4457-b947-9ca8c59c5794  peter-datagen-to-kafka  persistent           1        2024-08-08T22:34:55.284Z  2024-08-08T22:36:03.203Z  2024-08-08T22:36:03.201Z
➜  teraslice git:(job-deletion) ✗ earl ex list local
 name                 lifecycle   slicers  workers  _status  ex_id                                 job_id                                _created                  _updated
 peter-datagen-to-s3  persistent  1        1        running  abc20261-0baf-4e62-8432-3b57b00aae21  21963e57-4fa0-4cae-a1b9-304c2305f8bc  2024-08-08T22:54:40.986Z  2024-08-08T22:54:50.922Z

➜  teraslice git:(job-deletion) ✗ earl ex list local --deleted only
 name                 lifecycle   slicers  workers  _status  ex_id                                 job_id                                _created                  _updated                  _deleted_on
 peter-datagen-to-es  persistent  1        1        stopped  92a2c02b-51a3-4643-8b42-02bb0369a3eb  7636e71b-eda8-4a8d-8069-bc5201985271  2024-08-08T22:39:30.672Z  2024-08-08T22:48:40.460Z  2024-08-08T22:48:40.460Z

➜  teraslice git:(job-deletion) ✗ earl ex list local --deleted include
 name                 lifecycle   slicers  workers  _status  ex_id                                 job_id                                _created                  _updated                  _deleted_on
 peter-datagen-to-s3  persistent  1        1        running  abc20261-0baf-4e62-8432-3b57b00aae21  21963e57-4fa0-4cae-a1b9-304c2305f8bc  2024-08-08T22:54:40.986Z  2024-08-08T22:54:50.922Z
 peter-datagen-to-es  persistent  1        1        stopped  92a2c02b-51a3-4643-8b42-02bb0369a3eb  7636e71b-eda8-4a8d-8069-bc5201985271  2024-08-08T22:39:30.672Z  2024-08-08T22:48:40.460Z  2024-08-08T22:48:40.460Z

docs/management-apis/endpoints-txt.md Outdated Show resolved Hide resolved
packages/teraslice-cli/src/cmds/jobs/delete.ts Outdated Show resolved Hide resolved
packages/teraslice-cli/src/cmds/tjm/delete.ts Outdated Show resolved Hide resolved
packages/teraslice-cli/src/helpers/jobs.ts Outdated Show resolved Hide resolved
packages/teraslice-client-js/src/jobs.ts Show resolved Hide resolved
packages/teraslice/src/lib/cluster/services/jobs.ts Outdated Show resolved Hide resolved
docs/management-apis/endpoints-json.md Outdated Show resolved Hide resolved
docs/packages/teraslice-cli/overview.md Outdated Show resolved Hide resolved
packages/teraslice-cli/src/helpers/jobs.ts Outdated Show resolved Hide resolved
bump: (minor) teraslice-client-js@1.1.0, teraslice-cli@2.3.0

bump: (minor) @terascope/types@1.1.0, @terascope/utils@1.1.0

bump: (minor) @terascope/data-types@1.1.0, @terascope/data-mate@1.1.0

bump: (minor) elasticsearch-store@1.1.0, terafoundation@1.3.0

bump: (minor) ts-transforms@1.1.0, xlucene-parser@1.1.0

bump: (minor) xlucene-translator@1.1.0, @terascope/elasticsearch-api@4.1.0
@busma13 busma13 changed the title Add ability to soft delete a job [teraslice] - Add ability to soft delete a job Sep 5, 2024
Copy link
Member

@godber godber left a comment

Choose a reason for hiding this comment

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

Please, at the very least make the requested doc change. The e2e changes are optional.

await terasliceHarness.teraslice.jobs.post(`/jobs/${jobId}/_stop`);
await terasliceHarness.waitForExStatus(ex, 'stopped', 100, 1000);

await expect(terasliceHarness.teraslice.jobs.delete(`/jobs/${jobId}`)).resolves.toMatchObject(deletedJobProperties);
Copy link
Member

Choose a reason for hiding this comment

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

At this point, the job should not show up in /txt/jobs, if there's an easy way to test that, it might be worth doing.

You can test any of the scenarios that being deleted causes, like no updating or starting.

@@ -563,6 +572,33 @@ $ curl 'localhost:5678/v1/jobs/5a50580c-4a50-48d9-80f8-ac70a00f3dbd/errors'
]
```

## DELETE /v1/jobs/\{jobId\};

Issues a delete command, deleting the job and all related execution contexts. Any orphaned K8s resources associated with the job will also be deleted. The job must have a terminal status to be deleted. The `active` field will automatically be set to `false`.
Copy link
Member

Choose a reason for hiding this comment

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

Please extend this with the consequences of deleting a job:

A delete job cannot be updated ....

@ciorg
Copy link
Member

ciorg commented Sep 6, 2024

LGTM

Copy link
Member

@jsnoble jsnoble left a comment

Choose a reason for hiding this comment

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

LGTM

@jsnoble jsnoble merged commit dc89d8c into master Sep 6, 2024
66 checks passed
@jsnoble jsnoble deleted the job-deletion branch September 6, 2024 21:28
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.

4 participants