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

(DIO-3162) vmpooler gce provider to support disk type (to use ssd) #10

Merged
merged 2 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/vmpooler/providers/gce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,20 @@ def create_vm(pool_name, new_vmname)
network: network_name
)
network_interfaces.subnetwork = subnetwork_name(pool_name) if subnetwork_name(pool_name)
init_params = {
init_params = Google::Apis::ComputeV1::AttachedDiskInitializeParams.new(
source_image: pool['template'], # The source image to create this disk.
labels: { 'vm' => new_vmname, 'pool' => pool_name },
disk_name: "#{new_vmname}-disk0"
}
)
# rubocop:disable Style/IfUnlessModifier
if pool['disk_type'] && !pool['disk_type'].empty?
init_params.disk_type = "https://www.googleapis.com/compute/v1/projects/#{project}/zones/#{zone(pool_name)}/diskTypes/#{pool['disk_type']}"
end
# rubocop:enable Style/IfUnlessModifier
disk = Google::Apis::ComputeV1::AttachedDisk.new(
auto_delete: true,
boot: true,
initialize_params: Google::Apis::ComputeV1::AttachedDiskInitializeParams.new(init_params)
initialize_params: init_params
)
append_domain = domain || global_config[:config]['domain']
fqdn = "#{new_vmname}.#{append_domain}" if append_domain
Expand Down
3 changes: 2 additions & 1 deletion spec/unit/providers/gce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
describe '#manual tests live' do
context 'in itsysops' do
before(:each) { allow(subject).to receive(:dns).and_call_original }
let(:vmname) { "instance-24" }
let(:vmname) { "instance-27" }
let(:project) { 'vmpooler-test' }
let(:config) { YAML.load(<<~EOT
---
Expand All @@ -87,6 +87,7 @@
provider: 'gce'
subnetwork_name: 'projects/itsysopsnetworking/regions/us-west1/subnetworks/vmpooler-test'
machine_type: 'zones/#{zone}/machineTypes/e2-micro'
disk_type: 'pd-ssd'
EOT
) }
skip 'gets a vm' do
Expand Down
4 changes: 4 additions & 0 deletions vmpooler.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
# (optional: default is global provider zone value)
# - machine_type
# Full or partial URL of the machine type resource to use for this instance, in the format: zones/zone/machineTypes/machine-type
# - disk_type
# the disk type to use, see https://cloud.google.com/compute/docs/disks one of
# pd-standard, pd-balanced, pd-ssd or pd-extreme
# (optional, when nil or empty defaults to pd-standard)
# Example:

:pools:
Expand Down