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

Problem deleting chef server with attached orgs #3294

Closed
msorens opened this issue Apr 7, 2020 · 3 comments · Fixed by #3478
Closed

Problem deleting chef server with attached orgs #3294

msorens opened this issue Apr 7, 2020 · 3 comments · Fixed by #3478
Assignees
Labels
automate-infra-proxy bug 🐛 Something isn't working

Comments

@msorens
Copy link
Contributor

msorens commented Apr 7, 2020

Describe the bug

There is a problem deleting a chef server that has one or more organizations attached. I am not sure what is supposed to happen, but a fix is needed either way.

To Reproduce

Create a server:

$ curl -sSkH "api-token: $TOK" -X POST \
-d '{"name": "SERVER_NAME2", "description": "SERVER_DESCRIPTION2", "fqdn": "example.com", "ip_address": "127.0.0.1"}' \
https://a2-dev.test/api/v0/infra/servers?pretty
{
  "server": {
    "id": "d31e49ce-608b-46d4-b8b5-a819d19222ad",
    "name": "SERVER_NAME2",
    "description": "SERVER_DESCRIPTION2",
    "fqdn": "example.com",
    "ip_address": "127.0.0.1",
    "orgs_count": 0
  }
}

Grab the id value from above and plug in here to add an organization:

$ curl -sSkH "api-token: $TOK" -X POST \
-d '{"name": "ORG_NAME2", "admin_user": "ADMIN_USER", "admin_key": "KEY"}' \
https://a2-dev.test/api/v0/infra/servers/d31e49ce-608b-46d4-b8b5-a819d19222ad/orgs?pretty
{
  "org": {
    "id": "956c1773-d5ba-471b-8e0d-ceb37603e271",
    "name": "ORG_NAME2",
    "admin_user": "ADMIN_USER",
    "admin_key": "e2ac8d74-b419-42b3-b96c-aa2f738e8f18",
    "server_id": "d31e49ce-608b-46d4-b8b5-a819d19222ad",
    "projects": [
    ]
  }
}

Attempt to delete the server and it fails with, at a minimum, the wrong error message:

$ curl -sSkH "api-token: $TOK" -X DELETE \
https://a2-dev.test/api/v0/infra/servers/d31e49ce-608b-46d4-b8b5-a819d19222ad?pretty
{
  "error": "no server found with id \"d31e49ce-608b-46d4-b8b5-a819d19222ad\"",
  "code": 5,
  "message": "no server found with id \"d31e49ce-608b-46d4-b8b5-a819d19222ad\"",
  "details": [
  ]
}

Delete org first:

$ curl -sSkH "api-token: $TOK" -X DELETE \
https://a2-dev.test/api/v0/infra/servers/d31e49ce-608b-46d4-b8b5-a819d19222ad/orgs/956c1773-d5ba-471b-8e0d-ceb37603e271?pretty
{
  "org": {
    "id": "956c1773-d5ba-471b-8e0d-ceb37603e271",
    "name": "ORG_NAME2",
    "admin_user": "ADMIN_USER",
    "admin_key": "e2ac8d74-b419-42b3-b96c-aa2f738e8f18",
    "server_id": "d31e49ce-608b-46d4-b8b5-a819d19222ad",
    "projects": [
    ]
  }
}

Now try to delete the server again and it works:

$  curl -sSkH "api-token: $TOK" -X DELETE https://a2-dev.test/api/v0/infra/servers/d31e49ce-608b-46d4-b8b5-a819d19222ad?pretty
{
  "server": {
    "id": "d31e49ce-608b-46d4-b8b5-a819d19222ad",
    "name": "SERVER_NAME2",
    "description": "SERVER_DESCRIPTION2",
    "fqdn": "example.com",
    "ip_address": "127.0.0.1",
    "orgs_count": 0
  }
}

The same incorrect error occurs in the UI:
image

Expected behavior

I am not sure what is supposed to happen, but a fix is needed either way.

Scenario 1: User should NOT be allowed to delete a chef server if it has orgs

Fix needed: Error message should say

"cannot delete server _<server-guid>_ because it still has organizations attached"

instead of

"no server found with id _<server-guid>_"

Scenario 2: User should be allowed to delete a chef server if it has orgs

Fix needed: process the delete of the server (and presumably its associated orgs)
and present a success message instead of the incorrect error message.

@msorens msorens added bug 🐛 Something isn't working automate-infra-proxy labels Apr 7, 2020
@kvivek1115
Copy link

kvivek1115 commented Apr 7, 2020

@msorens Thanks for reporting the issue, this should be supposed to work as expected behavior, User should not be allowed to delete a chef server if it has orgs, but seems error message is wrong.

@susanev
Copy link
Contributor

susanev commented Apr 7, 2020

itd be rad if we can follow the same design pattern for a project that has ingest rules, on project delete it opens a modal with more details on what they need to do in order to delete. am attaching the modal for project.

project-delete

@jonong1972
Copy link

Yup. I we should follow our current pattern as @susanev mentioned above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automate-infra-proxy bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants