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

Fixed a bug where environments could not be deleted. #1623

Merged
merged 2 commits into from
May 31, 2018

Conversation

echlebek
Copy link
Contributor

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]

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 echlebek force-pushed the bugfix/delete-environments branch from fc58274 to 6ca392a Compare May 30, 2018 17:58
@echlebek echlebek requested review from teekennedy and nikkictl May 30, 2018 18:36
Copy link

@nikkictl nikkictl left a comment

Choose a reason for hiding this comment

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

I could use a little clarification here 😄

@@ -71,3 +67,38 @@ func TestEnvStorage(t *testing.T) {
assert.Equal(t, 1, len(envs))
})
}

func TestDeleteEnvironment_GH1567(t *testing.T) {

Choose a reason for hiding this comment

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

Perhaps I'm missing some context here, but what does GH1567 mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the issue this test was written to reproduce. (GH stands for Github)

Choose a reason for hiding this comment

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

Ah very cool!


// Second delete should succeed
require.NoError(t, store.DeleteEnvironment(ctx, env))
require.NoError(t, store.DeleteEnvironment(ctx, env))

Choose a reason for hiding this comment

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

Could you help me understand why this is the desired action? If an environment has been deleted and does not exist, why wouldn't it return an error when you attempt to delete it again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because HTTP DELETE needs to be idempotent. See https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html for more information.

Copy link
Contributor

@teekennedy teekennedy left a comment

Choose a reason for hiding this comment

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

The original issue and the solution/tests look good.

I'm curious as to why assets aren't tagged with environment/organization though. I could see use cases where part of an org would want to restrict access to an asset. Is it because access restriction for assets would be unenforceable?

Copy link

@nikkictl nikkictl left a comment

Choose a reason for hiding this comment

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

Thanks for answering those questions!!

giphy

@echlebek echlebek merged commit f0158dc into master May 31, 2018
@echlebek echlebek deleted the bugfix/delete-environments branch May 31, 2018 16:40
@echlebek
Copy link
Contributor Author

@Cyphus I think Sean and Greg designed assets to be scoped to Organizations so that Environments could reuse them.

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.

Unable to delete environment
3 participants