Class: Kitchen::Verifier::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/helpers.rb

Overview

See Also:

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ void

This method returns an undefined value.

Run the verifier against the instance.

This replaces Kitchen::Verifier::Base#call outright, so it has to be read against the upstream version it stands in for. It diverges in three places, and each divergence is deliberate:

  1. The upload is gated on the data container. Files are only shipped when the driver built one, which it does exactly when the daemon cannot read the host filesystem. Otherwise the sandboxes are bind-mounted and are already in place. init_command is gated with it because for Busser it clears the verifier root, which in bind-mount mode is the host sandbox that was just populated.

  2. cleanup_sandbox is not called, and must not be. Upstream can rmtree its sandbox because a stock one is a throwaway Dir.mktmpdir. Dokken's is a stable per-instance directory that the driver bind-mounts into a long-lived container, and a bind mount is bound to an inode rather than to a path: removing the directory severs it permanently, and the mkdir_p in the next create_sandbox does not restore it. Verified against Docker -- after an rmtree and a recreate, the host has the file and the container cannot see it, until the container itself is replaced. Kitchen::Provisioner::Dokken#cleanup_dokken_sandbox is the shape that is safe here: empty the directory, keep the inode.

  3. config[:downloads] is not honoured. Upstream downloads files off the instance after the run command. That cannot work here yet for a second reason as well: Transport::Dokken::Connection does not implement download, so the base class would raise. Wiring both up is worth doing, and is the one divergence here that is a gap rather than a decision.

spec/kitchen/verifier_override_contract_spec.rb pins the upstream facts this reasoning rests on, so that a test-kitchen release which invalidates any of them fails loudly rather than silently.

Parameters:

  • state (Hash)

    mutable instance state

Raises:

  • (Kitchen::ActionFailed)

    if the transport fails



669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/kitchen/helpers.rb', line 669

def call(state)
  create_sandbox
  instance.transport.connection(state) do |conn|
    conn.execute(install_command)

    unless state[:data_container].nil?
      conn.execute(init_command)
      info("Transferring files to #{instance.to_str}")
      conn.upload(sandbox_dirs, config[:root_path])
      debug("Transfer complete")
    end

    conn.execute(prepare_command)
    conn.execute(run_command)
  end
rescue Kitchen::Transport::TransportFailed => ex
  raise ActionFailed, ex.message
end

#create_sandboxvoid

This method returns an undefined value.

Create the verifier sandbox under ~/.dokken.



608
609
610
611
612
613
# File 'lib/kitchen/helpers.rb', line 608

def create_sandbox
  info("Creating kitchen sandbox in #{sandbox_path}")
  unless ::Dir.exist?(sandbox_path)
    FileUtils.mkdir_p(sandbox_path, mode: 0o755)
  end
end

#instance_nameString

A container-safe, collision-free name for this kitchen instance.

Returns:

  • (String)

    the instance name

See Also:



626
627
628
# File 'lib/kitchen/helpers.rb', line 626

def instance_name
  ::Dokken::Helpers.instance_name_for(instance)
end

#sandbox_pathString

Where the verifier stages files for this instance.

Returns:

  • (String)

    an absolute path on the host



618
619
620
# File 'lib/kitchen/helpers.rb', line 618

def sandbox_path
  "#{Dir.home}/.dokken/verifier_sandbox/#{instance_name}"
end