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

[Feature]: Developer can wait for the deletion of a space to be complete #2604

Closed
gcapizzi opened this issue Jun 14, 2023 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@gcapizzi
Copy link
Contributor

gcapizzi commented Jun 14, 2023

Background

As a developer
I want to know when a space has finished deleting
So that I can plan other operations accordingly

Dev Notes

  • We may want to add timeout logic to check the deletion timestamp on the object set for deletion.
  • Note that other jobs default to a 15 minute timeout, but technically the top level delete jobs do not get marked as failed in CF for VMs.
  • We're thinking about adding the failed state here along with a small message about checking for the lingering resources like service binding projections
  • https://v3-apidocs.cloudfoundry.org/version/3.139.0/index.html#jobs
  • Similar to other jobs we suspect this will not require a new crd to track the job, instead encoding the required information in the url

Acceptance Criteria

GIVEN I have a space
WHEN I delete the space
AND I follow the redirect to the deletion job
THEN I see that the job looks like this:

{
  "guid": "space.delete~<the-space-guid>",
  "operation": "space.delete",
  "state": "PROCESSING",
  "links": {
    "self": {
      "href": "https://api.example.org/v3/jobs/space.delete~<the-space-guid>"
    }
  },
  "errors": [],
  "warnings": []
}

GIVEN I have waited long enough for the space deletion to successfully complete
WHEN I get the deletion job
THEN I see it looks like this:

{
  "guid": "space.delete~<the-space-guid>",
  "operation": "space.delete",
  "state": "COMPLETE",
  "links": {
    "self": {
      "href": "https://api.example.org/v3/jobs/space.delete~<the-space-guid>"
    }
  },
  "errors": [],
  "warnings": []
}

GIVEN I have waited long enough for the org deletion to time out
WHEN I get the deletion job
THEN I see it looks roughly like this:

{
  "guid": "space.delete~<the-space-guid>",
  "operation": "space.delete",
  "state": "FAILED",
  "links": {
    "self": {
      "href": "https://api.example.org/v3/jobs/space.delete~<the-space-guid>"
    }
  },
 "errors": [
    {
      "code": 10008,
      "title": "CF-UnprocessableEntity",
      "detail": "something went wrong, check for lingering resources in cfspace"
    }
  ],
  "warnings": [
    {
      "detail": "warning! warning!"
    }
  ]
}

GIVEN the space doesn't exist
WHEN I get the deletion job
THEN I still see a COMPLETE response like the above

GIVEN I have no permissions to get the space
WHEN I get the deletion job
THEN I still see a COMPLETE response like the above

GIVEN a space that hasn't been deleted
WHEN I get the deletion job
THEN I get a 404 Not Found

@gcapizzi gcapizzi added the Jobs label Jun 14, 2023
@gcapizzi gcapizzi added this to the v0.9 milestone Jun 14, 2023
@gcapizzi gcapizzi modified the milestones: v0.9, v0.8 Jun 28, 2023
@davewalter davewalter self-assigned this Jun 28, 2023
davewalter added a commit that referenced this issue Jun 29, 2023
- Refactor org deletion helper to handle all types.

[#2604]

Co-authored-by: Dave Walter <walterda@vmware.com>
davewalter added a commit that referenced this issue Jun 30, 2023
- Refactor org deletion helper to handle all types.

[#2604]

Co-authored-by: Dave Walter <walterda@vmware.com>
davewalter added a commit that referenced this issue Jun 30, 2023
- The cached client would sometimes return a resource without the
  deletion timestamp when the job endpoint was called immediately after
  deleting the resource.
- Consolidate CFSpaceRepository and SpaceRepository interfaces.

[#2604]
[#2605]

Co-authored-by: Dave Walter <walterda@vmware.com>
davewalter added a commit that referenced this issue Jun 30, 2023
- The cached client would sometimes return a resource without the
  deletion timestamp when the job endpoint was called immediately after
  deleting the resource.
- Consolidate CFSpaceRepository and SpaceRepository interfaces.

[#2604]
[#2605]

Co-authored-by: Dave Walter <walterda@vmware.com>
davewalter added a commit that referenced this issue Jul 3, 2023
- Add a retry loop to wait for the deletion timestamp to propagate.
- Added a GetOrgForDeletion function to the org repository to avoid
  falsely returning a not found error when the role binding is deleted
  from an org during deletion.
- Consolidate CFSpaceRepository and SpaceRepository interfaces.

[#2604]
[#2605]

Co-authored-by: Dave Walter <walterda@vmware.com>
Co-authored-by: Julian Hjortshoj <hjortshojj@vmware.com>
davewalter added a commit that referenced this issue Jul 5, 2023
- Refactor org deletion helper to handle all types.

[#2604]

Co-authored-by: Dave Walter <walterda@vmware.com>
davewalter added a commit that referenced this issue Jul 5, 2023
- Add a retry loop to wait for the deletion timestamp to propagate.
- Added a GetOrgForDeletion function to the org repository to avoid
  falsely returning a not found error when the role binding is deleted
  from an org during deletion.
- Consolidate CFSpaceRepository and SpaceRepository interfaces.

[#2604]
[#2605]

Co-authored-by: Dave Walter <walterda@vmware.com>
Co-authored-by: Julian Hjortshoj <hjortshojj@vmware.com>
davewalter added a commit that referenced this issue Jul 6, 2023
- Add a retry loop to wait for the deletion timestamp to propagate.
- Added a GetOrgUnfiltered function to the org repository to avoid
  falsely returning a not found error when the role binding is deleted
  from an org during deletion.
- Consolidate CFSpaceRepository and SpaceRepository interfaces.

[#2604]
[#2605]

Co-authored-by: Dave Walter <walterda@vmware.com>
Co-authored-by: Julian Hjortshoj <hjortshojj@vmware.com>
davewalter added a commit that referenced this issue Jul 6, 2023
- Refactor org deletion helper to handle all types.

[#2604]

Co-authored-by: Dave Walter <walterda@vmware.com>
davewalter added a commit that referenced this issue Jul 6, 2023
- Add a retry loop to wait for the deletion timestamp to propagate.
- Added a GetOrgUnfiltered function to the org repository to avoid
  falsely returning a not found error when the role binding is deleted
  from an org during deletion.
- Consolidate CFSpaceRepository and SpaceRepository interfaces.

[#2604]
[#2605]

Co-authored-by: Dave Walter <walterda@vmware.com>
Co-authored-by: Julian Hjortshoj <hjortshojj@vmware.com>
@matt-royal
Copy link
Member

This story passed the acceptance criteria.

When the space was deleting but hadn't completed, I got a 200 with this body:

{
  "created_at": "",
  "errors": [],
  "guid": "space.delete~cf-space-a0ad8c07-fd70-4d70-9458-d870578de5e5",
  "links": {
    "self": {
      "href": "https://localhost/v3/jobs/space.delete~cf-space-a0ad8c07-fd70-4d70-9458-d870578de5e5"
    }
  },
  "operation": "space.delete",
  "state": "PROCESSING",
  "updated_at": "",
  "warnings": null
}

When the space finished deleting, I got a 200 with this body:

{
  "created_at": "",
  "errors": [],
  "guid": "space.delete~cf-space-a0ad8c07-fd70-4d70-9458-d870578de5e5",
  "links": {
    "self": {
      "href": "https://localhost/v3/jobs/space.delete~cf-space-a0ad8c07-fd70-4d70-9458-d870578de5e5"
    }
  },
  "operation": "space.delete",
  "state": "COMPLETE",
  "updated_at": "",
  "warnings": null
}

When I added a fake finalizer to the CFSpace so it would never delete, I eventually got a 200 with this body:

{
  "created_at": "",
  "errors": [
    {
      "code": 10008,
      "detail": "Space deletion timed out, check the remaining \"cf-space-76917ca6-3dff-4baa-ad16-6c36549683b6\" resource",
      "title": "CF-UnprocessableEntity"
    }
  ],
  "guid": "space.delete~cf-space-76917ca6-3dff-4baa-ad16-6c36549683b6",
  "links": {
    "self": {
      "href": "https://localhost/v3/jobs/space.delete~cf-space-76917ca6-3dff-4baa-ad16-6c36549683b6"
    }
  },
  "operation": "space.delete",
  "state": "FAILED",
  "updated_at": "",
  "warnings": null
}

When I requested the job status for a non-existent space, I got a 200 with this body:

{
  "created_at": "",
  "errors": [],
  "guid": "space.delete~nosuchspace",
  "links": {
    "self": {
      "href": "https://localhost/v3/jobs/space.delete~nosuchspace"
    }
  },
  "operation": "space.delete",
  "state": "COMPLETE",
  "updated_at": "",
  "warnings": null
}

When querying the status of a space that I don't have access to I received a 200 with this body:

{
  "created_at": "",
  "errors": [],
  "guid": "space.delete~cf-space-34f3090f-5742-40c8-bcaa-adcc6a034b83",
  "links": {
    "self": {
      "href": "https://localhost/v3/jobs/space.delete~cf-space-34f3090f-5742-40c8-bcaa-adcc6a034b83"
    }
  },
  "operation": "space.delete",
  "state": "COMPLETE",
  "updated_at": "",
  "warnings": null
}

When the job doesn't exist, I got a 404 with this body:

{
  "errors": [
    {
      "code": 10010,
      "detail": "Job not found. Ensure it exists and you have access to it.",
      "title": "CF-ResourceNotFound"
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

3 participants