From 32ce79bfb52ac8487199293e2d733bd1cf0f26b9 Mon Sep 17 00:00:00 2001 From: aram price Date: Fri, 23 Feb 2024 16:46:22 -0800 Subject: [PATCH] Remove PowerDNS The PowerDNS package has not been updated since 2016. This commit removes: - package - job - all config values under `dns` except `domain_name` - models under `src/bosh-director/lib/bosh/director/models/dns/` - all mention or use of `dns_db` which was a separate database configuration for these models [#183367522] --- config/blobs.yml | 4 - jobs/director/spec | 26 -- jobs/director/templates/director.yml.erb | 26 +- jobs/powerdns/monit | 5 - jobs/powerdns/spec | 53 ---- jobs/powerdns/spec.yml | 1 - jobs/powerdns/templates/pdns.conf.erb | 44 --- jobs/powerdns/templates/powerdns_ctl.erb | 37 --- packages/powerdns/packaging | 10 - packages/powerdns/spec | 4 - packages/powerdns/spec.yml | 1 - spec/director.yml.erb_spec.rb | 5 +- src/bosh-dev/lib/bosh/dev/sandbox/main.rb | 7 +- src/bosh-director/bin/bosh-director-migrate | 4 +- .../migrations/dns/20120123234908_initial.rb | 25 -- src/bosh-director/lib/bosh/director.rb | 1 - .../api/controllers/info_controller.rb | 8 - .../lib/bosh/director/cloudcheck_helper.rb | 4 - src/bosh-director/lib/bosh/director/config.rb | 34 +-- .../lib/bosh/director/deployment_deleter.rb | 3 +- .../lib/bosh/director/deployment_plan.rb | 2 - .../director/deployment_plan/assembler.rb | 15 +- .../compilation_instance_pool.rb | 5 +- .../director/deployment_plan/instance_plan.rb | 25 +- .../director/deployment_plan/instance_spec.rb | 2 - .../network_parser/name_servers_parser.rb | 24 -- .../stages/pre_cleanup_stage.rb | 2 +- .../dns/director_dns_state_updater.rb | 4 - .../bosh/director/dns/power_dns_manager.rb | 116 -------- .../lib/bosh/director/dns/powerdns.rb | 133 --------- .../director/errand/instance_group_manager.rb | 1 - .../lib/bosh/director/instance_deleter.rb | 11 +- .../bosh/director/instance_group_updater.rb | 3 +- .../lib/bosh/director/job_runner.rb | 1 - .../lib/bosh/director/jobs/base_job.rb | 4 - .../bosh/director/jobs/delete_deployment.rb | 4 +- .../lib/bosh/director/jobs/vm_state.rb | 5 - .../lib/bosh/director/models/dns.rb | 7 - .../lib/bosh/director/models/dns/domain.rb | 7 - .../lib/bosh/director/models/dns/record.rb | 5 - src/bosh-director/spec/spec_helper.rb | 28 +- .../api/controllers/info_controller_spec.rb | 4 - .../spec/unit/cloudcheck_helper_spec.rb | 11 - .../spec/unit/deployment_deleter_spec.rb | 3 +- .../unit/deployment_plan/assembler_spec.rb | 17 +- .../compilation_instance_pool_spec.rb | 4 +- .../name_servers_parser_spec.rb | 53 +--- .../dns/director_dns_state_updater_spec.rb | 4 - .../spec/unit/dns/power_dns_manager_spec.rb | 277 ------------------ .../spec/unit/dns/powerdns_spec.rb | 109 ------- .../spec/unit/instance_deleter_spec.rb | 33 +-- .../spec/unit/jobs/vm_state_spec.rb | 2 +- .../spec/nats_sync/users_sync_spec.rb | 6 - src/spec/integration/cli_env_spec.rb | 1 - 54 files changed, 31 insertions(+), 1199 deletions(-) delete mode 100644 jobs/powerdns/monit delete mode 100644 jobs/powerdns/spec delete mode 120000 jobs/powerdns/spec.yml delete mode 100644 jobs/powerdns/templates/pdns.conf.erb delete mode 100644 jobs/powerdns/templates/powerdns_ctl.erb delete mode 100644 packages/powerdns/packaging delete mode 100644 packages/powerdns/spec delete mode 120000 packages/powerdns/spec.yml delete mode 100644 src/bosh-director/db/migrations/dns/20120123234908_initial.rb delete mode 100644 src/bosh-director/lib/bosh/director/dns/power_dns_manager.rb delete mode 100644 src/bosh-director/lib/bosh/director/dns/powerdns.rb delete mode 100644 src/bosh-director/lib/bosh/director/models/dns.rb delete mode 100644 src/bosh-director/lib/bosh/director/models/dns/domain.rb delete mode 100644 src/bosh-director/lib/bosh/director/models/dns/record.rb delete mode 100644 src/bosh-director/spec/unit/dns/power_dns_manager_spec.rb delete mode 100644 src/bosh-director/spec/unit/dns/powerdns_spec.rb diff --git a/config/blobs.yml b/config/blobs.yml index ebdecbea94a..5f6e441cf4f 100644 --- a/config/blobs.yml +++ b/config/blobs.yml @@ -30,10 +30,6 @@ postgres/postgresql-15.6.tar.gz: size: 30299236 object_id: 8cc25480-8de8-4f0b-56a2-b359ff6838dc sha: sha256:3a08314af1714671213a8a4f6bd646d0b1cdc94b029e8988944ab04d4b8cf2d2 -powerdns/pdns-static_3.3.1-1_amd64.deb: - size: 9353694 - object_id: 6e861aa6-2e83-4027-a1e8-0ebec995c274 - sha: 22bb46aa0b3e7671e0ee9aa30ed95c38841106ab s3cli/s3cli-0.0.271-linux-amd64: size: 18505101 object_id: c522f7df-db20-4418-6207-f227e7c8874a diff --git a/jobs/director/spec b/jobs/director/spec index e7ae83a91ec..a400117439f 100644 --- a/jobs/director/spec +++ b/jobs/director/spec @@ -336,35 +336,9 @@ properties: default: false # DNS - dns.address: - description: Address of the powerdns server dns.domain_name: description: TLD of the dns zone used by bosh default: bosh - dns.db.adapter: - description: DNS Database adapter - default: postgres - dns.db.user: - description: DNS Database user - default: bosh - dns.db.password: - description: DNS Database password - dns.db.host: - description: DNS Database host - default: 127.0.0.1 - dns.db.port: - description: Port that the powerdns database listens on - default: 5432 - dns.db.database: - description: Name of the powerdns database - default: bosh - dns.db.connection_options: - description: | - Additional options for the powerdns database. - The below default applies to postgres databases. For config options for mysql dbs, refer to the mysql2 gem options. - default: - max_connections: 32 #Maximum size of the connection pool - pool_timeout: 10 #Number of seconds to wait if a connection cannot be acquired before raising an error # Events director.events.record_events: diff --git a/jobs/director/templates/director.yml.erb b/jobs/director/templates/director.yml.erb index c3242017156..0cb567dc676 100644 --- a/jobs/director/templates/director.yml.erb +++ b/jobs/director/templates/director.yml.erb @@ -169,32 +169,10 @@ params['scan_and_fix'] = { 'auto_fix_stateful_nodes' => p('director.auto_fix_stateful_nodes') } -if_p('dns.db.adapter', 'dns.db.user', 'dns.db.password', 'dns.db.host', - 'dns.db.port', 'dns.db.database', 'dns.db.connection_options', 'dns.address') do - |adapter, user, password, db_host, port, database, connection_options, address| +if_p('dns.domain_name') do |domain_name| params['dns'] = { - 'server' => address, - 'flush_command' => '/var/vcap/jobs/powerdns/bin/powerdns_ctl flush', - 'db' => { - 'adapter' => adapter, - 'user' => user, - 'password' => password, - 'host' => db_host, - 'port' => port, - 'database' => database, - 'connection_options' => connection_options - } + 'domain_name' => domain_name } - - if_p('dns.domain_name') do |domain_name| - params['dns']['domain_name'] = domain_name - end -end.else do - if_p('dns.domain_name') do |domain_name| - params['dns'] = { - 'domain_name' => domain_name - } - end end if p('blobstore.provider') == 's3' diff --git a/jobs/powerdns/monit b/jobs/powerdns/monit deleted file mode 100644 index d245938a54a..00000000000 --- a/jobs/powerdns/monit +++ /dev/null @@ -1,5 +0,0 @@ -check process powerdns - with pidfile /var/vcap/sys/run/powerdns/pdns.pid - start program "/var/vcap/jobs/powerdns/bin/powerdns_ctl start" - stop program "/var/vcap/jobs/powerdns/bin/powerdns_ctl stop" - group vcap diff --git a/jobs/powerdns/spec b/jobs/powerdns/spec deleted file mode 100644 index ddc4785438d..00000000000 --- a/jobs/powerdns/spec +++ /dev/null @@ -1,53 +0,0 @@ ---- -name: powerdns - -templates: - pdns.conf.erb: config/pdns.conf - powerdns_ctl.erb: bin/powerdns_ctl - -packages: - - powerdns - -properties: - - dns.db.adapter: - description: Adapter for the PowerDNS database connection - default: postgres - dns.db.user: - description: User for the PowerDNS database connection - default: bosh - dns.db.password: - description: Password for the PowerDNS database connection - dns.db.host: - description: Address for the PowerDNS database - default: 127.0.0.1 - dns.db.port: - description: Port for the PowerDNS database connection - default: 5432 - dns.db.database: - description: Database for the PowerDNS database connection - default: bosh - - dns.distributor_threads: - description: Number of threads to query the backend, for each receiver thread - default: 2 - dns.receiver_threads: - description: Number of sockets the powerdns process will open - default: 2 - dns.recursor: - description: If recursion is desired, IP address of a recursing nameserver (optional) - dns.local_address: - description: IP address to which to bind to (optional; useful with multiple IP addresses) - dns.query_local_address: - description: IP address to use as a source address for sending queries (optional; useful with multiple IP addresses) - dns.address: - description: Address of the primary PowerDNS instance - - dns.webserver.port: - description: TCP port PowerDNS webserver listens on (optional) - default: 8081 - dns.webserver.address: - description: IP address PowerDNS webserver listens on (optional) - default: 0.0.0.0 - dns.webserver.password: - description: Password clients must use to access PowerDNS webserver (optional) diff --git a/jobs/powerdns/spec.yml b/jobs/powerdns/spec.yml deleted file mode 120000 index 15acefd8bbf..00000000000 --- a/jobs/powerdns/spec.yml +++ /dev/null @@ -1 +0,0 @@ -spec \ No newline at end of file diff --git a/jobs/powerdns/templates/pdns.conf.erb b/jobs/powerdns/templates/pdns.conf.erb deleted file mode 100644 index 42abddc69f8..00000000000 --- a/jobs/powerdns/templates/pdns.conf.erb +++ /dev/null @@ -1,44 +0,0 @@ -<% - adapters = { - 'mysql2' => 'gmysql', - 'mysql' => 'gmysql', - 'postgres' => 'gpgsql', - 'sqlite' => 'gsqlite3' - } - db_module = adapters[p('dns.db.adapter')] - raise "unknown adapter #{p('dns.db.adapter')} for powerdns" unless db_module -%> -launch=<%= db_module %> -<%= db_module %>-host=<%= p('dns.db.host') %> -<%= db_module %>-port=<%= p('dns.db.port') %> -<%= db_module %>-user=<%= p('dns.db.user') %> -<%= db_module %>-password=<%= p('dns.db.password') %> -<%= db_module %>-dbname=<%= p('dns.db.database') %> - -config-dir=/var/vcap/jobs/powerdns/config -daemon=yes -distributor-threads=<%= p('dns.distributor_threads') %> -receiver-threads=<%= p('dns.receiver_threads') %> -guardian=no -max-tcp-connections=256 -module-dir=/usr/local/lib -<% if_p('dns.recursor') do |recursor| %> -recursor=<%= recursor %> -<% end %> -<% if_p('dns.local_address') do |local_address| %> -local-address=<%= local_address %> -<% end %> -<% if_p('dns.query_local_address') do |query_local_address| %> -query-local-address=<%= query_local_address %> -<% end %> -setgid=vcap -setuid=vcap -version-string=anonymous -<% if_p('dns.webserver.port', - 'dns.webserver.address', - 'dns.webserver.password') do |web_port, web_address, web_pass| %> -webserver=yes -webserver-port=<%= web_port %> -webserver-address=<%= web_address %> -webserver-password=<%= web_pass %> -<% end %> diff --git a/jobs/powerdns/templates/powerdns_ctl.erb b/jobs/powerdns/templates/powerdns_ctl.erb deleted file mode 100644 index e31ee27db5e..00000000000 --- a/jobs/powerdns/templates/powerdns_ctl.erb +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -RUN_DIR=/var/vcap/sys/run/powerdns -LOG_DIR=/var/vcap/sys/log/powerdns -PIDFILE=$RUN_DIR/pdns.pid - -case $1 in - -start) - mkdir -p $RUN_DIR - mkdir -p $LOG_DIR - - echo $$ > $PIDFILE - - exec /var/vcap/packages/powerdns/pdns_server \ - --socket-dir=$RUN_DIR \ - --config-dir=/var/vcap/jobs/powerdns/config \ - >>$LOG_DIR/powerdns.stdout.log \ - 2>>$LOG_DIR/powerdns.stderr.log - ;; - -stop) - head -1 $PIDFILE | xargs kill - rm -f $PIDFILE - ;; - -flush) - /var/vcap/packages/powerdns/pdns_control \ - --socket-dir=$RUN_DIR \ - --config-dir=/var/vcap/jobs/powerdns/config \ - purge - ;; - -*) - echo "Usage: powerdns_ctl {start|stop|flush}" ;; -esac -exit 0 diff --git a/packages/powerdns/packaging b/packages/powerdns/packaging deleted file mode 100644 index 62ac5405a1a..00000000000 --- a/packages/powerdns/packaging +++ /dev/null @@ -1,10 +0,0 @@ -set -e - -echo "Extracting PowerDNS archive ..." - -mkdir -p target - -ar p powerdns/pdns-static_3.3.1-1_amd64.deb data.tar.gz | tar zx -C target - -cp -a target/usr/sbin/pdns_server ${BOSH_INSTALL_TARGET} -cp -a target/usr/bin/pdns_control ${BOSH_INSTALL_TARGET} diff --git a/packages/powerdns/spec b/packages/powerdns/spec deleted file mode 100644 index 52c6c81f7cd..00000000000 --- a/packages/powerdns/spec +++ /dev/null @@ -1,4 +0,0 @@ ---- -name: powerdns -files: -- powerdns/pdns-static_3.3.1-1_amd64.deb diff --git a/packages/powerdns/spec.yml b/packages/powerdns/spec.yml deleted file mode 120000 index 15acefd8bbf..00000000000 --- a/packages/powerdns/spec.yml +++ /dev/null @@ -1 +0,0 @@ -spec \ No newline at end of file diff --git a/spec/director.yml.erb_spec.rb b/spec/director.yml.erb_spec.rb index 700e442b30c..8b3bc8a711d 100644 --- a/spec/director.yml.erb_spec.rb +++ b/spec/director.yml.erb_spec.rb @@ -184,10 +184,10 @@ end end - context 'when domain name specified without all other dns properties' do + context 'when dns.domain_name specified' do before do merged_manifest_properties['dns'] = { - 'domain_name' => 'domain.name' + 'domain_name' => 'fake.domain.name' } end @@ -617,7 +617,6 @@ let(:erb_yaml) { File.read(File.join(File.dirname(__FILE__), '../jobs/director/templates/director.yml.erb')) } subject(:parsed_yaml) do - binding = Bosh::Template::EvaluationContext.new( { 'job' => {'name' => 'i_like_bosh'}, diff --git a/src/bosh-dev/lib/bosh/dev/sandbox/main.rb b/src/bosh-dev/lib/bosh/dev/sandbox/main.rb index fe56b95cb37..1c3e23dcc59 100644 --- a/src/bosh-dev/lib/bosh/dev/sandbox/main.rb +++ b/src/bosh-dev/lib/bosh/dev/sandbox/main.rb @@ -94,7 +94,6 @@ def initialize(db_opts, debug, test_env_number) @logger.level = ENV.fetch('LOG_LEVEL', 'DEBUG') - @dns_db_path = sandbox_path('director-dns.sqlite') @task_logs_dir = sandbox_path('boshdir/tasks') @blobstore_storage_dir = sandbox_path('bosh_test_blobstore') @verify_multidigest_path = File.join(REPO_ROOT, 'tmp', 'verify-multidigest', 'verify-multidigest') @@ -278,7 +277,6 @@ def stop @sandbox_log_file.close unless @sandbox_log_file == STDOUT - FileUtils.rm_f(dns_db_path) FileUtils.rm_rf(agent_tmp_path) FileUtils.rm_rf(blobstore_storage_dir) end @@ -289,9 +287,8 @@ def run loop { sleep 60 } - # rubocop:disable HandleExceptions rescue Interrupt - # rubocop:enable HandleExceptions + # Ignored ensure stop @logger.info('Stopped sandbox') @@ -580,6 +577,6 @@ def get_nats_client_ca_private_key_path File.join(SANDBOX_ASSETS_DIR, 'nats_server', 'certs', 'rootCA.key') end - attr_reader :director_tmp_path, :dns_db_path, :task_logs_dir + attr_reader :director_tmp_path, :task_logs_dir end end diff --git a/src/bosh-director/bin/bosh-director-migrate b/src/bosh-director/bin/bosh-director-migrate index 0fb50bc2c0d..e5741a2daae 100755 --- a/src/bosh-director/bin/bosh-director-migrate +++ b/src/bosh-director/bin/bosh-director-migrate @@ -25,11 +25,9 @@ director_db = config.db # Configure the singleton for migrations that need access to this config. There does not appear # to be a way to pass additional data or objects into Sequel gem migrations. if director_db.table_exists?(:releases) - config.configure_evil_config_singleton!(preload_db_classes: false) + config.configure_evil_config_singleton! end abort 'Director database config missing from config file' unless director_db -dns_db = config.dns_db DBMigrator.new(director_db, :director).migrate -DBMigrator.new(dns_db, :dns).migrate DBMigrator.new(director_db, :cpi, cpi: config.cpi).migrate diff --git a/src/bosh-director/db/migrations/dns/20120123234908_initial.rb b/src/bosh-director/db/migrations/dns/20120123234908_initial.rb deleted file mode 100644 index 813b34d9bee..00000000000 --- a/src/bosh-director/db/migrations/dns/20120123234908_initial.rb +++ /dev/null @@ -1,25 +0,0 @@ -Sequel.migration do - change do - create_table :domains do - primary_key :id - String :name, :size => 255, :null => false, :unique => true - String :master, :size => 128, :null => true, :default => nil - Integer :last_check, :null => true, :default => nil - String :type, :size => 6, :null => false - Integer :notified_serial, :null => true, :default => nil - String :account, :size=> 40, :null => true, :default => nil - end - - create_table :records do - primary_key :id - String :name, :size => 255, :null => true, :default => nil, :index => true - String :type, :size => 10, :null => true, :default => nil - String :content, :size => 4098, :null => true, :default => nil - Integer :ttl, :null => true, :default => nil - Integer :prio, :null => true, :default => nil - Integer :change_date, :null => true, :default => nil - foreign_key :domain_id, :domains, :on_delete => :cascade, :null => true, :default => nil, :index => true - index [:name, :type] - end - end -end diff --git a/src/bosh-director/lib/bosh/director.rb b/src/bosh-director/lib/bosh/director.rb index f9967aa07c2..b37893e415d 100644 --- a/src/bosh-director/lib/bosh/director.rb +++ b/src/bosh-director/lib/bosh/director.rb @@ -53,7 +53,6 @@ module Director require 'bosh/director/dns/dns_encoder' require 'bosh/director/dns/local_dns_encoder_manager' require 'bosh/director/dns/local_dns_manager' -require 'bosh/director/dns/power_dns_manager' require 'bosh/director/dns/dns_records' require 'bosh/director/errors' require 'bosh/director/ext' diff --git a/src/bosh-director/lib/bosh/director/api/controllers/info_controller.rb b/src/bosh-director/lib/bosh/director/api/controllers/info_controller.rb index 79384e54554..adf14a21421 100644 --- a/src/bosh-director/lib/bosh/director/api/controllers/info_controller.rb +++ b/src/bosh-director/lib/bosh/director/api/controllers/info_controller.rb @@ -3,10 +3,6 @@ module Bosh::Director module Api::Controllers class InfoController < BaseController - def initialize(config) - super(config) - @powerdns_manager = PowerDnsManagerProvider.create - end def requires_authentication? false @@ -27,10 +23,6 @@ def requires_authentication? 'status' => Config.local_dns_enabled?, 'extras' => { 'domain_name' => Config.root_domain }, }, - 'power_dns' => { - 'status' => @powerdns_manager.dns_enabled?, - 'extras' => { 'domain_name' => @powerdns_manager.root_domain }, - }, 'snapshots' => { 'status' => Config.enable_snapshots, }, diff --git a/src/bosh-director/lib/bosh/director/cloudcheck_helper.rb b/src/bosh-director/lib/bosh/director/cloudcheck_helper.rb index d342cfcc9a2..78d5d6d70fe 100644 --- a/src/bosh-director/lib/bosh/director/cloudcheck_helper.rb +++ b/src/bosh-director/lib/bosh/director/cloudcheck_helper.rb @@ -75,7 +75,6 @@ def recreate_vm(instance_model, wait_for_running = true) true, ) - powerdns_manager = PowerDnsManagerProvider.create local_dns_manager = LocalDnsManager.create(Config.root_domain, @logger) dns_names_to_ip = {} @@ -103,11 +102,8 @@ def recreate_vm(instance_model, wait_for_running = true) end @logger.debug("Updating DNS record for instance: #{instance_model.inspect}; to: #{dns_names_to_ip.inspect}") - powerdns_manager.update_dns_record_for_instance(instance_model, dns_names_to_ip) local_dns_manager.update_dns_record_for_instance(instance_plan_to_create) - powerdns_manager.flush_dns_cache - cloud_check_procedure = lambda do blobstore_client = App.instance.blobstores.blobstore diff --git a/src/bosh-director/lib/bosh/director/config.rb b/src/bosh-director/lib/bosh/director/config.rb index db771eaabec..fb2fd23f999 100644 --- a/src/bosh-director/lib/bosh/director/config.rb +++ b/src/bosh-director/lib/bosh/director/config.rb @@ -24,7 +24,6 @@ class << self :default_ssh_options, :default_update_vm_strategy, :dns, - :dns_db, :enable_cpi_resize_disk, :enable_short_lived_nats_bootstrap_credentials, :enable_short_lived_nats_bootstrap_credentials_compilation_vms, @@ -89,7 +88,7 @@ def clear @nats_rpc = nil end - def configure(config, preload_db_classes: true) + def configure(config) @max_vm_create_tries = Integer(config.fetch('max_vm_create_tries', 5)) @flush_arp = config.fetch('flush_arp', false) @@ -173,24 +172,7 @@ def configure(config, preload_db_classes: true) @db_config = config['db'] @db = configure_db(config['db']) - @dns = config['dns'] - if @dns && @dns['db'] - @dns_db = configure_db(@dns['db']) - if @dns_db && preload_db_classes - # Load these constants early. - # These constants are not 'require'd, they are 'autoload'ed - # in models.rb. We're seeing that in 1.9.3 that sometimes - # the constants loaded from one thread are not visible to other threads, - # causing failures. - # These constants cannot be required because they are Sequel model classes - # that refer to database configuration that is only present when the (optional) - # powerdns job is present and configured and points to a valid DB. - # This is an attempt to make sure the constants are loaded - # before forking off to other threads, hopefully eliminating the errors. - Bosh::Director::Models::Dns::Record.class - Bosh::Director::Models::Dns::Domain.class - end - end + @dns = config.fetch('dns', {}) @local_dns_enabled = config.fetch('local_dns', {}).fetch('enabled', false) @local_dns_include_index = config.fetch('local_dns', {}).fetch('include_index', false) @@ -269,8 +251,7 @@ def log_director_start_event(object_type, object_name, context = {}) end def root_domain - dns_config = Config.dns || {} - dns_config.fetch('domain_name', 'bosh') + Config.dns.fetch('domain_name', 'bosh') end def log_dir @@ -535,11 +516,6 @@ def db Config.configure_db(hash['db']) end - def dns_db - dns_db = hash.dig('dns', 'db') - Config.configure_db(dns_db) if dns_db - end - def cpi hash.dig('cloud', 'plugin') end @@ -556,8 +532,8 @@ def director_pool Config.director_pool end - def configure_evil_config_singleton!(preload_db_classes: true) - Config.configure(hash, preload_db_classes: preload_db_classes) + def configure_evil_config_singleton! + Config.configure(hash) end def get_uuid_provider diff --git a/src/bosh-director/lib/bosh/director/deployment_deleter.rb b/src/bosh-director/lib/bosh/director/deployment_deleter.rb index 9e11e3bc1f0..cfe7e203071 100644 --- a/src/bosh-director/lib/bosh/director/deployment_deleter.rb +++ b/src/bosh-director/lib/bosh/director/deployment_deleter.rb @@ -1,10 +1,9 @@ module Bosh::Director class DeploymentDeleter include LockHelper - def initialize(event_log, logger, powerdns_manager, max_threads) + def initialize(event_log, logger, max_threads) @event_log = event_log @logger = logger - @powerdns_manager = powerdns_manager @max_threads = max_threads @variables_interpolator = ConfigServer::VariablesInterpolator.new end diff --git a/src/bosh-director/lib/bosh/director/deployment_plan.rb b/src/bosh-director/lib/bosh/director/deployment_plan.rb index 4dd03474fe5..dd230f91f82 100644 --- a/src/bosh-director/lib/bosh/director/deployment_plan.rb +++ b/src/bosh-director/lib/bosh/director/deployment_plan.rb @@ -64,5 +64,3 @@ module DeploymentPlan require 'bosh/director/deployment_plan/persistent_disk_collection.rb' require 'bosh/director/deployment_plan/merged_cloud_properties.rb' require 'bosh/director/deployment_plan/vm_resources_cache.rb' - -require 'bosh/director/dns/powerdns' diff --git a/src/bosh-director/lib/bosh/director/deployment_plan/assembler.rb b/src/bosh-director/lib/bosh/director/deployment_plan/assembler.rb index b37284938c1..ce8f0af017c 100644 --- a/src/bosh-director/lib/bosh/director/deployment_plan/assembler.rb +++ b/src/bosh-director/lib/bosh/director/deployment_plan/assembler.rb @@ -6,14 +6,13 @@ class DeploymentPlan::Assembler include IpUtil def self.create(deployment_plan, variables_interpolator) - new(deployment_plan, Api::StemcellManager.new, PowerDnsManagerProvider.create, variables_interpolator) + new(deployment_plan, Api::StemcellManager.new, variables_interpolator) end - def initialize(deployment_plan, stemcell_manager, powerdns_manager, variables_interpolator) + def initialize(deployment_plan, stemcell_manager, variables_interpolator) @deployment_plan = deployment_plan @logger = Config.logger @stemcell_manager = stemcell_manager - @powerdns_manager = powerdns_manager @links_manager = Bosh::Director::Links::LinksManager.new(deployment_plan.model.links_serial_id) @variables_interpolator = variables_interpolator end @@ -208,16 +207,6 @@ def bind_stemcells end end - def bind_dns - @powerdns_manager.configure_nameserver - end - - def migrate_legacy_dns_records - @deployment_plan.instance_models.each do |instance_model| - @powerdns_manager.migrate_legacy_records(instance_model) - end - end - def resolve_network_plans_for_create_swap_deleted_instances(desired_instance_groups) network_planner = DeploymentPlan::NetworkPlanner::Planner.new(@logger) diff --git a/src/bosh-director/lib/bosh/director/deployment_plan/compilation_instance_pool.rb b/src/bosh-director/lib/bosh/director/deployment_plan/compilation_instance_pool.rb index 6181037b24a..333218c53f4 100644 --- a/src/bosh-director/lib/bosh/director/deployment_plan/compilation_instance_pool.rb +++ b/src/bosh-director/lib/bosh/director/deployment_plan/compilation_instance_pool.rb @@ -17,10 +17,7 @@ def create(deployment_plan) private def make_instance_deleter(logger) - Bosh::Director::InstanceDeleter.new( - PowerDnsManagerProvider.create, - DiskManager.new(logger), - ) + Bosh::Director::InstanceDeleter.new(DiskManager.new(logger)) end def make_instance_provider(logger, deployment_plan) diff --git a/src/bosh-director/lib/bosh/director/deployment_plan/instance_plan.rb b/src/bosh-director/lib/bosh/director/deployment_plan/instance_plan.rb index 6346577b1f8..a729f5d7717 100644 --- a/src/bosh-director/lib/bosh/director/deployment_plan/instance_plan.rb +++ b/src/bosh-director/lib/bosh/director/deployment_plan/instance_plan.rb @@ -35,7 +35,6 @@ def initialize(existing_instance:, @link_provider_intents = link_provider_intents @logger = logger @tags = tags - @powerdns_manager = PowerDnsManagerProvider.create @variables_interpolator = variables_interpolator end @@ -207,28 +206,12 @@ def state_changed? end def dns_changed? - power_dns_changed = false - - if @powerdns_manager.dns_enabled? - power_dns_changed = network_settings.dns_record_info.any? do |name, ip| - not_found = @powerdns_manager.find_dns_record(name, ip).nil? - - if not_found - @logger.debug( - "#{__method__} The requested dns record with name '#{name}' " \ - "and ip '#{ip}' was not found in the db.", - ) - end - - not_found - end - end - diff = LocalDnsRecordsRepo.new(@logger, Config.root_domain).diff(self) if diff.changes? log_changes(:local_dns_changed?, diff.obsolete + diff.unaffected, diff.unaffected + diff.missing, instance) end - power_dns_changed || diff.changes? + + diff.changes? end def configuration_changed? @@ -327,10 +310,6 @@ def link_network_addresses(link_def, prefer_dns_entry) network_settings.link_network_addresses(link_def, prefer_dns_entry) end - def root_domain - @powerdns_manager.root_domain - end - def needs_shutting_down? obsolete? || recreate_for_non_network_reasons? || networks_changed? || network_settings_changed? end diff --git a/src/bosh-director/lib/bosh/director/deployment_plan/instance_spec.rb b/src/bosh-director/lib/bosh/director/deployment_plan/instance_spec.rb index 5bb2b8febc4..44faf594a06 100644 --- a/src/bosh-director/lib/bosh/director/deployment_plan/instance_spec.rb +++ b/src/bosh-director/lib/bosh/director/deployment_plan/instance_spec.rb @@ -13,7 +13,6 @@ def self.create_from_instance_plan(instance_plan) instance = instance_plan.instance deployment_name = instance.deployment_model.name instance_group = instance_plan.desired_instance.instance_group - powerdns_manager = PowerDnsManagerProvider.create spec = { 'deployment' => deployment_name, @@ -32,7 +31,6 @@ def self.create_from_instance_plan(instance_plan) 'packages' => instance_group.package_spec, 'properties' => instance_group.properties, 'properties_need_filtering' => true, - 'dns_domain_name' => powerdns_manager.root_domain, 'address' => instance_plan.network_address, 'update' => instance_group.update_spec } diff --git a/src/bosh-director/lib/bosh/director/deployment_plan/network_parser/name_servers_parser.rb b/src/bosh-director/lib/bosh/director/deployment_plan/network_parser/name_servers_parser.rb index e0658404b72..47cbaa9bad1 100644 --- a/src/bosh-director/lib/bosh/director/deployment_plan/network_parser/name_servers_parser.rb +++ b/src/bosh-director/lib/bosh/director/deployment_plan/network_parser/name_servers_parser.rb @@ -2,15 +2,8 @@ module Bosh::Director module DeploymentPlan module NetworkParser class NameServersParser - include ValidationHelper - def initialize() - dns_config = Config.dns || {} - @include_power_dns_server_addr = !!Config.dns_db - @default_server = dns_config['server'] - end - def parse(network, subnet_properties) dns_spec = safe_property(subnet_properties, 'dns', :class => Array, :optional => true) @@ -29,23 +22,6 @@ def parse(network, subnet_properties) end end - if @include_power_dns_server_addr - return add_default_dns_server(servers) - end - - servers - end - - private - - # add default dns server to an array of dns servers - def add_default_dns_server(servers) - - unless @default_server.to_s.empty? || @default_server == '127.0.0.1' - (servers ||= []) << @default_server - servers.uniq! - end - servers end end diff --git a/src/bosh-director/lib/bosh/director/deployment_plan/stages/pre_cleanup_stage.rb b/src/bosh-director/lib/bosh/director/deployment_plan/stages/pre_cleanup_stage.rb index 0321f6276ba..8ad9afc207c 100644 --- a/src/bosh-director/lib/bosh/director/deployment_plan/stages/pre_cleanup_stage.rb +++ b/src/bosh-director/lib/bosh/director/deployment_plan/stages/pre_cleanup_stage.rb @@ -20,7 +20,7 @@ def delete_instances_for_obsolete_instance_groups if !obsolete_plans.empty? event_log_stage = Config.event_log.begin_stage('Deleting unneeded instances', obsolete_plans.size) - instance_deleter = InstanceDeleter.new(PowerDnsManagerProvider.create, DiskManager.new(@logger)) + instance_deleter = InstanceDeleter.new(DiskManager.new(@logger)) instance_deleter.delete_instance_plans(obsolete_plans, event_log_stage) @logger.info('Deleted no longer needed instances') diff --git a/src/bosh-director/lib/bosh/director/dns/director_dns_state_updater.rb b/src/bosh-director/lib/bosh/director/dns/director_dns_state_updater.rb index 8e573fd00f3..e9e57174e2f 100644 --- a/src/bosh-director/lib/bosh/director/dns/director_dns_state_updater.rb +++ b/src/bosh-director/lib/bosh/director/dns/director_dns_state_updater.rb @@ -1,15 +1,11 @@ module Bosh::Director class DirectorDnsStateUpdater def initialize - @powerdns_manager = PowerDnsManagerProvider.create @local_dns_manager = LocalDnsManager.create(Config.root_domain, Config.logger) end def update_dns_for_instance(instance_plan, dns_record_info) - @powerdns_manager.update_dns_record_for_instance(instance_plan.instance.model, dns_record_info) @local_dns_manager.update_dns_record_for_instance(instance_plan) - - @powerdns_manager.flush_dns_cache end end end diff --git a/src/bosh-director/lib/bosh/director/dns/power_dns_manager.rb b/src/bosh-director/lib/bosh/director/dns/power_dns_manager.rb deleted file mode 100644 index 324f7d41d3f..00000000000 --- a/src/bosh-director/lib/bosh/director/dns/power_dns_manager.rb +++ /dev/null @@ -1,116 +0,0 @@ -module Bosh::Director - class PowerDnsManagerProvider - def self.create - dns_config = Config.dns || {} - - logger = Config.logger - root_domain = Config.root_domain - - dns_provider = PowerDns.new(root_domain, logger) if !!Config.dns_db - PowerDnsManager.new(root_domain, dns_config, dns_provider, logger) - end - end - - class PowerDnsManager - attr_reader :root_domain - - def initialize(root_domain, dns_config, dns_provider, logger) - @root_domain = root_domain - @dns_provider = dns_provider - @flush_command = dns_config['flush_command'] - @ip_address = dns_config['address'] - @logger = logger - end - - def dns_enabled? - !@dns_provider.nil? - end - - def configure_nameserver - @dns_provider.create_or_update_nameserver(@ip_address) if dns_enabled? - end - - def find_dns_record(dns_record_name, ip_address) - @dns_provider.find_dns_record(dns_record_name, ip_address) - end - - def update_dns_record_for_instance(instance_model, dns_names_to_ip) - current_dns_records = find_dns_record_names_by_instance(instance_model) - new_dns_records = [] - dns_names_to_ip.each do |record_name, ip_address| - new_dns_records << record_name - if dns_enabled? - @logger.info("Updating DNS for: #{record_name} to #{ip_address}") - @dns_provider.create_or_update_dns_records(record_name, ip_address) - end - end - dns_records = (current_dns_records + new_dns_records).uniq - instance_model.update(dns_record_names: dns_records) - end - - def migrate_legacy_records(instance_model) - return if find_dns_record_names_by_instance(instance_model).any? - return unless dns_enabled? - - index_pattern_for_all_networks = DnsNameGenerator.dns_record_name( - instance_model.index, - instance_model.job, - '%', - instance_model.deployment.name, - @root_domain - ) - uuid_pattern_for_all_networks = DnsNameGenerator.dns_record_name( - instance_model.uuid, - instance_model.job, - '%', - instance_model.deployment.name, - @root_domain - ) - - legacy_record_names = [index_pattern_for_all_networks, uuid_pattern_for_all_networks] - .map { |pattern| @dns_provider.find_dns_records_by_pattern(pattern) } - .flatten - .map(&:name) - - instance_model.update(dns_record_names: legacy_record_names) - end - - def delete_dns_for_instance(instance_model) - if dns_enabled? - current_dns_records = find_dns_record_names_by_instance(instance_model) - if current_dns_records.empty? - # for backwards compatibility when old instances - # did not have records in local repo - # we cannot migrate them because powerdns can be different database - # those instance only had index-based dns records (before global-net) - index_record_pattern = DnsNameGenerator.dns_record_name(instance_model.index, instance_model.job, '%', instance_model.deployment.name, @root_domain) - @dns_provider.delete(index_record_pattern) - return - end - - current_dns_records.each do |record_name| - @logger.info("Removing DNS for: #{record_name}") - @dns_provider.delete(record_name) - end - end - - instance_model.update(dns_record_names: []) - end - - # Purge cached DNS records - def flush_dns_cache - if @flush_command && !@flush_command.empty? - stdout, stderr, status = Open3.capture3(@flush_command) - if status == 0 - @logger.debug("Flushed #{stdout.chomp} records from DNS cache") - else - @logger.warn("Failed to flush DNS cache: #{stderr.chomp}") - end - end - end - - def find_dns_record_names_by_instance(instance_model) - instance_model.nil? ? [] : instance_model.dns_record_names.to_a.compact - end - end -end diff --git a/src/bosh-director/lib/bosh/director/dns/powerdns.rb b/src/bosh-director/lib/bosh/director/dns/powerdns.rb deleted file mode 100644 index 9c6f4ac4c9e..00000000000 --- a/src/bosh-director/lib/bosh/director/dns/powerdns.rb +++ /dev/null @@ -1,133 +0,0 @@ -module Bosh::Director - class PowerDns - SOA = 'localhost hostmaster@localhost 0 10800 604800 30' - TTL_5M = 300 - TTL_4H = 3600 * 4 - TTL_5H = 3600 * 5 - - def initialize(domain_name, logger) - @domain_name = domain_name - @logger = logger - end - - def find_dns_record(dns_record_name, ip_address) - Models::Dns::Record.find(name: dns_record_name, type: 'A', content: ip_address) - end - - def find_dns_records_by_ip(ip_address) - domain_id = find_domain_id - return [] unless domain_id - - Models::Dns::Record.filter(domain_id: domain_id, type: 'A', content: ip_address) - end - - def create_or_update_nameserver(ip_address) - create_or_update_domain - create_or_update_record(@domain_name, SOA, TTL_5M, 'SOA') - create_or_update_record(@domain_name, "ns.#{@domain_name}", TTL_4H, 'NS') - create_or_update_record("ns.#{@domain_name}", ip_address, TTL_5H, 'A') - end - - def create_or_update_dns_records(dns_record_name, ip_address) - create_or_update_record(dns_record_name, ip_address, TTL_5M, 'A') - update_ptr_record(dns_record_name, ip_address) - end - - def find_dns_records_by_pattern(record_pattern) - records = Models::Dns::Record.grep(:name, record_pattern) - records.filter(:domain_id => find_domain_id).all - end - - def delete(record_pattern) - records = find_dns_records_by_pattern(record_pattern) - - # delete A records and collect all IPs for later - ips = [] - records.each do |record| - ips << record.content - Models::Dns::Record.grep(:content, record.name).each do |ptr| - @logger.info("Deleting reverse DNS record: #{ptr.name} -> #{ptr.content}") - ptr.destroy - end - @logger.info("Deleting DNS record: #{record.name}") - record.destroy - end - end - - private - - def create_or_update_domain - Models::Dns::Domain.safe_find_or_create(name: @domain_name, type: 'NATIVE') - end - - def create_or_update_record(dns_record_name, ip_address, ttl, type) - record = Models::Dns::Record.find(name: dns_record_name, type: type) - if record.nil? - domain = create_or_update_domain - record = Models::Dns::Record.new(domain_id: domain.id, - name: dns_record_name, type: type, - ttl: ttl) - end - record.content = ip_address - record.change_date = Time.now.to_i - record.save - end - - # create/update DNS PTR records (for reverse lookups) - def update_ptr_record(record_name, ip_address) - reverse_domain = reverse_domain(ip_address) - reverse_host = reverse_host(ip_address) - - rdomain = Models::Dns::Domain.safe_find_or_create(name: reverse_domain, type: 'NATIVE') - - Models::Dns::Record.find_or_create( - domain: rdomain, - name: reverse_domain, - type: 'SOA', content: SOA, - ttl: TTL_4H - ) - - Models::Dns::Record.find_or_create( - domain: rdomain, - name: reverse_domain, - type: 'NS', ttl: TTL_4H, - content: "ns.#{@domain_name}" - ) - - record = Models::Dns::Record.find_or_create(content: record_name, type: 'PTR') - record.update( - domain: rdomain, - name: reverse_host, - content: record_name, - type: 'PTR', - ttl: TTL_5M, - change_date: Time.now.to_i - ) - end - - def find_domain_id - dns_domain = Models::Dns::Domain.find( - :name => @domain_name, - :type => 'NATIVE', - ) - dns_domain.nil? ? nil : dns_domain.id - end - - # @param [String] ip IP address - # @return [String] reverse dns name for an IP used for a PTR record - def reverse_host(ip) - reverse(ip, 4) - end - - # @param [String] ip IP address - # @return [String] reverse dns domain name for an IP - def reverse_domain(ip) - reverse(ip, 3) - end - - def reverse(ip, n) - octets = ip.split(/\./) - "#{octets[0..(n-1)].reverse.join(".")}.in-addr.arpa" - end - end -end diff --git a/src/bosh-director/lib/bosh/director/errand/instance_group_manager.rb b/src/bosh-director/lib/bosh/director/errand/instance_group_manager.rb index f1eec07223a..2d580884313 100644 --- a/src/bosh-director/lib/bosh/director/errand/instance_group_manager.rb +++ b/src/bosh-director/lib/bosh/director/errand/instance_group_manager.rb @@ -11,7 +11,6 @@ def initialize(deployment_planner, instance_group, logger) @deployment_planner.use_short_dns_addresses?, @deployment_planner.use_link_dns_names?, ) - @powerdns_manager = PowerDnsManagerProvider.create @vm_deleter = VmDeleter.new(logger, false, Config.enable_virtual_delete_vms) @vm_creator = VmCreator.new( logger, diff --git a/src/bosh-director/lib/bosh/director/instance_deleter.rb b/src/bosh-director/lib/bosh/director/instance_deleter.rb index 404d244afeb..440e431cbc8 100644 --- a/src/bosh-director/lib/bosh/director/instance_deleter.rb +++ b/src/bosh-director/lib/bosh/director/instance_deleter.rb @@ -1,8 +1,7 @@ module Bosh::Director # Coordinates the safe deletion of an instance and all associates resources. class InstanceDeleter - def initialize(powerdns_manager, disk_manager, options = {}) - @powerdns_manager = powerdns_manager + def initialize(disk_manager, options = {}) @disk_manager = disk_manager @logger = Config.logger @local_dns_manager = LocalDnsManager.create(Config.root_domain, @logger) @@ -33,14 +32,6 @@ def delete_instance_plan(instance_plan, event_log_stage) @disk_manager.delete_persistent_disks(instance_model) end - error_ignorer.with_force_check do - @powerdns_manager.delete_dns_for_instance(instance_model) - end - - error_ignorer.with_force_check do - @local_dns_manager.delete_dns_for_instance(instance_model) - end - error_ignorer.with_force_check do RenderedJobTemplatesCleaner.new(instance_model, @blobstore, @logger).clean_all end diff --git a/src/bosh-director/lib/bosh/director/instance_group_updater.rb b/src/bosh-director/lib/bosh/director/instance_group_updater.rb index a5d30b4798d..0e48aa9a4cb 100644 --- a/src/bosh-director/lib/bosh/director/instance_group_updater.rb +++ b/src/bosh-director/lib/bosh/director/instance_group_updater.rb @@ -135,8 +135,7 @@ def delete_unneeded_instances [@instance_group.name], ) - powerdns_manager = PowerDnsManagerProvider.create - deleter = InstanceDeleter.new(powerdns_manager, @disk_manager) + deleter = InstanceDeleter.new(@disk_manager) deleter.delete_instance_plans( unneeded_instance_plans, diff --git a/src/bosh-director/lib/bosh/director/job_runner.rb b/src/bosh-director/lib/bosh/director/job_runner.rb index 3cb2349fc5f..c2dcf8a73d3 100644 --- a/src/bosh-director/lib/bosh/director/job_runner.rb +++ b/src/bosh-director/lib/bosh/director/job_runner.rb @@ -60,7 +60,6 @@ def setup_task_logging_for_files Config.logger = @task_logger Config.db.logger = @task_logger - Config.dns_db.logger = @task_logger if Config.dns_db cpi_log = File.join(log_dir, 'cpi') Config.cloud_options['properties'] ||= {} diff --git a/src/bosh-director/lib/bosh/director/jobs/base_job.rb b/src/bosh-director/lib/bosh/director/jobs/base_job.rb index 63dd03475d4..b139b86465a 100644 --- a/src/bosh-director/lib/bosh/director/jobs/base_job.rb +++ b/src/bosh-director/lib/bosh/director/jobs/base_job.rb @@ -23,10 +23,6 @@ def task_result @task_result ||= Config.result end - def powerdns_manager - @powerdns_manager ||= PowerDnsManagerProvider.create - end - def dry_run? false end diff --git a/src/bosh-director/lib/bosh/director/jobs/delete_deployment.rb b/src/bosh-director/lib/bosh/director/jobs/delete_deployment.rb index cef54a7d5e9..df113996a7b 100644 --- a/src/bosh-director/lib/bosh/director/jobs/delete_deployment.rb +++ b/src/bosh-director/lib/bosh/director/jobs/delete_deployment.rb @@ -24,15 +24,13 @@ def perform fail_if_ignored_instances_found(deployment_model) - powerdns_manager = PowerDnsManagerProvider.create disk_manager = DiskManager.new(logger) instance_deleter = InstanceDeleter.new( - powerdns_manager, disk_manager, force: @force, stop_intent: :delete_deployment, ) - deployment_deleter = DeploymentDeleter.new(Config.event_log, logger, powerdns_manager, Config.max_threads) + deployment_deleter = DeploymentDeleter.new(Config.event_log, logger, Config.max_threads) vm_deleter = Bosh::Director::VmDeleter.new(logger, @force, Config.enable_virtual_delete_vms) deployment_deleter.delete(deployment_model, instance_deleter, vm_deleter) diff --git a/src/bosh-director/lib/bosh/director/jobs/vm_state.rb b/src/bosh-director/lib/bosh/director/jobs/vm_state.rb index e7b8dc1bf2a..85209f4b8e2 100644 --- a/src/bosh-director/lib/bosh/director/jobs/vm_state.rb +++ b/src/bosh-director/lib/bosh/director/jobs/vm_state.rb @@ -50,11 +50,6 @@ def process_vm_for_instance(instance, vm) job_state, job_vitals, processes, _ = vm_details(vm) - if powerdns_manager.dns_enabled? - dns_records = powerdns_manager.find_dns_record_names_by_instance(instance) - dns_records.sort_by! { |name| -(name.split('.').first.length) } - end - vm_type_name = instance.spec_p('vm_type.name') { diff --git a/src/bosh-director/lib/bosh/director/models/dns.rb b/src/bosh-director/lib/bosh/director/models/dns.rb deleted file mode 100644 index 94c568a0cc9..00000000000 --- a/src/bosh-director/lib/bosh/director/models/dns.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "bosh/director/models/dns/domain" -require "bosh/director/models/dns/record" - -module Bosh::Director::Models - module Dns - end -end diff --git a/src/bosh-director/lib/bosh/director/models/dns/domain.rb b/src/bosh-director/lib/bosh/director/models/dns/domain.rb deleted file mode 100644 index ed112fcf92b..00000000000 --- a/src/bosh-director/lib/bosh/director/models/dns/domain.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Bosh::Director::Models::Dns - class Domain < Sequel::Model(Bosh::Director::Config.dns_db) - extend Bosh::Director::ModelHelper - - one_to_many :records - end -end diff --git a/src/bosh-director/lib/bosh/director/models/dns/record.rb b/src/bosh-director/lib/bosh/director/models/dns/record.rb deleted file mode 100644 index 2385780ab64..00000000000 --- a/src/bosh-director/lib/bosh/director/models/dns/record.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Bosh::Director::Models::Dns - class Record < Sequel::Model(Bosh::Director::Config.dns_db) - many_to_one :domain - end -end diff --git a/src/bosh-director/spec/spec_helper.rb b/src/bosh-director/spec/spec_helper.rb index 17c83c17780..f2fb1903605 100644 --- a/src/bosh-director/spec/spec_helper.rb +++ b/src/bosh-director/spec/spec_helper.rb @@ -121,7 +121,6 @@ def init_database @init_logger, db_options, ) - @dns_db_helper = Bosh::Dev::Sandbox::Postgresql.new("#{@db_name}_dns", Bosh::Core::Shell.new, @init_logger, db_options) when 'mysql' require File.expand_path('../../bosh-dev/lib/bosh/dev/sandbox/mysql', File.dirname(__FILE__)) db_options[:port] = 3306 @@ -132,19 +131,15 @@ def init_database @init_logger, db_options, ) - @dns_db_helper = Bosh::Dev::Sandbox::Mysql.new("#{@db_name}_dns", Bosh::Core::Shell.new, @init_logger, db_options) when 'sqlite' require File.expand_path('../../bosh-dev/lib/bosh/dev/sandbox/sqlite', File.dirname(__FILE__)) @director_db_helper = Bosh::Dev::Sandbox::Sqlite.new(File.join(@temp_dir, "#{@db_name}_director.sqlite"), @init_logger) - @dns_db_helper = Bosh::Dev::Sandbox::Sqlite.new(File.join(@temp_dir, "#{@db_name}_dns.sqlite"), @init_logger) else raise "Unsupported DB value: #{ENV['DB']}" end @director_db_helper.create_db - @dns_db_helper.create_db - @dns_migrations = File.expand_path('../db/migrations/dns', __dir__) @director_migrations = File.expand_path('../db/migrations/director', __dir__) Sequel.extension :migration @@ -165,11 +160,6 @@ def connect_database @director_db.loggers << (logger || @init_logger) @director_db.log_connection_info = true Bosh::Director::Config.db = @director_db - - @dns_db = Sequel.connect(@dns_db_helper.connection_string, db_opts) - @dns_db.loggers << (logger || @init_logger) - @dns_db.log_connection_info = true - Bosh::Director::Config.dns_db = @dns_db end def disconnect_database @@ -180,18 +170,9 @@ def disconnect_database @director_db = nil @director_db_helper = nil end - - return unless @dns_db - - @dns_db.disconnect - @dns_db_helper.drop_db - - @dns_db = nil - @dns_db_helper = nil end def run_migrations - Sequel::Migrator.apply(@dns_db, @dns_migrations, nil) Sequel::Migrator.apply(@director_db, @director_migrations, nil) end @@ -205,17 +186,11 @@ def setup_datasets c = Delayed::Backend::Sequel.const_get(e) c.dataset = @director_db[c.simple_table.gsub(/[`"]/, '').to_sym] if c.is_a?(Class) && c.ancestors.include?(Sequel::Model) end - - Bosh::Director::Models::Dns.constants.each do |e| - c = Bosh::Director::Models::Dns.const_get(e) - c.dataset = @dns_db[c.simple_table.gsub(/[`"]/, '').to_sym] if c.is_a?(Class) && c.ancestors.include?(Sequel::Model) - end end def reset(logger) Bosh::Director::Config.clear Bosh::Director::Config.db = @director_db - Bosh::Director::Config.dns_db = @dns_db Bosh::Director::Config.logger = logger Bosh::Director::Config.trusted_certs = '' Bosh::Director::Config.max_threads = 1 @@ -225,7 +200,7 @@ def reset_database(example) if example.metadata[:truncation] && ENV.fetch('DB', 'sqlite') != 'sqlite' example.run else - Sequel.transaction([@director_db, @dns_db], rollback: :always, auto_savepoint: true) do + Sequel.transaction([@director_db], rollback: :always, auto_savepoint: true) do example.run end end @@ -235,7 +210,6 @@ def reset_database(example) return unless example.metadata[:truncation] @director_db_helper.truncate_db - @dns_db_helper.truncate_db end end end diff --git a/src/bosh-director/spec/unit/api/controllers/info_controller_spec.rb b/src/bosh-director/spec/unit/api/controllers/info_controller_spec.rb index 3e79d451e7c..0886259c7df 100644 --- a/src/bosh-director/spec/unit/api/controllers/info_controller_spec.rb +++ b/src/bosh-director/spec/unit/api/controllers/info_controller_spec.rb @@ -81,10 +81,6 @@ module Api 'status' => true, 'extras' => { 'domain_name' => 'bosh' }, }, - 'power_dns' => { - 'status' => true, - 'extras' => { 'domain_name' => 'bosh' }, - }, 'snapshots' => { 'status' => false, }, diff --git a/src/bosh-director/spec/unit/cloudcheck_helper_spec.rb b/src/bosh-director/spec/unit/cloudcheck_helper_spec.rb index 372d6dc92a9..63bc91f9059 100644 --- a/src/bosh-director/spec/unit/cloudcheck_helper_spec.rb +++ b/src/bosh-director/spec/unit/cloudcheck_helper_spec.rb @@ -61,7 +61,6 @@ def initialize(instance_uuid, data) let(:agent_client) { instance_double(AgentClient) } let(:event_manager) { Api::EventManager.new(true) } let(:update_job) { instance_double(Bosh::Director::Jobs::UpdateDeployment, username: 'user', task_id: 42, event_manager: event_manager) } - let(:powerdns_manager) { instance_double(PowerDnsManager) } let(:rendered_templates_persister) { instance_double(RenderedTemplatesPersister) } let(:planner) do @@ -241,7 +240,6 @@ def fake_job_context before do BD::Models::Stemcell.make(name: 'stemcell-name', version: '3.0.2', cid: 'sc-302') instance.update(spec: spec) - allow(PowerDnsManagerProvider).to receive(:create).and_return(powerdns_manager) end context 'recreates the vm' do @@ -276,15 +274,6 @@ def expect_vm_gets_created expect(Bosh::Director::DnsNameGenerator).to receive(:dns_record_name).with(0, 'mysql_node', 'ip', deployment_model.name, 'bosh').and_return('index.record.name') expect(Bosh::Director::DnsNameGenerator).to receive(:dns_record_name).with(instance.uuid, 'mysql_node', 'ip', deployment_model.name, 'bosh').and_return('uuid.record.name') - expect(powerdns_manager).to receive(:update_dns_record_for_instance).with( - instance, - { - 'index.record.name' => nil, - 'uuid.record.name' => nil, - }, - ) - expect(powerdns_manager).to receive(:flush_dns_cache) - expect(template_cache).to receive(:clean_cache!) end diff --git a/src/bosh-director/spec/unit/deployment_deleter_spec.rb b/src/bosh-director/spec/unit/deployment_deleter_spec.rb index 0de8e83d726..83151773f0e 100644 --- a/src/bosh-director/spec/unit/deployment_deleter_spec.rb +++ b/src/bosh-director/spec/unit/deployment_deleter_spec.rb @@ -2,14 +2,13 @@ module Bosh::Director describe DeploymentDeleter do - subject(:deleter) { described_class.new(event_log, logger, powerdns_manager, 3) } + subject(:deleter) { described_class.new(event_log, logger, 3) } before do allow(App).to receive_message_chain(:instance, :blobstores, :blobstore).and_return(blobstore) end let(:blobstore) { instance_double(Bosh::Blobstore::Client) } let(:instance_deleter) { instance_double(InstanceDeleter) } let(:vm_deleter) { instance_double(VmDeleter) } - let(:powerdns_manager) { instance_double(PowerDnsManager) } let(:dns_enabled) { false } let(:task) { Models::Task.make(id: 42) } let(:task_writer) { Bosh::Director::TaskDBWriter.new(:event_output, task.id) } diff --git a/src/bosh-director/spec/unit/deployment_plan/assembler_spec.rb b/src/bosh-director/spec/unit/deployment_plan/assembler_spec.rb index 2620ce9d3b5..74fd3538266 100644 --- a/src/bosh-director/spec/unit/deployment_plan/assembler_spec.rb +++ b/src/bosh-director/spec/unit/deployment_plan/assembler_spec.rb @@ -2,7 +2,7 @@ module Bosh::Director describe DeploymentPlan::Assembler do - subject(:assembler) { DeploymentPlan::Assembler.new(deployment_plan, stemcell_manager, powerdns_manager, variables_interpolator) } + subject(:assembler) { DeploymentPlan::Assembler.new(deployment_plan, stemcell_manager, variables_interpolator) } let(:deployment_plan) do instance_double( Bosh::Director::DeploymentPlan::Planner, @@ -16,9 +16,7 @@ module Bosh::Director end let(:variables) { Bosh::Director::DeploymentPlan::Variables.new(nil) } - let(:deployment_model) {BD::Models::Deployment.make} let(:stemcell_manager) {nil} - let(:powerdns_manager) {PowerDnsManagerProvider.create} let(:event_log) {Config.event_log} let(:links_manager) do instance_double(Bosh::Director::Links::LinksManager).tap do |double| @@ -82,13 +80,6 @@ module Bosh::Director end end - describe 'migrate_legacy_dns_records' do - it 'migrates legacy dns records' do - expect(powerdns_manager).to receive(:migrate_legacy_records).with(instance_model) - assembler.bind_models - end - end - it 'should bind stemcells' do sc1 = DeploymentPlan::Stemcell.make sc2 = DeploymentPlan::Stemcell.make(os: 'arch-linux') @@ -550,11 +541,6 @@ def make_instance_group(name, template_name) end end - it 'configures dns' do - expect(powerdns_manager).to receive(:configure_nameserver) - assembler.bind_models - end - it 'passes fix into the state_migrator' do allow(deployment_plan).to receive(:deployment_wide_options).and_return(fix: true) instance_model_to_override = instance_double( @@ -579,7 +565,6 @@ def make_instance_group(name, template_name) expect(DeploymentPlan::Assembler).to receive(:new).with( deployment_plan, an_instance_of(Api::StemcellManager), - an_instance_of(PowerDnsManager), variables_interpolator, ).and_call_original diff --git a/src/bosh-director/spec/unit/deployment_plan/compilation_instance_pool_spec.rb b/src/bosh-director/spec/unit/deployment_plan/compilation_instance_pool_spec.rb index 68fa29ca922..6c7951f103a 100644 --- a/src/bosh-director/spec/unit/deployment_plan/compilation_instance_pool_spec.rb +++ b/src/bosh-director/spec/unit/deployment_plan/compilation_instance_pool_spec.rb @@ -594,7 +594,6 @@ module Bosh::Director let(:instance_reuser) { InstanceReuser.new } let(:disk_manager) { DiskManager.new(logger) } let(:agent_broadcaster) { AgentBroadcaster.new } - let(:powerdns_manager) { PowerDnsManagerProvider.create } let(:vm_deleter) { instance_double('Bosh::Director::VmDeleter') } let(:vm_creator) { instance_double('Bosh::Director::VmCreator') } let(:instance_deleter) { instance_double('Bosh::Director::InstanceDeleter') } @@ -605,9 +604,8 @@ module Bosh::Director allow(Config).to receive(:enable_virtual_delete_vms).and_return(false) allow(Config).to receive(:logger).and_return(logger) allow(DiskManager).to receive(:new).with(logger).and_return(disk_manager) - allow(InstanceDeleter).to receive(:new).with(powerdns_manager, disk_manager).and_return(instance_deleter) + allow(InstanceDeleter).to receive(:new).with(disk_manager).and_return(instance_deleter) allow(InstanceReuser).to receive(:new).and_return(instance_reuser) - allow(PowerDnsManagerProvider).to receive(:create).and_return(powerdns_manager) allow(VmCreator).to receive(:new) .with(logger, template_blob_cache, anything, agent_broadcaster, deployment_plan.link_provider_intents) .and_return(vm_creator) diff --git a/src/bosh-director/spec/unit/deployment_plan/network_parser/name_servers_parser_spec.rb b/src/bosh-director/spec/unit/deployment_plan/network_parser/name_servers_parser_spec.rb index 544b02261bc..d996d61c37a 100644 --- a/src/bosh-director/spec/unit/deployment_plan/network_parser/name_servers_parser_spec.rb +++ b/src/bosh-director/spec/unit/deployment_plan/network_parser/name_servers_parser_spec.rb @@ -3,7 +3,7 @@ module Bosh::Director module DeploymentPlan::NetworkParser describe NameServersParser do - subject(:name_servers_parser) { NameServersParser.new() } + subject(:name_servers_parser) { NameServersParser.new } it 'should return nil when there are no DNS servers' do expect(name_servers_parser.parse('network', {})).to be_nil @@ -19,56 +19,9 @@ module DeploymentPlan::NetworkParser }.to raise_error(NetAddr::ValidationError, /foo.bar is invalid \(contains invalid characters\)./) end - context 'when power dns is not enabled' do - let(:dns_config) do - { 'server' => '9.10.11.12' } - end - - before do - allow(Config).to receive(:dns_db).and_return(false) - allow(Config).to receive(:dns).and_return(dns_config) - end - - it 'should not add the power dns nameserver' do - expect(name_servers_parser.parse('network', {'dns' => %w[1.2.3.4]})).to eq(%w[1.2.3.4]) - end + it 'returns an array containing the nameserver address' do + expect(name_servers_parser.parse('network', {'dns' => %w[1.2.3.4]})).to eq(%w[1.2.3.4]) end - - context 'when power dns is enabled' do - context 'when there is a default server' do - let(:dns_config) do - { 'server' => '9.10.11.12' } - end - - before do - allow(Config).to receive(:dns_db).and_return(true) - allow(Config).to receive(:dns).and_return(dns_config) - end - - it 'should add default dns server when there are no DNS servers' do - expect(name_servers_parser.parse('network', {'dns' => []})).to eq(%w[9.10.11.12]) - end - - it 'should add default dns server to an array of DNS servers' do - expect(name_servers_parser.parse('network', {'dns' => %w[1.2.3.4 5.6.7.8]})).to eq(%w[1.2.3.4 5.6.7.8 9.10.11.12]) - end - - it 'should not add default dns server if already set' do - expect(name_servers_parser.parse('network', {'dns' => %w[1.2.3.4 9.10.11.12]})).to eq(%w[1.2.3.4 9.10.11.12]) - end - - context 'when dns server is 127.0.0.1' do - let(:dns_config) do - { 'server' => '127.0.0.1' } - end - - it 'should not add default dns server if it is 127.0.0.1' do - expect(name_servers_parser.parse('network', {'dns' => %w[1.2.3.4]})).to eq(%w[1.2.3.4]) - end - end - end - end - end end end diff --git a/src/bosh-director/spec/unit/dns/director_dns_state_updater_spec.rb b/src/bosh-director/spec/unit/dns/director_dns_state_updater_spec.rb index 140d563104a..f269fa84489 100644 --- a/src/bosh-director/spec/unit/dns/director_dns_state_updater_spec.rb +++ b/src/bosh-director/spec/unit/dns/director_dns_state_updater_spec.rb @@ -15,11 +15,9 @@ module Bosh::Director end let(:dns_record_info) { ['asdf-asdf-asdf-asdf', 'my-instance-group', 'az1', 'my-network', 'my-deployment', '1.2.3.4'] } - let(:powerdns_manager) { instance_double(PowerDnsManager) } let(:localdns_manager) { instance_double(LocalDnsManager) } before do - allow(PowerDnsManagerProvider).to receive(:create).and_return(powerdns_manager) allow(LocalDnsManager).to receive(:create).with( Config.root_domain, Config.logger, @@ -28,9 +26,7 @@ module Bosh::Director describe '#update_dns_for_instance' do it 'calls out to dns manager to update records for instance and flush cache' do - expect(powerdns_manager).to receive(:update_dns_record_for_instance).with(instance, dns_record_info).ordered expect(localdns_manager).to receive(:update_dns_record_for_instance).with(instance_plan) - expect(powerdns_manager).to receive(:flush_dns_cache).ordered subject.update_dns_for_instance(instance_plan, dns_record_info) end diff --git a/src/bosh-director/spec/unit/dns/power_dns_manager_spec.rb b/src/bosh-director/spec/unit/dns/power_dns_manager_spec.rb deleted file mode 100644 index e25b51cd5a9..00000000000 --- a/src/bosh-director/spec/unit/dns/power_dns_manager_spec.rb +++ /dev/null @@ -1,277 +0,0 @@ -require 'spec_helper' - -module Bosh::Director - describe PowerDnsManager do - subject(:powerdns_manager) { described_class.new(domain.name, dns_config, dns_provider, logger) } - - let(:instance_model) do - Models::Instance.make( - uuid: 'fake-uuid', - index: 0, - job: 'job-a', - deployment: deployment_model, - spec_json: spec_json - ) - end - let(:spec_json) { '{}' } - let(:deployment_model) { Models::Deployment.make(name: 'bosh.1') } - let(:domain) { Models::Dns::Domain.make(name: 'bosh', type: 'NATIVE') } - let(:dns_config) do - {} - end - let(:dns_provider) { nil } - let(:blobstore) { instance_double(Bosh::Blobstore::S3cliBlobstoreClient) } - let(:root_domain) { 'bosh1.tld' } - - describe '#flush_dns_cache' do - let(:dns_config) do - { 'domain_name' => domain.name, 'flush_command' => flush_command } - end - let(:flush_command) { nil } - - context 'when flush command is present' do - let(:flush_command) { "echo \"7\" && exit 0" } - - it 'logs success' do - expect(logger).to receive(:debug).with("Flushed 7 records from DNS cache") - powerdns_manager.flush_dns_cache - end - end - - context 'when running flush command fails' do - let(:flush_command) { "echo fake failure >&2 && exit 1" } - - it 'logs an error' do - expect(logger).to receive(:warn).with("Failed to flush DNS cache: fake failure") - powerdns_manager.flush_dns_cache - end - end - - context 'when flush command is not present' do - it 'does not do anything' do - expect(Open3).to_not receive(:capture3) - expect { - powerdns_manager.flush_dns_cache - }.to_not raise_error - end - end - - context 'when dns_publisher is disabled' do - it 'calls nothing on the dns_publisher' do - powerdns_manager.flush_dns_cache - end - end - end - - describe '#find_dns_record_names_by_instance' do - context 'instance model is not set' do - let(:instance_model) { nil } - - it 'returns an empty list' do - expect(powerdns_manager.find_dns_record_names_by_instance(instance_model)).to eq([]) - end - end - - context 'instance model is set' do - let(:instance_model) { Models::Instance.make(uuid: 'fake-uuid', index: 0, job: 'job-a', deployment: deployment_model, dns_records: '["test1.example.com","test2.example.com"]') } - - it 'returns an empty list' do - expect(powerdns_manager.find_dns_record_names_by_instance(instance_model)).to eq(['test1.example.com', 'test2.example.com']) - end - end - end - - context 'when PowerDNS is enabled' do - let(:dns_provider) { PowerDns.new(domain.name, logger) } - - describe '#dns_enabled?' do - it 'should be true' do - expect(powerdns_manager.dns_enabled?).to eq(true) - end - end - - describe '#delete_dns_for_instance' do - before do - powerdns_manager.update_dns_record_for_instance(instance_model, {'fake-dns-name-1' => '1.2.3.4', 'fake-dns-name-2' => '5.6.7.8'}) - end - - it 'deletes dns records from dns provider' do - expect(dns_provider.find_dns_record('fake-dns-name-1', '1.2.3.4')).to_not be_nil - expect(dns_provider.find_dns_record('fake-dns-name-2', '5.6.7.8')).to_not be_nil - powerdns_manager.delete_dns_for_instance(instance_model) - expect(dns_provider.find_dns_record('fake-dns-name-1', '1.2.3.4')).to be_nil - expect(dns_provider.find_dns_record('fake-dns-name-2', '5.6.7.8')).to be_nil - end - - it 'deletes dns records from instance model' do - expect(instance_model.dns_record_names.to_a).to eq(['fake-dns-name-1', 'fake-dns-name-2']) - powerdns_manager.delete_dns_for_instance(instance_model) - expect(instance_model.dns_record_names.to_a).to eq([]) - end - - context 'when instance has records in dns provider but not in instance model' do - before do - dns_provider.create_or_update_dns_records('fake-uuid.job-a.network-a.dep.bosh', '1.2.3.4') - end - - it 'removes them from dns provider' do - powerdns_manager.delete_dns_for_instance(instance_model) - expect(dns_provider.find_dns_record('0.job-a.network-a.dep.bosh', '1.2.3.4')).to be_nil - end - end - end - - describe '#configure_nameserver' do - context 'dns is enabled' do - let(:dns_config) do - { 'domain_name' => domain.name, 'address' => '1.2.3.4' } - end - it 'creates name server records' do - powerdns_manager.configure_nameserver - ns_record = Models::Dns::Record.find(name: 'bosh', type: 'NS') - a_record = Models::Dns::Record.find(type: 'A') - soa_record = Models::Dns::Record.find(name: 'bosh', type: 'SOA') - domain = Models::Dns::Domain.find(name: 'bosh', type: 'NATIVE') - expect(ns_record.content).to eq('ns.bosh') - expect(a_record.content).to eq('1.2.3.4') - expect(soa_record.content).to eq(PowerDns::SOA) - expect(domain).to_not eq(nil) - end - end - end - - describe '#update_dns_record_for_instance' do - let(:spec_json) { JSON.dump({'networks' => {'net-name' => {'ip' => '1234'}}}) } - before do - instance_model.update(availability_zone: 'az1') - powerdns_manager.update_dns_record_for_instance(instance_model, {'fake-dns-name-1' => '1.2.3.4', 'fake-dns-name-2' => '5.6.7.8'}) - end - - it 'updates dns records for instance in database' do - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2']) - powerdns_manager.update_dns_record_for_instance(instance_model, {'fake-dns-name-3' => '9.8.7.6'}) - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2', 'fake-dns-name-3']) - end - - it 'appends the records to the model' do - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2']) - powerdns_manager.update_dns_record_for_instance(instance_model, {'another-dns-name-1' => '1.2.3.4', 'another-dns-name-2' => '5.6.7.8'}) - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2', 'another-dns-name-1', 'another-dns-name-2']) - expect(dns_provider.find_dns_record('fake-dns-name-1', '1.2.3.4')).to_not be_nil - expect(dns_provider.find_dns_record('fake-dns-name-2', '5.6.7.8')).to_not be_nil - expect(dns_provider.find_dns_record('another-dns-name-1', '1.2.3.4')).to_not be_nil - expect(dns_provider.find_dns_record('another-dns-name-2', '5.6.7.8')).to_not be_nil - end - - it 'it keeps old record names pointing at their original ips' do - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2']) - powerdns_manager.update_dns_record_for_instance(instance_model, {'another-dns-name-1' => '1.2.3.5', 'another-dns-name-2' => '5.6.7.9'}) - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2', 'another-dns-name-1', 'another-dns-name-2']) - expect(dns_provider.find_dns_record('fake-dns-name-1', '1.2.3.4')).to_not be_nil - expect(dns_provider.find_dns_record('fake-dns-name-2', '5.6.7.8')).to_not be_nil - expect(dns_provider.find_dns_record('another-dns-name-1', '1.2.3.5')).to_not be_nil - expect(dns_provider.find_dns_record('another-dns-name-2', '5.6.7.9')).to_not be_nil - end - - context 'when the dns entry already exists' do - it 'updates the DNS record when the IP address has changed' do - powerdns_manager.update_dns_record_for_instance(instance_model, {'fake-dns-name-2' => '9.8.7.6'}) - - dns_record = Models::Dns::Record.find(name: 'fake-dns-name-2') - expect(dns_record.content).to eq('9.8.7.6') - end - - it 'does NOT update the DNS record when the IP address is the same' do - powerdns_manager.update_dns_record_for_instance(instance_model, {'fake-dns-name-2' => '5.6.7.8'}) - - dns_record = Models::Dns::Record.find(name: 'fake-dns-name-2') - expect(dns_record.content).to eq('5.6.7.8') - end - end - end - - describe '#migrate_legacy_records' do - before do - dns_provider.create_or_update_dns_records('0.job-a.network-a.bosh1.bosh', '1.2.3.4') - dns_provider.create_or_update_dns_records('fake-uuid.job-a.network-a.bosh1.bosh', '1.2.3.4') - dns_provider.create_or_update_dns_records('0.job-a.network-b.bosh1.bosh', '5.6.7.8') - dns_provider.create_or_update_dns_records('fake-uuid.job-a.network-b.bosh1.bosh', '5.6.7.8') - end - - it 'saves instance dns records for all networks in local instance model' do - expect(instance_model.dns_record_names).to be_nil - - powerdns_manager.migrate_legacy_records(instance_model) - - expect(instance_model.dns_record_names).to match_array([ - '0.job-a.network-a.bosh1.bosh', - 'fake-uuid.job-a.network-a.bosh1.bosh', - '0.job-a.network-b.bosh1.bosh', - 'fake-uuid.job-a.network-b.bosh1.bosh' - ]) - end - - context 'when instance model has dns records' do - before do - instance_model.update(dns_record_names: ['anything']) - end - - it 'does not migrate' do - powerdns_manager.migrate_legacy_records(instance_model) - expect(instance_model.dns_record_names).to match_array(['anything']) - end - end - end - end - - context 'when PowerDNS is disabled' do - let(:instance_model) { Models::Instance.make(uuid: 'fake-uuid', index: 0, job: 'job-a', deployment: deployment_model) } - - describe '#dns_enabled?' do - it 'should be false' do - expect(powerdns_manager.dns_enabled?).to eq(false) - end - end - - describe '#delete_dns_for_instance' do - it 'returns with no errors' do - powerdns_manager.delete_dns_for_instance(instance_model) - end - end - - describe '#migrate_legacy_records' do - it 'does not migrate' do - powerdns_manager.migrate_legacy_records(instance_model) - expect(instance_model.dns_record_names.to_a).to match_array([]) - end - end - - describe '#configure_nameserver' do - it 'creates nothing' do - powerdns_manager.configure_nameserver - ns_record = Models::Dns::Record.find(name: domain.name, type: 'NS') - a_record = Models::Dns::Record.find(type: 'A') - soa_record = Models::Dns::Record.find(name: domain.name, type: 'SOA') - expect(ns_record).to eq(nil) - expect(a_record).to eq(nil) - expect(soa_record).to eq(nil) - end - end - - describe '#update_dns_record_for_instance' do - before do - powerdns_manager.update_dns_record_for_instance(instance_model, {'fake-dns-name-1' => '1.2.3.4', 'fake-dns-name-2' => '5.6.7.8'}) - end - - context 'when IPs/hosts change' do - it 'updates dns records for instance' do - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2']) - powerdns_manager.update_dns_record_for_instance(instance_model, {'fake-dns-name-1' => '11.22.33.44', 'new-fake-dns-name' => '99.88.77.66'}) - expect(instance_model.dns_record_names).to eq(['fake-dns-name-1', 'fake-dns-name-2', 'new-fake-dns-name']) - expect(Models::Dns::Record.all.count).to eq(0) - end - end - end - end - end -end diff --git a/src/bosh-director/spec/unit/dns/powerdns_spec.rb b/src/bosh-director/spec/unit/dns/powerdns_spec.rb deleted file mode 100644 index 2d74b796351..00000000000 --- a/src/bosh-director/spec/unit/dns/powerdns_spec.rb +++ /dev/null @@ -1,109 +0,0 @@ -require 'spec_helper' - -module Bosh::Director - describe PowerDns do - subject(:power_dns) { PowerDns.new('bosh', logger) } - describe '#create_or_update' do - context 'when dns record does not exist' do - - it 'creates new A record' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '1.2.3.4') - record = Models::Dns::Record.find(name: '1.foobar.network.dep.bosh', content: '1.2.3.4', type: 'A') - expect(record).to exist - end - - it 'creates a new PTR record' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '1.2.3.4') - ptr_record = Models::Dns::Record.find( - name: '4.3.2.1.in-addr.arpa', - content: '1.foobar.network.dep.bosh', - type: 'PTR' - ) - expect(ptr_record).to exist - end - - it 'creates a domain' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '1.2.3.4') - domain = Models::Dns::Domain.find(name: 'bosh', type: 'NATIVE') - expect(domain).to exist - end - - it 'creates a PTR domain' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '1.2.3.4') - ptr_domain = Models::Dns::Domain.find(name: '3.2.1.in-addr.arpa', type: 'NATIVE') - expect(ptr_domain).to exist - end - - it 'creates a new NS record in the new domain' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '1.2.3.4') - ns_record = Models::Dns::Record.find(name: '3.2.1.in-addr.arpa', content: 'ns.bosh', type: 'NS') - expect(ns_record).to exist - end - - it 'creates a new SOA record in the new domain' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '1.2.3.4') - soa_record = Models::Dns::Record.find( - name: '3.2.1.in-addr.arpa', - content: 'localhost hostmaster@localhost 0 10800 604800 30', - type: 'SOA' - ) - expect(soa_record).to exist - end - end - - context 'when a dns record exists' do - before do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '1.2.3.4') - end - - it 'updates the ip address on A record' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '5.6.7.8') - records = Models::Dns::Record.where(name: '1.foobar.network.dep.bosh', type: 'A') - expect(records.map(&:content)).to eq(['5.6.7.8']) - end - - it 'updates PTR records' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '5.6.7.8') - ptr_records = Models::Dns::Record.where(name: '8.7.6.5.in-addr.arpa', type: 'PTR') - expect(ptr_records.map(&:content)).to eq(['1.foobar.network.dep.bosh']) - end - - it 'creates a new NS record in the new domain' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '5.6.7.8') - ns_record = Models::Dns::Record.find(name: '7.6.5.in-addr.arpa', content: 'ns.bosh', type: 'NS') - expect(ns_record).to exist - end - - it 'creates a new SOA record in the new domain' do - power_dns.create_or_update_dns_records('1.foobar.network.dep.bosh', '5.6.7.8') - soa_record = Models::Dns::Record.find( - name: '7.6.5.in-addr.arpa', - content: 'localhost hostmaster@localhost 0 10800 604800 30', - type: 'SOA' - ) - expect(soa_record).to exist - end - end - end - - describe '#delete' do - let(:ip) {'1.2.3.4'} - - before do - power_dns.create_or_update_dns_records('1.foobar.network-a.dep.bosh', ip) - power_dns.create_or_update_dns_records('uuid1uuid.foobar.network-a.dep.bosh', ip) - power_dns.create_or_update_dns_records('1.foobar.network-b.dep.bosh', ip) - end - - it 'deletes A records' do - power_dns.delete('1.foobar.%.dep.bosh') - expect(Models::Dns::Record.filter(type: 'A').map(&:name)).to eq(['uuid1uuid.foobar.network-a.dep.bosh']) - end - - it 'deletes PTR records associated with the pattern' do - power_dns.delete('1.foobar.%.dep.bosh') - expect(Models::Dns::Record.filter(type: 'PTR').map(&:content)).to eq(['uuid1uuid.foobar.network-a.dep.bosh']) - end - end - end -end diff --git a/src/bosh-director/spec/unit/instance_deleter_spec.rb b/src/bosh-director/spec/unit/instance_deleter_spec.rb index 2fe826971c1..a305eef5050 100644 --- a/src/bosh-director/spec/unit/instance_deleter_spec.rb +++ b/src/bosh-director/spec/unit/instance_deleter_spec.rb @@ -6,12 +6,10 @@ module Bosh::Director let(:cloud) { instance_double(Bosh::Clouds::ExternalCpi) } let(:cloud_factory) { instance_double(Bosh::Director::CloudFactory) } let(:delete_job) { Jobs::DeleteDeployment.new('test_deployment', {}) } - let(:deleter) { InstanceDeleter.new(powerdns_manager, disk_manager, options) } + let(:deleter) { InstanceDeleter.new(disk_manager, options) } let(:disk_manager) { DiskManager.new(logger) } let(:dns_publisher) { instance_double(BlobstoreDnsPublisher, publish_and_broadcast: nil) } - let(:domain) { Models::Dns::Domain.make(name: 'bosh') } let(:local_dns_records_repo) { instance_double(LocalDnsRecordsRepo, delete_for_instance: nil) } - let(:powerdns_manager) { instance_double(PowerDnsManager, delete_dns_for_instance: nil) } let(:task) { Bosh::Director::Models::Task.make(id: 42, username: 'user') } let(:variables_interpolator) { instance_double(Bosh::Director::ConfigServer::VariablesInterpolator) } @@ -171,7 +169,6 @@ module Bosh::Director it 'drains, deletes snapshots, dns records, persistent disk' do expect(Stopper).to receive(:stop) - expect(powerdns_manager).to receive(:delete_dns_for_instance).with(existing_instance) expect(dns_publisher).to receive(:publish_and_broadcast) expect(local_dns_records_repo).to receive(:delete_for_instance) @@ -224,7 +221,6 @@ module Bosh::Director it 'deletes snapshots, persistent disk' do expect(VmDeleter).to receive(:new).with(anything, true, false) - expect(powerdns_manager).to receive(:delete_dns_for_instance).with(existing_instance) expect(dns_publisher).to receive(:publish_and_broadcast) expect(local_dns_records_repo).to receive(:delete_for_instance) @@ -252,7 +248,6 @@ module Bosh::Director it 'drains, deletes snapshots, persistent disk' do expect(Stopper).to receive(:stop) expect(disk_manager).to receive(:delete_persistent_disks).with(existing_instance) - expect(powerdns_manager).to receive(:delete_dns_for_instance).with(existing_instance) expect(dns_publisher).to receive(:publish_and_broadcast) expect(local_dns_records_repo).to receive(:delete_for_instance) @@ -267,30 +262,6 @@ module Bosh::Director end end - context 'when deleting dns fails' do - before do - allow(powerdns_manager).to receive(:delete_dns_for_instance).and_raise('failed') - - allow(dns_publisher).to receive(:publish_and_broadcast) - allow(local_dns_records_repo).to receive(:delete_for_instance) - end - - it 'drains, deletes vm, snapshots, disks' do - expect(Stopper).to receive(:stop) - expect(cloud).to receive(:delete_vm).with(existing_instance.vm_cid) - - expect(event_log_stage).to receive(:advance_and_track).with('fake-job-name/my-uuid-1 (5)') - - expect(job_templates_cleaner).to receive(:clean_all).with(no_args) - - expect do - deleter.delete_instance_plans([instance_plan], event_log_stage) - end.to change { Models::Instance.all.select { |i| i.active_vm == existing_vm }.count }.from(1).to(0) - - expect(disk_manager).to have_received(:delete_persistent_disks).with(existing_instance) - end - end - context 'when cleaning templates fails' do before do allow(job_templates_cleaner).to receive(:clean_all).and_raise('failed') @@ -323,8 +294,6 @@ module Bosh::Director expect(Stopper).to receive(:stop) expect(cloud).not_to receive(:delete_vm) - expect(powerdns_manager).to receive(:delete_dns_for_instance).with(existing_instance) - expect(dns_publisher).to receive(:publish_and_broadcast) expect(local_dns_records_repo).to receive(:delete_for_instance) diff --git a/src/bosh-director/spec/unit/jobs/vm_state_spec.rb b/src/bosh-director/spec/unit/jobs/vm_state_spec.rb index bdfa2f5314e..e00cd8130a3 100644 --- a/src/bosh-director/spec/unit/jobs/vm_state_spec.rb +++ b/src/bosh-director/spec/unit/jobs/vm_state_spec.rb @@ -32,7 +32,7 @@ def stub_agent_get_state_to_return_state_with_vitals let(:instance) { Models::Instance.make(deployment: deployment) } before do - allow(Config).to receive(:dns).and_return('domain_name' => 'microbosh', 'db' => {}) + allow(Config).to receive(:dns).and_return('domain_name' => 'microbosh') allow(Config).to receive(:result).and_return(TaskDBWriter.new(:result_output, task.id)) end diff --git a/src/bosh-nats-sync/spec/nats_sync/users_sync_spec.rb b/src/bosh-nats-sync/spec/nats_sync/users_sync_spec.rb index a020c17ddc4..3b8022c2bdd 100644 --- a/src/bosh-nats-sync/spec/nats_sync/users_sync_spec.rb +++ b/src/bosh-nats-sync/spec/nats_sync/users_sync_spec.rb @@ -124,12 +124,6 @@ module NATSSync "domain_name": "bosh" } }, - "power_dns": { - "status": false, - "extras": { - "domain_name": "bosh" - } - }, "snapshots": { "status": false }, diff --git a/src/spec/integration/cli_env_spec.rb b/src/spec/integration/cli_env_spec.rb index 1b6de5fbab4..41084ba790d 100644 --- a/src/spec/integration/cli_env_spec.rb +++ b/src/spec/integration/cli_env_spec.rb @@ -17,7 +17,6 @@ features = [] features << 'config_server: disabled' features << 'local_dns: disabled' - features << 'power_dns: enabled' features << 'snapshots: enabled' features_regex = /Features\s*#{features.join('\s*')}/m