Class: Kitchen::Driver::Dokken
- Inherits:
-
Base
- Object
- Base
- Kitchen::Driver::Dokken
- Defined in:
- lib/kitchen/driver/dokken.rb
Overview
Dokken driver for Kitchen.
Creates three containers per instance: a runner, which the converge actually happens in; a chef volume container, whose /opt/chef is mounted into the runner instead of installing chef; and -- only when the docker daemon cannot read the local filesystem -- a data container that serves the kitchen sandbox over ssh.
Defined Under Namespace
Classes: PartialHash
Instance Method Summary collapse
- #create(state) ⇒ void
-
#destroy(_state) ⇒ Object
The chef volume container and the dokken network are deliberately left behind: both are shared by every instance using the same chef version.
-
#status(_state) ⇒ Hash
kitchen list --liveasks the driver whether the instance is really there rather than trusting the last recorded action, which is exactly the question a docker daemon can answer precisely.
Instance Method Details
#create(state) ⇒ void
This method returns an undefined value.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/kitchen/driver/dokken.rb', line 107 def create(state) # Authenticate the private registry authenticate! # image to config pull_platform_image # network make_dokken_network # chef pull_chef_image create_chef_container state # data dokken_create_sandbox if remote_docker_host? || running_inside_docker? make_data_image start_data_container state end # work image build_work_image state # runner start_runner_container state # misc save_misc_state state end |
#destroy(_state) ⇒ Object
The chef volume container and the dokken network are deliberately left behind: both are shared by every instance using the same chef version.
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/kitchen/driver/dokken.rb', line 143 def destroy(_state) if remote_docker_host? || running_inside_docker? stop_data_container delete_data_container end stop_runner_container delete_runner_container delete_work_image dokken_delete_sandbox end |
#status(_state) ⇒ Hash
kitchen list --live asks the driver whether the instance is really
there rather than trusting the last recorded action, which is exactly
the question a docker daemon can answer precisely. Without this the
driver inherited Base's "unknown", so a container that was plainly
Up still listed as unknown.
The runner is the instance. The chef container is a shared volume and the data container only exists on the remote-daemon path, so neither says anything about whether this instance is up.
Deliberately not wrapped in #with_retries: this backs a listing, and a slow answer is worse than an honest "unknown".
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/kitchen/driver/dokken.rb', line 172 def status(_state) container_status(::Docker::Container.get(runner_container_name, {}, docker_connection)) rescue ::Docker::Error::NotFoundError { live: false, state: "not created", source: "driver" } # Every other failure -- an unreachable daemon most of all -- is an # unknown rather than an exception. Kitchen would catch it either way, # but it would then report the exception class instead of the daemon # url that could not be reached. rescue ::StandardError => e { live: nil, state: "unknown", source: "driver", message: "could not ask the docker daemon at #{config[:docker_host_url]}: #{e.}", } end |