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

Can't avoid hardcoding interface:scsi #5295

Open
jsoref opened this issue Jan 2, 2020 · 3 comments · May be fixed by GoogleCloudPlatform/magic-modules#11423
Open

Can't avoid hardcoding interface:scsi #5295

jsoref opened this issue Jan 2, 2020 · 3 comments · May be fixed by GoogleCloudPlatform/magic-modules#11423

Comments

@jsoref
Copy link
Contributor

jsoref commented Jan 2, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

Terraform v0.12.16
+ provider.google v3.3.0

Affected Resource(s)

  • google_compute_instance_template

Terraform Configuration Files

provider google {
  version = "~> 3.0"
}

resource "google_compute_instance_template" "node" {
  name         = "node"
  machine_type = "n1-standard-1"
  can_ip_forward = false

  disk {
    source_image = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9"
    disk_size_gb = 10
    disk_type    = "pd-ssd"
    boot         = true
    mode         = "READ_WRITE"
    type         = "PERSISTENT"
  }

  network_interface {
    network = "default"
  }
}

resource "google_compute_instance_template" "node-scsi" {
  name         = "node-scsi"
  machine_type = "n1-standard-1"
  can_ip_forward = false

  disk {
    source_image = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9"
    disk_size_gb = 10
    disk_type    = "pd-ssd"
    boot         = true
    mode         = "READ_WRITE"
    type         = "PERSISTENT"
    interface    = "SCSI"
  }

  network_interface {
    network = "default"
  }
}

Debug Output

Panic Output

Expected Behavior

A similarly manually created template doesn't declare a scsi interface -- which to me means that in theory it could change if google updates their defaults (which is perhaps something i might want):

creationTimestamp: '...'
description: ''
id: '...'
kind: compute#instanceTemplate
name: node-native
properties:
  canIpForward: false
  disks:
  - autoDelete: true
    boot: true
    deviceName: boot
    index: 0
    initializeParams:
      diskSizeGb: '10'
      diskType: pd-ssd
      sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
    kind: compute#attachedDisk
    mode: READ_WRITE
    type: PERSISTENT
  machineType: n1-standard-1
  metadata:
    fingerprint: ...
    kind: compute#metadata
  networkInterfaces:
  - kind: compute#networkInterface
    network: https://www.googleapis.com/compute/v1/projects/.../global/networks/default
  scheduling:
    automaticRestart: true
    onHostMaintenance: MIGRATE
    preemptible: false
  serviceAccounts:
  - email: [email protected]
    scopes:
    - https://www.googleapis.com/auth/devstorage.read_only
    - https://www.googleapis.com/auth/logging.write
    - https://www.googleapis.com/auth/monitoring.write
    - https://www.googleapis.com/auth/service.management.readonly
    - https://www.googleapis.com/auth/servicecontrol
    - https://www.googleapis.com/auth/trace.append
selfLink: https://www.googleapis.com/compute/v1/projects/.../global/instanceTemplates/node-native

Actual Behavior

plan output:

Terraform will perform the following actions:

  # google_compute_instance_template.node will be created
  + resource "google_compute_instance_template" "node" {
      + can_ip_forward       = false
      + id                   = (known after apply)
      + machine_type         = "n1-standard-1"
      + metadata_fingerprint = (known after apply)
      + name                 = "node"
      + name_prefix          = (known after apply)
      + project              = (known after apply)
      + region               = (known after apply)
      + self_link            = (known after apply)
      + tags_fingerprint     = (known after apply)

      + disk {
          + auto_delete  = true
          + boot         = true
          + device_name  = (known after apply)
          + disk_size_gb = 10
          + disk_type    = "pd-ssd"
          + interface    = (known after apply)
          + mode         = "READ_WRITE"
          + source_image = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9"
          + type         = "PERSISTENT"
        }

      + network_interface {
          + network            = "default"
          + subnetwork         = (known after apply)
          + subnetwork_project = (known after apply)
        }

      + scheduling {
          + automatic_restart   = (known after apply)
          + on_host_maintenance = (known after apply)
          + preemptible         = (known after apply)

          + node_affinities {
              + key      = (known after apply)
              + operator = (known after apply)
              + values   = (known after apply)
            }
        }
    }

  # google_compute_instance_template.node-scsi will be created
  + resource "google_compute_instance_template" "node-scsi" {
      + can_ip_forward       = false
      + id                   = (known after apply)
      + machine_type         = "n1-standard-1"
      + metadata_fingerprint = (known after apply)
      + name                 = "node-scsi"
      + name_prefix          = (known after apply)
      + project              = (known after apply)
      + region               = (known after apply)
      + self_link            = (known after apply)
      + tags_fingerprint     = (known after apply)

      + disk {
          + auto_delete  = true
          + boot         = true
          + device_name  = (known after apply)
          + disk_size_gb = 10
          + disk_type    = "pd-ssd"
          + interface    = "SCSI"
          + mode         = "READ_WRITE"
          + source_image = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9"
          + type         = "PERSISTENT"
        }

      + network_interface {
          + network            = "default"
          + subnetwork         = (known after apply)
          + subnetwork_project = (known after apply)
        }

      + scheduling {
          + automatic_restart   = (known after apply)
          + on_host_maintenance = (known after apply)
          + preemptible         = (known after apply)

          + node_affinities {
              + key      = (known after apply)
              + operator = (known after apply)
              + values   = (known after apply)
            }
        }
    }

describe output:

$ gcloud compute instance-templates describe node
creationTimestamp: '...'
description: ''
id: '...'
kind: compute#instanceTemplate
name: node
properties:
  disks:
  - autoDelete: true
    boot: true
    deviceName: persistent-disk-0
    index: 0
    initializeParams:
      diskSizeGb: '10'
      diskType: pd-ssd
      sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
    interface: SCSI
    kind: compute#attachedDisk
    mode: READ_WRITE
    type: PERSISTENT
  machineType: n1-standard-1
  metadata:
    fingerprint: JTqYaJW_BVs=
    kind: compute#metadata
  networkInterfaces:
  - kind: compute#networkInterface
    network: https://www.googleapis.com/compute/v1/projects/.../global/networks/default
  scheduling:
    automaticRestart: true
    onHostMaintenance: MIGRATE
    preemptible: false
selfLink: https://www.googleapis.com/compute/v1/projects/.../global/instanceTemplates/node

$ gcloud compute instance-templates describe node-scsi
creationTimestamp: '...'
description: ''
id: '...'
kind: compute#instanceTemplate
name: node-scsi
properties:
  disks:
  - autoDelete: true
    boot: true
    deviceName: persistent-disk-0
    index: 0
    initializeParams:
      diskSizeGb: '10'
      diskType: pd-ssd
      sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
    interface: SCSI
    kind: compute#attachedDisk
    mode: READ_WRITE
    type: PERSISTENT
  machineType: n1-standard-1
  metadata:
    fingerprint: JTqYaJW_BVs=
    kind: compute#metadata
  networkInterfaces:
  - kind: compute#networkInterface
    network: https://www.googleapis.com/compute/v1/projects/.../global/networks/default
  scheduling:
    automaticRestart: true
    onHostMaintenance: MIGRATE
    preemptible: false
selfLink: https://www.googleapis.com/compute/v1/projects/.../global/instanceTemplates/node-scsi

Steps to Reproduce

  1. terraform apply
  2. gcloud compute instance-templates describe node-native
  3. gcloud compute instance-templates describe node
  4. gcloud compute instance-templates describe node-scsi

Important Factoids

I have pre-existing manually created templates that I kind of like. I'd like to migrate to using terraform w/o losing their characteristics.

(Yes, I understand SCSI is the default today, and the terraform behavior is documented, but it clearly isn't required from gcloud's perspective.)

References

This is in the family of #5283 -- things which do not quite work the way I'd like in that I can't produce the output I'd like the way I'd like / there doesn't appear to be any way to do so using terraform.

b/308756461

@venkykuberan
Copy link
Contributor

venkykuberan commented Jan 6, 2020

@jsoref Is your question is why Terraform is setting SCSI for disk interface?. if so per [https://cloud.google.com/compute/docs/reference/rest/v1/instanceTemplates] (api spec) the default value for disk.interface is SCSI.

Can you please provide a little more detail on what the bug is ?

@venkykuberan
Copy link
Contributor

@jsoref if you aren't looking for help on this issue, shall i go head and close this one ?

@jsoref
Copy link
Contributor Author

jsoref commented Apr 16, 2020

@venkykuberan: sorry. I thought it was plainly obvious. There's no reason that terraform should take the node case which doesn't hard-code scsi and hard-code scsi into the template. Google will on the other side do that.

I'm not sure how else to explain it. Just because Google's backend does something by default doesn't mean your frontend should perform that coercion up front. Let the backend do the conversion.

@ghost ghost removed the waiting-response label Apr 16, 2020
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Oct 8, 2021
Signed-off-by: Modular Magician <[email protected]>
modular-magician added a commit that referenced this issue Oct 8, 2021
Signed-off-by: Modular Magician <[email protected]>
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-instances labels Oct 25, 2023
@edwardmedia edwardmedia removed the forward/review In review; remove label to forward label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants