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

Weird behaviour (remove all+add all) when changing resources in digitalocean_project #585

Closed
morsik opened this issue Feb 17, 2021 · 1 comment · Fixed by #586
Closed

Weird behaviour (remove all+add all) when changing resources in digitalocean_project #585

morsik opened this issue Feb 17, 2021 · 1 comment · Fixed by #586
Labels

Comments

@morsik
Copy link

@morsik morsik commented Feb 17, 2021

Hi there,

Not sure if this is related to provider itself or DigitalOcean web page, but here what's the problem.

While adding or removing resources to digitalocean_project, webpage GUI tells that everything was removed and everything was added again even I removed only 1 item from resources. This feels very wrong and I always feel I just destroyed too much.

Terraform Version

Terraform v0.14.6
+ provider registry.terraform.io/digitalocean/digitalocean v2.5.1

Affected Resource(s)

  • digitalocean_project
  • digitalocean_project_resources (possibly, not tested)

Expected Behavior

Web page should just show notification about removing exactly 1 item. Not removing everything and adding back again.

Actual Behavior

Shows information about removing everything!

Steps to Reproduce

Terraform Configuration Files

Just create simpliest digitalocean_project like:

# of course here you need those actual resources too, I'm not entering them for simplicity

resource "digitalocean_project" "labs" {
  name        = "labs"
  resources = [
    digitalocean_domain.lab.urn,
    digitalocean_droplet.swarmtest_01.urn,
    digitalocean_droplet.swarmtest_02.urn,
    digitalocean_droplet.swarmtest_03.urn,
  ]
}

Apply Terraform. Check webpage (you'll see 3 Droplets in this Project).

After checking, remove one Droplet resource (for ex digitalocean_droplet.swarmtest_03.urn). Apply and check again. If you slow enough, everything will look fine, but if you were watching DigitalOcean webpage in real-time you'll see that all resources were actually deleted from this project (and moved to main project) and then restored back again (without the one you removed).

Also there is a lot of notifications about this:

Screenshot from 2021-02-17 20-03-47

@morsik morsik changed the title Weird behaviour of changing resources in digitalocean_project Weird behaviour (remove all+add all) when changing resources in digitalocean_project Feb 17, 2021
@andrewsomething
Copy link
Member

@andrewsomething andrewsomething commented Feb 17, 2021

Thanks for raising this issue. It looks it currently does remove all resource and then adds them back:

// The API requires project resources to be reassigned to another project if the association needs to be deleted.
// a diff of the resource could be implemented instead of removing all, (bulk) and adding the back again.

We can definitely improve the experience here.

andrewsomething added a commit that referenced this issue Feb 18, 2021
…585). (#586)

* Add function for comparing *schema.Sets

* projects: Only add or remove resources that have changed.

* datasource_digitalocean_projects accepance test should not run in parallel.

* Check error; protect against empty requests.
andrewsomething added a commit that referenced this issue Apr 26, 2021
…585). (#586)

* Add function for comparing *schema.Sets

* projects: Only add or remove resources that have changed.

* datasource_digitalocean_projects accepance test should not run in parallel.

* Check error; protect against empty requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants