vx-lib-container 0.5.11 → 0.6.0
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 +4 -4
- data/lib/vx/lib/container.rb +0 -3
- data/lib/vx/lib/container/docker.rb +5 -25
- data/lib/vx/lib/container/docker/spawner.rb +4 -0
- data/lib/vx/lib/container/local.rb +3 -7
- data/lib/vx/lib/container/local/spawner.rb +4 -0
- data/lib/vx/lib/container/version.rb +1 -1
- metadata +2 -3
- data/lib/vx/lib/container/mixin/instrument.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aa9c3e92022ed99759a8493f55ca3bda44459a6
|
4
|
+
data.tar.gz: 711b942d04d5e771cebc2883be205ef9f499be15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da843df18fa69d2e606f2b8f604ede2f276656e37675799a248221bd67617d2e488f9dd5a7c1ee53cd40e3efd4f497e9635694caac5c47b43c413eb1598a3aab
|
7
|
+
data.tar.gz: b2664f01f405660715fd9c8dd93f7bfb9d936146fbc62fd4fef8d464bee8285b9ebef7d3ec9c061ea0bc71413b55b9c09c832b92b872ab8e662bc62a16d5f503
|
data/lib/vx/lib/container.rb
CHANGED
@@ -8,13 +8,10 @@ module Vx
|
|
8
8
|
autoload :Local, File.expand_path("../container/local", __FILE__)
|
9
9
|
autoload :Docker, File.expand_path("../container/docker", __FILE__)
|
10
10
|
autoload :Retriable, File.expand_path("../container/mixin/retriable", __FILE__)
|
11
|
-
autoload :Instrument, File.expand_path("../container/mixin/instrument", __FILE__)
|
12
11
|
autoload :Upload, File.expand_path("../container/mixin/upload", __FILE__)
|
13
12
|
|
14
13
|
extend self
|
15
14
|
|
16
|
-
attr_accessor :instrumenter
|
17
|
-
|
18
15
|
def lookup(name, options = {})
|
19
16
|
case name.to_sym
|
20
17
|
when :docker
|
@@ -14,7 +14,6 @@ module Vx
|
|
14
14
|
|
15
15
|
include Lib::Shell
|
16
16
|
include Lib::Container::Retriable
|
17
|
-
include Lib::Container::Instrument
|
18
17
|
|
19
18
|
attr_reader :user, :password, :init, :image, :remote_dir, :memory, :memory_swap
|
20
19
|
|
@@ -55,16 +54,8 @@ module Vx
|
|
55
54
|
timeout: 3,
|
56
55
|
}
|
57
56
|
|
58
|
-
instrumentation = {
|
59
|
-
container_type: "docker",
|
60
|
-
container: container.json,
|
61
|
-
ssh_options: ssh_options.merge(host: host, user: user)
|
62
|
-
}
|
63
|
-
|
64
57
|
ssh = with_retries ::Net::SSH::AuthenticationFailed, ::Errno::ECONNREFUSED, ::Errno::ETIMEDOUT, ::Timeout::Error, limit: 5, sleep: 3 do
|
65
|
-
|
66
|
-
::Net::SSH.start host, user, ssh_options
|
67
|
-
end
|
58
|
+
::Net::SSH.start host, user, ssh_options
|
68
59
|
end
|
69
60
|
|
70
61
|
re = yield Spawner.new(container, ssh)
|
@@ -75,27 +66,16 @@ module Vx
|
|
75
66
|
def start_container(&block)
|
76
67
|
container =
|
77
68
|
with_retries ::Docker::Error::TimeoutError, limit: 5, sleep: 3 do
|
78
|
-
|
79
|
-
::Docker::Container.create create_container_options
|
80
|
-
end
|
69
|
+
::Docker::Container.create create_container_options
|
81
70
|
end
|
82
71
|
|
83
|
-
|
84
|
-
container_type: "docker",
|
85
|
-
container: container.json
|
86
|
-
}
|
87
|
-
|
88
|
-
instrument("start", instrumentation) do
|
89
|
-
container.start
|
90
|
-
end
|
72
|
+
container.start
|
91
73
|
|
92
74
|
begin
|
93
75
|
yield container
|
94
76
|
ensure
|
95
|
-
|
96
|
-
|
97
|
-
container.remove
|
98
|
-
end
|
77
|
+
container.kill
|
78
|
+
container.remove
|
99
79
|
end
|
100
80
|
end
|
101
81
|
|
@@ -17,18 +17,14 @@ module Vx ; module Lib ; module Container ;
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def start(&block)
|
20
|
-
|
21
|
-
|
22
|
-
FileUtils.mkdir_p(work_dir)
|
23
|
-
end
|
20
|
+
FileUtils.rm_rf(work_dir)
|
21
|
+
FileUtils.mkdir_p(work_dir)
|
24
22
|
|
25
23
|
begin
|
26
24
|
spawner = Spawner.new(work_dir)
|
27
25
|
yield spawner
|
28
26
|
ensure
|
29
|
-
|
30
|
-
FileUtils.mkdir_p(work_dir)
|
31
|
-
end
|
27
|
+
FileUtils.mkdir_p(work_dir)
|
32
28
|
end
|
33
29
|
end
|
34
30
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-lib-container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -100,7 +100,6 @@ files:
|
|
100
100
|
- lib/vx/lib/container/errors.rb
|
101
101
|
- lib/vx/lib/container/local.rb
|
102
102
|
- lib/vx/lib/container/local/spawner.rb
|
103
|
-
- lib/vx/lib/container/mixin/instrument.rb
|
104
103
|
- lib/vx/lib/container/mixin/retriable.rb
|
105
104
|
- lib/vx/lib/container/mixin/upload.rb
|
106
105
|
- lib/vx/lib/container/version.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Lib
|
3
|
-
module Container
|
4
|
-
module Instrument
|
5
|
-
|
6
|
-
def instrument(name, payload, &block)
|
7
|
-
name = "#{name}.container.lib.vx"
|
8
|
-
|
9
|
-
if ENV['DEBUG']
|
10
|
-
$stdout.puts " --> #{name}: #{payload}"
|
11
|
-
end
|
12
|
-
|
13
|
-
if inst = Container.instrumenter
|
14
|
-
inst.instrument(name, payload, &block)
|
15
|
-
else
|
16
|
-
yield if block_given?
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|