googleapis / google-api-python-client

🐍 The official Python client library for Google's discovery based APIs.
https://googleapis.github.io/google-api-python-client/docs/
Apache License 2.0
7.76k stars 2.41k forks source link

diskSizeGb param does not work with compute.instances().insert() #787

Closed linzwatt closed 4 years ago

linzwatt commented 4 years ago

When I try to launch a GCP compute instance using this python client api, the diskSizeGb param seems to be ignored, and the instance launches with a disk that is the same size as the image.

Environment details

Steps to reproduce

Launch config

{
    'disks': [
        {
            'autoDelete': True,
            'boot': True,
            'diskSizeGb': '200',
            'diskType': 'zones/us-west1-a/diskTypes/pd-ssd',
            'initializeParams': {
                'sourceImage': 'https://www.googleapis.com/compute/v1/projects/idyllic-root-258007/global/images/vaux-image-1574381864'
            }
        }
    ],
    'guestAccelerators': [{
        'acceleratorCount': 1,
        'acceleratorType': 'projects/idyllic-root-258007/zones/us-west1-a/acceleratorTypes/nvidia-tesla-v100'
    }],
    'machineType': 'zones/us-west1-a/machineTypes/n1-standard-8',
    'name': 'test',
    'networkInterfaces': [{
        'accessConfigs': [{
            'name': 'External NAT',
            'type': 'ONE_TO_ONE_NAT'
        }],
        'network': 'global/networks/default'
    }],
    'scheduling': {
        'onHostMaintenance': 'TERMINATE',
        'preemptible': False
    },
    'serviceAccounts': [{
        'email': 'default',
        'scopes': [
            'https://www.googleapis.com/auth/devstorage.read_write',
            'https://www.googleapis.com/auth/logging.write'
        ]
    }]
}
  1. create a launch config that uses a image with some size (100GB in this case), and specify a diskSizeGb param of a different size, say 200GB
  2. call compute.instances().insert(project=project, zone=zone, body=config) function with this launch config.
  3. instance launches with a disk of 100GB instead of 200GB...

Thanks!

linzwatt commented 4 years ago

Also, with this launch config, the instance launched with a pd-standard disk instead of a pd-ssd, even though I specified a pd-ssd

linzwatt commented 4 years ago

Nevermind, the diskSizeGb and diskType params are meant to go inside the initialiseParams object..

Sorry if I wasted anyone's time :smile: it is hard to see the proper structure in the docs because it is one giant text blob... would be good if there was some better formatting on this docs page: http://googleapis.github.io/google-api-python-client/docs/dyn/compute_v1.instances.html#insert