Skip to content

Commit

Permalink
Merge pull request #676 from cloudfoundry/remove_config_disk_support
Browse files Browse the repository at this point in the history
Remove config disk support
  • Loading branch information
rkoster authored Dec 8, 2022
2 parents c82e19f + 5ffcd54 commit be1a3a2
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 386 deletions.
1 change: 0 additions & 1 deletion src/bosh_azure_cpi/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ Style/OpenStructUse:
- 'spec/manual_tests/performance/upload_image.rb'
- 'spec/manual_tests/resource_group_name/helpers.rb'
- 'spec/unit/bosh_release/jobs/cpi/templates/cpi.json.erb_spec.rb'
- 'spec/unit/vm_manager/create/use_config_disk_spec.rb'

# Offense count: 4
# Configuration parameters: AllowedMethods.
Expand Down
1 change: 0 additions & 1 deletion src/bosh_azure_cpi/lib/cloud/azure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ module AzureCloud; end
require 'cloud/azure/disk/vhd_utils'
require 'cloud/azure/storage/blob_manager'
require 'cloud/azure/disk/disk_manager'
require 'cloud/azure/disk/config_disk_manager'
require 'cloud/azure/stemcell/stemcell_manager'
require 'cloud/azure/meta_store/meta_store'
require 'cloud/azure/meta_store/stemcell_meta'
Expand Down
3 changes: 1 addition & 2 deletions src/bosh_azure_cpi/lib/cloud/azure/cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,7 @@ def _init_azure
@disk_manager2 = Bosh::AzureCloud::DiskManager2.new(@azure_client)
@stemcell_manager2 = Bosh::AzureCloud::StemcellManager2.new(@blob_manager, @meta_store, @storage_account_manager, @azure_client)
@light_stemcell_manager = Bosh::AzureCloud::LightStemcellManager.new(@blob_manager, @storage_account_manager, @azure_client)
@config_disk_manager = Bosh::AzureCloud::ConfigDiskManager.new(@blob_manager, @disk_manager2, @storage_account_manager)
@vm_manager = Bosh::AzureCloud::VMManager.new(_azure_config, @registry.endpoint, @disk_manager, @disk_manager2, @azure_client, @storage_account_manager, @stemcell_manager, @stemcell_manager2, @light_stemcell_manager, @config_disk_manager)
@vm_manager = Bosh::AzureCloud::VMManager.new(_azure_config, @registry.endpoint, @disk_manager, @disk_manager2, @azure_client, @storage_account_manager, @stemcell_manager, @stemcell_manager2, @light_stemcell_manager)
@instance_type_mapper = Bosh::AzureCloud::InstanceTypeMapper.new
rescue Net::OpenTimeout => e
cloud_error("Please make sure the CPI has proper network access to Azure. #{e.inspect}") # TODO: Will it throw the error when initializing the client and manager
Expand Down
109 changes: 0 additions & 109 deletions src/bosh_azure_cpi/lib/cloud/azure/disk/config_disk_manager.rb

This file was deleted.

12 changes: 0 additions & 12 deletions src/bosh_azure_cpi/lib/cloud/azure/models/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ def initialize(azure_stack_config_hash)
end
end

# TODO: Refactoring: Move class to new file: ConfigDisk
class ConfigDisk
attr_reader :enabled

def initialize(config_disk_config_hash)
@enabled = config_disk_config_hash['enabled']
end
end

# TODO: Refactoring: Move class to new file: AzureConfig
class AzureConfig
include Helpers
Expand All @@ -84,7 +75,6 @@ class AzureConfig
attr_reader :pip_idle_timeout_in_minutes
attr_reader :parallel_upload_thread_num
attr_reader :ssh_user, :ssh_public_key
attr_reader :config_disk
attr_reader :stemcell_api_version
attr_reader :use_default_account_for_cleaning

Expand Down Expand Up @@ -127,8 +117,6 @@ def initialize(azure_config_hash)
@ssh_user = azure_config_hash['ssh_user']
@ssh_public_key = azure_config_hash['ssh_public_key']

@config_disk = ConfigDisk.new(azure_config_hash.fetch('config_disk', 'enabled' => false))

# Flag to skip looping all storage account in subscription
@use_default_account_for_cleaning = false
@use_default_account_for_cleaning = azure_config_hash['use_default_account_for_cleaning'] unless azure_config_hash['use_default_account_for_cleaning'].nil?
Expand Down
2 changes: 1 addition & 1 deletion src/bosh_azure_cpi/lib/cloud/azure/models/disk_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def disk_name
end

def caching
invalid = !disk_name.start_with?(DATA_DISK_PREFIX, MANAGED_DATA_DISK_PREFIX, MANAGED_CONFIG_DISK_PREFIX)
invalid = !disk_name.start_with?(DATA_DISK_PREFIX, MANAGED_DATA_DISK_PREFIX)
cloud_error('This function should only be called for data disks') if invalid

return _parse_data_disk_caching_plain(@plain_id) unless @plain_id.nil?
Expand Down
12 changes: 0 additions & 12 deletions src/bosh_azure_cpi/lib/cloud/azure/restapi/azure_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,6 @@ def create_virtual_machine(resource_group_name, vm_params, network_interfaces, a
end
end

unless vm_params[:config_disk].nil?
# append the config disk into the vm.
vm['properties']['storageProfile']['dataDisks'] = [] if vm['properties']['storageProfile']['dataDisks'].nil?
vm['properties']['storageProfile']['dataDisks'].push(
'lun' => 1,
'createOption' => 'Attach',
'managedDisk' => {
'id' => vm_params[:config_disk][:id].to_s
}
)
end

unless availability_set.nil?
vm['properties']['availabilitySet'] = {
'id' => availability_set[:id]
Expand Down
6 changes: 3 additions & 3 deletions src/bosh_azure_cpi/lib/cloud/azure/utils/bosh_agent_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def encode_user_data(user_data)
Base64.strict_encode64(JSON.dump(user_data))
end

# Obtain the full VM metadata to write in config disk or custom data.
# Obtain the full VM metadata to write custom data.
#
# As of CPI API version 2, and stemcell API version 2, the registry is bypassed.
# The agent settings are written directly to config disk if used, or the VM's custom data.
# The agent settings are written directly to the VM's custom data.
# The stemcell API version is used to determine compatibility with the agent on the stemcell.
# An updated agent will read the base metadata, and additionally the agent settings, bypassing the registry.
def user_data_obj(registry_endpoint, instance_id, dns, agent_id, network_spec, environment, vm_params, config, computer_name = nil)
Expand Down Expand Up @@ -88,7 +88,7 @@ def meta_data_obj(instance_id, ssh_public_key)
#
# Note:
# As of CPI API version 2, and stemcell API version 2, the registry is bypassed.
# The agent settings are written directly to config disk if used, or the VM's custom data.
# The agent settings are written directly to the VM's custom data.
#
# @param [String] agent_id Agent id (will be picked up by agent to
# assume its identity
Expand Down
1 change: 0 additions & 1 deletion src/bosh_azure_cpi/lib/cloud/azure/utils/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ module Helpers
DATA_DISK_PREFIX = 'bosh-data'
MANAGED_OS_DISK_PREFIX = 'bosh-disk-os'
MANAGED_DATA_DISK_PREFIX = 'bosh-disk-data'
MANAGED_CONFIG_DISK_PREFIX = 'bosh-cfg-disk'
EPHEMERAL_DISK_POSTFIX = 'ephemeral-disk'
STEMCELL_PREFIX = 'bosh-stemcell'
LIGHT_STEMCELL_PREFIX = 'bosh-light-stemcell'
Expand Down
18 changes: 2 additions & 16 deletions src/bosh_azure_cpi/lib/cloud/azure/vms/vm_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ module Bosh::AzureCloud
class VMManager # rubocop:todo Metrics/ClassLength
include Helpers

def initialize(azure_config, registry_endpoint, disk_manager, disk_manager2, azure_client, storage_account_manager, stemcell_manager, stemcell_manager2, light_stemcell_manager, config_disk_manager = nil)
def initialize(azure_config, registry_endpoint, disk_manager, disk_manager2, azure_client, storage_account_manager, stemcell_manager, stemcell_manager2, light_stemcell_manager)
@azure_config = azure_config
@registry_endpoint = registry_endpoint
@config_disk_manager = config_disk_manager
@disk_manager = disk_manager
@disk_manager2 = disk_manager2
@azure_client = azure_client
Expand Down Expand Up @@ -156,16 +155,7 @@ def create(bosh_vm_meta, location, vm_props, disk_cids, network_configurator, en
vm_params[:ssh_username] = @azure_config.ssh_user
vm_params[:ssh_cert_data] = @azure_config.ssh_public_key
user_data = agent_settings.user_data_obj(@registry_endpoint, instance_id.to_s, network_configurator.default_dns, bosh_vm_meta.agent_id, network_spec, env, vm_params, config)
if @azure_config.config_disk.enabled
meta_data_obj = agent_settings.meta_data_obj(
instance_id.to_s,
@azure_config.ssh_public_key
)
config_disk = @config_disk_manager.prepare_config_disk(resource_group_name, vm_name, location, meta_data_obj, user_data)
vm_params[:config_disk] = config_disk
else
vm_params[:custom_data] = agent_settings.encode_user_data(user_data)
end
vm_params[:custom_data] = agent_settings.encode_user_data(user_data)
when 'windows'
# Generate secure random strings as username and password for Windows VMs
# Users do not use this credential to logon to Windows VMs
Expand Down Expand Up @@ -211,8 +201,6 @@ def create(bosh_vm_meta, location, vm_props, disk_cids, network_configurator, en
ephemeral_disk_name = @disk_manager2.generate_ephemeral_disk_name(vm_name)
error_message += "\t Managed Ephemeral Disk: #{ephemeral_disk_name}\n"
end

# TODO: Output message to delete config disk
else
storage_account_name = instance_id.storage_account_name
os_disk_name = @disk_manager.generate_os_disk_name(vm_name)
Expand Down Expand Up @@ -266,8 +254,6 @@ def create(bosh_vm_meta, location, vm_props, disk_cids, network_configurator, en
end
)

# TODO: delete the config disk.

tasks.map(&:wait)
tasks.map(&:wait!)
rescue StandardError => error
Expand Down
5 changes: 1 addition & 4 deletions src/bosh_azure_cpi/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ def mock_cloud_options
'default_security_group' => MOCK_DEFAULT_SECURITY_GROUP,
'debug_mode' => false,
'use_managed_disks' => false,
'request_id' => MOCK_REQUEST_ID,
'config_disk' => {
'enabled' => false
}
'request_id' => MOCK_REQUEST_ID
},
'registry' => {
'endpoint' => 'localhost:42288',
Expand Down
Loading

0 comments on commit be1a3a2

Please sign in to comment.