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

Unable to delete environment #1567

Closed
treydock opened this issue May 21, 2018 · 4 comments · Fixed by #1623
Closed

Unable to delete environment #1567

treydock opened this issue May 21, 2018 · 4 comments · Fixed by #1623
Assignees
Labels

Comments

@treydock
Copy link
Contributor

Expected Behavior

I'd expect to delete an environment that has only been created during tests.

Current Behavior

/usr/bin/sensuctl environment delete test --skip-confirm

{"error":"environment is not empty","code":0}

Possible Solution

It would be handy if the resource keeping an environment from being deleted is printed. I can imagine this would be very expensive or verbose with lots of resources but in this case there should be nothing, see below.

Steps to Reproduce (for bugs)

Unsure how to reproduce as my acceptance testing will create resources then delete them so nothing should be persisting long enough to stay in a test environment.

Context

I am running acceptance tests for Puppet sensu module and an environment is created, modified then deleted and the deletion is failing. This only manifests itself when other resources before this environment are created. What's making this strange is nothing is added or modified while between environment creation and deletion attempt.

I'm unsure how to debug this issue as seems like this environment should have no resources associated with it and thus should be allowed to be deleted.

CC: @ghoneycutt

Your Environment

  • Sensu version used (sensuctl, sensu-backend, and/or sensu-agent): Nightly as of 05/20/2018
  • Installation method (packages, binaries, docker etc.): RPM
  • Operating System and version (e.g. Ubuntu 14.04): EL7
@treydock
Copy link
Contributor Author

Was able to reproduce inside Vagrant test environment

[root@sensu-backend ~]# sensuctl environment delete test
? Are you sure you would like to delete resource 'test'? Yes
Error: {"error":"environment is not empty","code":0}

I've not assigned anything to this environment.

Based on #333 I checked resources and what I found is a test asset with no environment shows up when I query with --environment test.

[root@sensu-backend ~]# for r in asset check entity handler mutator ; do sensuctl $r list --environment test ; done
  Name                URL                 Hash
 ────── ─────────────────────────────── ─────────
  test   //example.com/.../example.tar   4f926bf
  Name   Command   Interval   Cron   Timeout   TTL   Subscriptions   Handlers   Assets   Hooks   Publish?   Stdin?   Metric Format   Metric Handlers
 ────── ───────── ────────── ────── ───────── ───── ─────────────── ────────── ──────── ─────── ────────── ──────── ─────────────── ─────────────────
  ID   Class   OS   Subscriptions   Last Seen
 ──── ─────── ──── ─────────────── ───────────
  Name   Type   Timeout   Filters   Mutator   Execute   Environment Variables
 ────── ────── ───────── ───────── ───────── ───────── ───────────────────────
  Name   Command   Environment Variables   Timeout
 ────── ───────── ─────────────────────── ─────────
[root@sensu-backend ~]# sensuctl asset list --format json
[
  {
    "name": "test",
    "url": "http://example.com/asset/example.tar",
    "sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b",
    "metadata": null,
    "filters": [
      "System.OS==linux"
    ],
    "organization": "default"
  }
]

I don't know if this is the resource keeping the environment held but I can't delete the asset as that doesn't yet seem supported.

@echlebek
Copy link
Contributor

We'd have to resolve the issue with assets not being able to be deleted first. See #988

@grepory grepory removed the ready label May 29, 2018
@treydock
Copy link
Contributor Author

Does an asset belong to all environments? I don't recall seeing an explicit environment assigned to assets when testing, only an organization.

@echlebek
Copy link
Contributor

Looking at this again it appears you're correct! We are needlessly checking for the presence of assets when the environment is being deleted. Thanks. 👍

@echlebek echlebek added the ready label May 30, 2018
@echlebek echlebek self-assigned this May 30, 2018
echlebek added a commit that referenced this issue May 30, 2018
This commit fixes a bug where environments could not be deleted if
the organization they reside in has one or more assets.

Assets do not exist within environments, so there is no reason to
consider them when deleting environments.

This commit also stops the environment store from reporting an
error when an environment that doesn't exist is deleted.

Closes #1567

Signed-off-by: Eric Chlebek <[email protected]>
echlebek added a commit that referenced this issue May 30, 2018
This commit fixes a bug where environments could not be deleted if
the organization they reside in has one or more assets.

Assets do not exist within environments, so there is no reason to
consider them when deleting environments.

This commit also stops the environment store from reporting an
error when an environment that doesn't exist is deleted.

Closes #1567

Signed-off-by: Eric Chlebek <[email protected]>
echlebek added a commit that referenced this issue May 31, 2018
This commit fixes a bug where environments could not be deleted if
the organization they reside in has one or more assets.

Assets do not exist within environments, so there is no reason to
consider them when deleting environments.

This commit also stops the environment store from reporting an
error when an environment that doesn't exist is deleted.

Closes #1567

Signed-off-by: Eric Chlebek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants