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

[improvement] google_compute_disk support for resizing disk #10442

Closed
JorritSalverda opened this issue Nov 30, 2016 · 6 comments
Closed

[improvement] google_compute_disk support for resizing disk #10442

JorritSalverda opened this issue Nov 30, 2016 · 6 comments

Comments

@JorritSalverda
Copy link

Increasing the size of google_compute_disk forces recreation, however it's possible to resize a google cloud disk on the fly, see https://cloud.google.com/compute/docs/disks/add-persistent-disk.

Instead of recreating the resource just modifying the size would be ideal. Now I still have to do that outside of terraform and then update my tf file and the terraform.tfstate file to reflect the new size.

Terraform Version

Terraform v0.7.13

Affected Resource(s)

google_compute_disk

@paddycarver
Copy link
Contributor

Hey @JorritSalverda! Thanks for bringing this up. Definitely a great feature that we'd love to add. Looking into it a bit:

  • Modifying persistent disks is currently problematic. See 'google_compute_instance' adding 'google_compute_disk' forces new resource #6678. We need to come to a solution that allows us to edit modify disks without triggering a forced recreation of the instance, because currently we can't change anything about a disk without recreating the instance. This is a bit complicated, but @danawillow is thinking on it, and we'll continue talking about it.
  • Even if Terraform supports resizing the disk itself, I can't think of a reasonable or scalable method for resizing the filesystem, which also needs to happen. I know the AWS provider just did this, so I'll look into that and figure out what they did.
  • Finally, resizing the root disk gets even more tricky, as you need to restart the instance for it to take effect. Terraform doesn't know about started/stopped/restarting, it only really knows about creating and destroying. Again, I think the AWS provider just had to deal with this, so I'll look into what they did.

As for updating your tfstate, you should be able to just update the config, and refresh should update the state to show the new size. If not, that's a bug, and please let me know!

So this is a bit complicated, and has some work that needs to get done before it's feasible. Which isn't to say that it won't happen, but I just want to set expectations accordingly that it may not happen immediately, and if/when it does happen, there may be some caveats around the filesystem.

@bgt101
Copy link

bgt101 commented May 4, 2017

Increasing the size of the disk using gcloud and then refreshing the state does not update the size in the state.

As for growing the filesystem, that can be done while mounted without a reboot. I suspect it could be implemented in a null_resource using a trigger and a remote-exec, without the need for additional Terraform changes.

@paddycarver
Copy link
Contributor

Thanks for letting us know, @bgt101. This is probably related to #14136. We're looking into it to see what's going on.

@danawillow
Copy link
Contributor

Support for this was added in #15077. However, it does not address the pitfalls noted in this issue, so please be very careful when using it.

@bgt101
Copy link

bgt101 commented Jun 8, 2017

In Terraform 0.9.8 resizing disks works beautifully. Thanks!

To resize the filesystem online, I used a null_resource like this:

resource "null_resource" "fs_grower" {
  triggers {
    disk_size = "${google_compute_disk.data.size}"
  }

  provisioner "remote-exec" {
    connection {
      host = "${google_compute_instance.instance.network_interface.0.address}"
      type = "ssh"
      user = "xxxxx"
    }

    inline = [
      "sudo xfs_growfs -d /data",
    ]
  }
}

It gets a little trickier for devices which are partitioned, but doable.

@ghost
Copy link

ghost commented Apr 10, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants