kitchen-dokken 2.23.5 → 2.23.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed64ab202db24ce243e1a4c26083a924b194aec6a3cc448c88de450d6e53e091
4
- data.tar.gz: d252f250ec7bc1af41500443d3c2edf295b622d0222467fc9a1bb1edc552b065
3
+ metadata.gz: c9cac8cad07f229a018567a935e33aaa71edaa04c65dd05a38afbcd10bc839e4
4
+ data.tar.gz: 971a897b24f4a00f224d995f18ae7177712110ed4048d2a9d02fb03fcd8948a4
5
5
  SHA512:
6
- metadata.gz: df9c8ca5f29d747dc3e4838338f793e46cc4ea3138db6fbd9f4cd65ce0a94cbf3a2a62a0417fd312b399258d378bd046d6659a55fcc982264a6908587ccee049
7
- data.tar.gz: dd0477b6314e4ae2efc3b529b77cad5408493b157bd49471205edfdc5a6eaf464feb51a12928259195c80ce14c65d22e39a13c017e7de0105569e02606e8c858
6
+ metadata.gz: 578aca5a5d479624c15313d7d6695d8ea42f75e5822ed55f3c083bb9b561b5b0e1378fa0e27964b0444cfd93f1db63eb5d6fc3b124ac977683b792735bfae7d2
7
+ data.tar.gz: 2bf35be1a50b68a4de9ac5e0d8ac674904165a65f730b472b30c488b9c786890d740586fc7189bf21f22d95fe49cb1bcb2be33456ae37bb43b25d144f3c02854
@@ -543,7 +543,8 @@ module Kitchen
543
543
  return unless self[:network_mode] == "dokken"
544
544
 
545
545
  with_file_lock("#{home_dir}/.dokken-network.lock") do
546
- with_retries { ::Docker::Network.get("dokken", {}, docker_connection) }
546
+ network = with_retries { ::Docker::Network.get("dokken", {}, docker_connection) }
547
+ warn_on_ipv6_mismatch(network)
547
548
  rescue ::Docker::Error::NotFoundError
548
549
  begin
549
550
  with_retries { ::Docker::Network.create("dokken", network_settings) }
@@ -553,6 +554,34 @@ module Kitchen
553
554
  end
554
555
  end
555
556
 
557
+ # Say something when the shared network cannot honour `ipv6: true`.
558
+ #
559
+ # The dokken network is created once and shared by every instance, and
560
+ # `destroy` deliberately leaves it behind -- so on any workstation that
561
+ # has run a non-ipv6 suite, it already exists without ipv6. Since the
562
+ # network is only created when absent, a later `ipv6: true` suite
563
+ # quietly reuses it, the container gets no ipv6 address, and nothing
564
+ # anywhere says why.
565
+ #
566
+ # Deliberately a warning rather than an error: the network may be in use
567
+ # by other instances right now, and removing it is the user's call.
568
+ #
569
+ # @param network [::Docker::Network] the existing dokken network
570
+ # @return [void]
571
+ def warn_on_ipv6_mismatch(network)
572
+ return unless self[:ipv6]
573
+
574
+ # A daemon that does not report the flag must not produce a warning on
575
+ # every converge.
576
+ enabled = network.info["EnableIPv6"] if network.respond_to?(:info)
577
+ return if enabled.nil? || enabled
578
+
579
+ warn "The existing dokken network was created without IPv6, so `ipv6: true` " \
580
+ "will have no effect and this instance will get no IPv6 address. The " \
581
+ "network is shared and `kitchen destroy` leaves it in place; recreate it " \
582
+ "with `docker network rm dokken` once no containers are using it."
583
+ end
584
+
556
585
  # Build the data image, unless it is already present.
557
586
  #
558
587
  # @return [void]
@@ -776,7 +805,11 @@ module Kitchen
776
805
  with_retries { @image = ::Docker::Image.get(name, { "platform" => oci_platform(config[:platform]) }, docker_connection) }
777
806
  with_retries { @image.remove(force: true) }
778
807
  rescue ::Docker::Error::DockerError
779
- puts "Image #{name} not found. Nothing to delete."
808
+ # `debug`, not `puts`: this is routine during destroy, and writing
809
+ # straight to stdout puts it outside kitchen's logging entirely --
810
+ # it bypasses the log level, never reaches `.kitchen/logs`, and
811
+ # interleaves with kitchen's own output.
812
+ debug "Image #{name} not found. Nothing to delete."
780
813
  end
781
814
 
782
815
  # Whether the daemon knows about a container.
@@ -850,7 +883,7 @@ module Kitchen
850
883
  # @raise [RuntimeError] if the container could not be created
851
884
  def create_container(args, platform: nil)
852
885
  with_retries { @container = ::Docker::Container.get(args["name"], {}, docker_connection) }
853
- rescue
886
+ rescue ::Docker::Error::NotFoundError
854
887
  with_retries do
855
888
  # Merge rather than append: start_runner_container passes config[:env]
856
889
  # straight through, so mutating args["Env"] would edit the driver's
@@ -18,6 +18,6 @@
18
18
  module Kitchen
19
19
  module Driver
20
20
  # Version string for Dokken Kitchen driver
21
- DOKKEN_VERSION = "2.23.5".freeze
21
+ DOKKEN_VERSION = "2.23.7".freeze
22
22
  end
23
23
  end
@@ -253,17 +253,30 @@ module Dokken
253
253
  "#{home_dir}/.dokken/verifier_sandbox/#{instance_name}"
254
254
  end
255
255
 
256
- # A container-safe, collision-free name for this kitchen instance.
256
+ # A container-safe, collision-free name for a kitchen instance.
257
257
  #
258
258
  # The working directory is hashed into the prefix so that the same suite
259
259
  # in two checkouts does not fight over one set of containers.
260
260
  #
261
+ # Defined on the module itself because Kitchen's Provisioner and Verifier
262
+ # base classes need the same answer but do not mix this module in -- they
263
+ # used to carry their own copies of these two lines, and three copies of
264
+ # a container-naming rule is three chances for them to drift apart.
265
+ #
266
+ # @param instance [Object] the kitchen instance
261
267
  # @return [String] the instance name
262
- def instance_name
268
+ def self.instance_name_for(instance)
263
269
  prefix = (Digest::SHA2.hexdigest FileUtils.pwd)[0, 10]
264
270
  "#{prefix}-#{instance.name}".downcase
265
271
  end
266
272
 
273
+ # (see Dokken::Helpers.instance_name_for)
274
+ #
275
+ # @return [String] the instance name
276
+ def instance_name
277
+ ::Dokken::Helpers.instance_name_for(instance)
278
+ end
279
+
267
280
  # The `ExposedPorts` value for the runner container.
268
281
  #
269
282
  # @return [Hash, nil] a Docker API ExposedPorts hash
@@ -453,7 +466,12 @@ module Dokken
453
466
  def running_inside_docker_desktop?
454
467
  Resolv.getaddress "host.docker.internal."
455
468
  true
456
- rescue
469
+ # Deliberately every StandardError, spelled out rather than bare. This is
470
+ # a probe: "can I resolve host.docker.internal" has exactly two useful
471
+ # answers, and a DNS timeout or a SocketError must be "no" rather than
472
+ # something that aborts a converge. Listing Resolv::ResolvError as well
473
+ # would be redundant -- it is a StandardError already.
474
+ rescue ::StandardError
457
475
  false
458
476
  end
459
477
 
@@ -521,8 +539,7 @@ module Kitchen
521
539
  # @return [String] the instance name
522
540
  # @see Dokken::Helpers#instance_name
523
541
  def instance_name
524
- prefix = (Digest::SHA2.hexdigest FileUtils.pwd)[0, 10]
525
- "#{prefix}-#{instance.name}".downcase
542
+ ::Dokken::Helpers.instance_name_for(instance)
526
543
  end
527
544
  end
528
545
  end
@@ -557,8 +574,7 @@ module Kitchen
557
574
  # @return [String] the instance name
558
575
  # @see Dokken::Helpers#instance_name
559
576
  def instance_name
560
- prefix = (Digest::SHA2.hexdigest FileUtils.pwd)[0, 10]
561
- "#{prefix}-#{instance.name}".downcase
577
+ ::Dokken::Helpers.instance_name_for(instance)
562
578
  end
563
579
 
564
580
  # Run the verifier against the instance.
@@ -79,7 +79,17 @@ module Kitchen
79
79
  create_sandbox
80
80
  write_run_command(run_command)
81
81
  instance.transport.connection(state) do |conn|
82
- if remote_docker_host? || running_inside_docker?
82
+ # Gate on what the driver recorded, not on a fresh probe. The driver
83
+ # already answered this at create time -- it built a data container
84
+ # or it did not -- and re-deriving the answer here means the two can
85
+ # disagree. Point DOCKER_HOST somewhere else between `kitchen
86
+ # create` and `kitchen converge` and they do: this side decides to
87
+ # upload, the container it would upload through was never created,
88
+ # and the transport dies on nil several frames down.
89
+ #
90
+ # Kitchen::Verifier::Base#call has always gated on the recorded
91
+ # state; this is the provisioner agreeing with it.
92
+ unless state[:data_container].nil?
83
93
  info("Transferring files to #{instance.to_str}")
84
94
  conn.upload(sandbox_dirs, config[:root_path])
85
95
  end
@@ -204,7 +214,7 @@ module Kitchen
204
214
  # @return [String] the container name
205
215
  # @api private
206
216
  def runner_container_name
207
- instance.name.to_s
217
+ instance_name.to_s
208
218
  end
209
219
 
210
220
  # Empty the sandbox after a converge, keeping the directory itself.
@@ -121,6 +121,17 @@ module Kitchen
121
121
  # @raise [Kitchen::UserError] if docker_host_url is not tcp:// or unix://
122
122
  # @raise [Kitchen::Transport::TransportFailed] if the copy fails
123
123
  def upload(locals, remote)
124
+ # Every route through ssh_endpoint reads the data container out of
125
+ # state, so being handed none is not a transfer that fails -- it is
126
+ # a caller that should not have asked. Said plainly here rather than
127
+ # as `undefined method '[]' for nil` from three frames down.
128
+ if options[:data_container].nil?
129
+ raise Kitchen::Transport::TransportFailed,
130
+ "Cannot upload to #{options[:instance_name]}: no data container was created " \
131
+ "for this instance. Files are only shipped over ssh when the docker daemon " \
132
+ "cannot read the local filesystem; otherwise the sandbox is bind-mounted."
133
+ end
134
+
124
135
  ssh_ip, ssh_port = ssh_endpoint
125
136
 
126
137
  debug "ssh_ip : #{ssh_ip}"
@@ -477,7 +488,11 @@ module Kitchen
477
488
  # @return [TrueClass,FalseClass]
478
489
  def docker_for_mac_or_win?
479
490
  ::Docker.info(::Docker::Connection.new(config[:docker_host_url], {}))["Name"] == "docker-desktop"
480
- rescue
491
+ # `::StandardError`, spelled out. This method lives inside module
492
+ # Kitchen, where a bare `StandardError` resolves to
493
+ # Kitchen::StandardError -- which Excon::Error::Socket is not, so an
494
+ # unreachable daemon would escape instead of answering "no".
495
+ rescue ::StandardError
481
496
  false
482
497
  end
483
498
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dokken
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.23.5
4
+ version: 2.23.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara