contained_mr 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0939e46065ffcf543130f1ed6243a896482a286c
4
- data.tar.gz: 3dee0167b3909de88614c152777feb90673e3874
3
+ metadata.gz: b85709886ebd903cf0ce3ebc0843fd1b9122faff
4
+ data.tar.gz: d9a4f3fb295ea57d39b7ee5f21526c5ed7903d79
5
5
  SHA512:
6
- metadata.gz: 9d1296d5f4926d089a5669028f71cba8486575463e0eb2b0de3a264c6e05d8f27a014270b29e30990307681063a39dedfccef6e596d6ba83c577897e56a11269
7
- data.tar.gz: 1d2a656d0b2001fa683ee76e4b9e59294ea1a315ef8cea99770fffd2daafc43e3634dc34b42ab28a75b3bc68b3d0c4e97faa508e83250a829949c39d14716e2a
6
+ metadata.gz: dd44006c2a201c54d0aeee2fc3a4815c231acfddebd87cdb8b022b3be3bd0152ff0a3dfa95197b71dd4e4f5e048881ec6864e40ac7274809e42cd6d3f2e42fcd
7
+ data.tar.gz: 8118a13d9c80711bff4ec08277bdef4719a4f89c2e81779a3c5c8d6a12933bc91978167fb2cb06dc0cbe276f864b3a23bc1c24a03490aa060399290e6ec96f2b
@@ -1,13 +1,16 @@
1
1
  sudo: required
2
+ dist: trusty
2
3
  language: ruby
3
- services:
4
- - docker
5
4
  rvm:
6
5
  - 2.2.4
7
6
  - 2.3.0
8
7
  before_install:
8
+ - sudo apt-get update
9
+ - sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-engine
9
10
  - gem install bundler
10
11
  before_script:
11
12
  - bundle install --jobs=3 --retry=3 --deployment
13
+ - docker version
14
+ - docker info
12
15
  script:
13
- - rake test
16
+ - bundle exec rake test
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'docker-api', '>= 1.24.1', require: 'docker'
3
+ gem 'docker-api', '>= 1.26.2', require: 'docker'
4
4
  gem 'rubyzip', '>= 1.1.7', require: 'zip'
5
5
 
6
6
  # Add dependencies to develop your gem here.
@@ -10,6 +10,7 @@ group :development do
10
10
  gem 'jeweler', '>= 2.0.1'
11
11
  gem 'minitest', '>= 5.8.3'
12
12
  gem 'mocha', '>= 1.1.0'
13
+ gem 'rake', '>= 11.1.2'
13
14
  gem 'rdoc', '>= 4.2.0'
14
15
  gem 'simplecov', '>= 0.10.0'
15
16
  gem 'yard', '>= 0.8.7.6'
@@ -6,13 +6,13 @@ GEM
6
6
  descendants_tracker (0.0.4)
7
7
  thread_safe (~> 0.3, >= 0.3.1)
8
8
  docile (1.1.5)
9
- docker-api (1.24.1)
9
+ docker-api (1.26.2)
10
10
  excon (>= 0.38.0)
11
11
  json
12
- excon (0.45.4)
12
+ excon (0.48.0)
13
13
  faraday (0.9.2)
14
14
  multipart-post (>= 1.2, < 3)
15
- git (1.2.9.1)
15
+ git (1.3.0)
16
16
  github_api (0.13.1)
17
17
  addressable (~> 2.4.0)
18
18
  descendants_tracker (~> 0.0.4)
@@ -32,29 +32,29 @@ GEM
32
32
  rake
33
33
  rdoc
34
34
  json (1.8.3)
35
- jwt (1.5.2)
35
+ jwt (1.5.1)
36
36
  metaclass (0.0.4)
37
37
  mini_portile2 (2.0.0)
38
- minitest (5.8.3)
38
+ minitest (5.8.4)
39
39
  mocha (1.1.0)
40
40
  metaclass (~> 0.0.1)
41
41
  multi_json (1.11.2)
42
42
  multi_xml (0.5.5)
43
43
  multipart-post (2.0.0)
44
- nokogiri (1.6.7.1)
44
+ nokogiri (1.6.7.2)
45
45
  mini_portile2 (~> 2.0.0.rc2)
46
- oauth2 (1.0.0)
46
+ oauth2 (1.1.0)
47
47
  faraday (>= 0.8, < 0.10)
48
- jwt (~> 1.0)
48
+ jwt (~> 1.0, < 1.5.2)
49
49
  multi_json (~> 1.3)
50
50
  multi_xml (~> 0.5)
51
- rack (~> 1.2)
51
+ rack (>= 1.2, < 3)
52
52
  rack (1.6.4)
53
- rake (10.4.2)
54
- rdoc (4.2.1)
53
+ rake (11.1.2)
54
+ rdoc (4.2.2)
55
55
  json (~> 1.4)
56
- rubyzip (1.1.7)
57
- simplecov (0.11.1)
56
+ rubyzip (1.2.0)
57
+ simplecov (0.11.2)
58
58
  docile (~> 1.1.0)
59
59
  json (~> 1.8)
60
60
  simplecov-html (~> 0.10.0)
@@ -67,10 +67,11 @@ PLATFORMS
67
67
 
68
68
  DEPENDENCIES
69
69
  bundler (>= 1.6.1)
70
- docker-api (>= 1.24.1)
70
+ docker-api (>= 1.26.2)
71
71
  jeweler (>= 2.0.1)
72
72
  minitest (>= 5.8.3)
73
73
  mocha (>= 1.1.0)
74
+ rake (>= 11.1.2)
74
75
  rdoc (>= 4.2.0)
75
76
  rubyzip (>= 1.1.7)
76
77
  simplecov (>= 0.10.0)
data/README.md CHANGED
@@ -6,6 +6,13 @@
6
6
  Map-Reduce where both the mappers and the reducer run inside Docker containers.
7
7
 
8
8
 
9
+ ## Prerequisites
10
+
11
+ `contained-mr` requires [docker](https://github.com/docker/docker) version 1.9
12
+ or above. If used, [docker-swarm](https://github.com/docker/swarm) must be at
13
+ vesion 1.0 or above.
14
+
15
+
9
16
  ## Development Environment
10
17
 
11
18
  `contained-mr` requires access to a Docker Swarm daemon. The easiest way to
data/Rakefile CHANGED
@@ -29,7 +29,8 @@ require 'rake/testtask'
29
29
  Rake::TestTask.new(:test) do |test|
30
30
  test.libs << 'lib' << 'test'
31
31
  test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
32
+ test.verbose = false
33
+ test.warning = false
33
34
  end
34
35
 
35
36
  desc "Code coverage detail"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: contained_mr 0.5.0 ruby lib
5
+ # stub: contained_mr 0.6.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "contained_mr"
9
- s.version = "0.5.0"
9
+ s.version = "0.6.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Victor Costan"]
14
- s.date = "2016-01-29"
14
+ s.date = "2016-03-28"
15
15
  s.description = "Plumbing for running mappers and reducers inside Docker containers"
16
16
  s.email = "victor@costan.us"
17
17
  s.extra_rdoc_files = [
@@ -75,33 +75,36 @@ Gem::Specification.new do |s|
75
75
  s.specification_version = 4
76
76
 
77
77
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
78
- s.add_runtime_dependency(%q<docker-api>, [">= 1.24.1"])
78
+ s.add_runtime_dependency(%q<docker-api>, [">= 1.26.2"])
79
79
  s.add_runtime_dependency(%q<rubyzip>, [">= 1.1.7"])
80
80
  s.add_development_dependency(%q<bundler>, [">= 1.6.1"])
81
81
  s.add_development_dependency(%q<jeweler>, [">= 2.0.1"])
82
82
  s.add_development_dependency(%q<minitest>, [">= 5.8.3"])
83
83
  s.add_development_dependency(%q<mocha>, [">= 1.1.0"])
84
+ s.add_development_dependency(%q<rake>, [">= 11.1.2"])
84
85
  s.add_development_dependency(%q<rdoc>, [">= 4.2.0"])
85
86
  s.add_development_dependency(%q<simplecov>, [">= 0.10.0"])
86
87
  s.add_development_dependency(%q<yard>, [">= 0.8.7.6"])
87
88
  else
88
- s.add_dependency(%q<docker-api>, [">= 1.24.1"])
89
+ s.add_dependency(%q<docker-api>, [">= 1.26.2"])
89
90
  s.add_dependency(%q<rubyzip>, [">= 1.1.7"])
90
91
  s.add_dependency(%q<bundler>, [">= 1.6.1"])
91
92
  s.add_dependency(%q<jeweler>, [">= 2.0.1"])
92
93
  s.add_dependency(%q<minitest>, [">= 5.8.3"])
93
94
  s.add_dependency(%q<mocha>, [">= 1.1.0"])
95
+ s.add_dependency(%q<rake>, [">= 11.1.2"])
94
96
  s.add_dependency(%q<rdoc>, [">= 4.2.0"])
95
97
  s.add_dependency(%q<simplecov>, [">= 0.10.0"])
96
98
  s.add_dependency(%q<yard>, [">= 0.8.7.6"])
97
99
  end
98
100
  else
99
- s.add_dependency(%q<docker-api>, [">= 1.24.1"])
101
+ s.add_dependency(%q<docker-api>, [">= 1.26.2"])
100
102
  s.add_dependency(%q<rubyzip>, [">= 1.1.7"])
101
103
  s.add_dependency(%q<bundler>, [">= 1.6.1"])
102
104
  s.add_dependency(%q<jeweler>, [">= 2.0.1"])
103
105
  s.add_dependency(%q<minitest>, [">= 5.8.3"])
104
106
  s.add_dependency(%q<mocha>, [">= 1.1.0"])
107
+ s.add_dependency(%q<rake>, [">= 11.1.2"])
105
108
  s.add_dependency(%q<rdoc>, [">= 4.2.0"])
106
109
  s.add_dependency(%q<simplecov>, [">= 0.10.0"])
107
110
  s.add_dependency(%q<yard>, [">= 0.8.7.6"])
@@ -65,9 +65,11 @@ class ContainedMr::Job
65
65
  end
66
66
 
67
67
  tar_io = mapper_tar_context mapper_input
68
- image = Docker::Image.build_from_tar tar_io, t: mapper_image_tag,
69
- forcerm: 1
70
- @mapper_image_id = image.id
68
+ Docker::Image.build_from_tar tar_io, mapper_image_options
69
+
70
+ # NOTE: The build process returns a short image ID. We need to perform
71
+ # another API call to get the canonical ID.
72
+ @mapper_image_id = Docker::Image.get(mapper_image_tag).id
71
73
  end
72
74
 
73
75
  # Builds the Docker image used to run this job's reducer.
@@ -82,9 +84,11 @@ class ContainedMr::Job
82
84
  end
83
85
 
84
86
  tar_io = reducer_tar_context
85
- image = Docker::Image.build_from_tar tar_io, t: reducer_image_tag,
86
- forcerm: 1
87
- @reducer_image_id = image.id
87
+ Docker::Image.build_from_tar tar_io, reducer_image_options
88
+
89
+ # NOTE: The build process returns a short image ID. We need to perform
90
+ # another API call to get the canonical ID.
91
+ @reducer_image_id = Docker::Image.get(reducer_image_tag).id
88
92
  end
89
93
 
90
94
  # Runs one of the job's mappers.
@@ -49,6 +49,24 @@ module ContainedMr::JobLogic
49
49
  "#{@name_prefix}/reducer.#{@id}"
50
50
  end
51
51
 
52
+ # @return {Hash<Symbol, Object>} options passed to the Docker API when
53
+ # building when building the mapper image
54
+ def mapper_image_options
55
+ {
56
+ t: mapper_image_tag, forcerm: 1,
57
+ buildargs: { 'affinity:image' => "=#{@template.image_tag}" }.to_json
58
+ }
59
+ end
60
+
61
+ # @return {Hash<Symbol, Object>} options passed to the Docker API when
62
+ # building when building the mapper image
63
+ def reducer_image_options
64
+ {
65
+ t: reducer_image_tag, forcerm: 1,
66
+ buildargs: { 'affinity:image' => "=#{@template.image_tag}" }.to_json
67
+ }
68
+ end
69
+
52
70
  # @return {Hash<String, Object>} params used to create a mapper container
53
71
  def mapper_container_options(i)
54
72
  ulimits = @mapper_options[:ulimits].map do |k, v|
@@ -77,8 +77,11 @@ class ContainedMr::Template
77
77
  #
78
78
  # @param {IO} tar_io IO implementation that produces the image's .tar file
79
79
  def build_image(tar_io)
80
- image = Docker::Image.build_from_tar tar_io, t: image_tag, forcerm: 1
81
- @image_id = image.id
80
+ Docker::Image.build_from_tar tar_io, t: image_tag, forcerm: 1
81
+
82
+ # NOTE: The build process returns a short image ID. We need to perform
83
+ # another API call to get the canonical ID.
84
+ @image_id = Docker::Image.get(image_tag).id
82
85
  end
83
86
  private :build_image
84
87
  end
@@ -70,6 +70,7 @@ module ContainedMr::TemplateLogic
70
70
  def job_dockerfile(job_definition, input_source)
71
71
  <<DOCKER_END
72
72
  FROM #{image_tag}
73
+ ARG affinity:image=
73
74
  COPY #{input_source} #{job_definition['input'] || '/input'}
74
75
  WORKDIR #{job_definition['chdir'] || '/'}
75
76
  ENTRYPOINT #{JSON.dump(job_definition['cmd'] || ['/bin/sh'])}
@@ -23,7 +23,7 @@ class TestJob < MiniTest::Test
23
23
 
24
24
  image = Docker::Image.get @job.mapper_image_tag
25
25
  assert image, 'Docker::Image'
26
- assert_operator image.id, :start_with?, @job.mapper_image_id
26
+ assert_equal image.id, @job.mapper_image_id
27
27
 
28
28
  1.upto 3 do |i|
29
29
  assert_nil @job.mapper_runner(i), "Mapper #{i} started prematurely"
@@ -48,8 +48,7 @@ class TestJob < MiniTest::Test
48
48
  def test_created_mapper_image_tags
49
49
  @job.build_mapper_image File.read('testdata/input.hello')
50
50
 
51
- images = Docker::Image.all
52
- image = images.find { |i| i.id.start_with? @job.mapper_image_id }
51
+ image = Docker::Image.get @job.mapper_image_id
53
52
  assert image, 'Docker::Image in collection returned by Docker::Image.all'
54
53
  assert image.info['RepoTags'], "Image missing RepoTags: #{image.inspect}"
55
54
  assert_includes image.info['RepoTags'],
@@ -97,12 +96,11 @@ class TestJob < MiniTest::Test
97
96
  @job.build_reducer_image
98
97
  image = Docker::Image.get @job.reducer_image_tag
99
98
  assert image, 'Docker::Image'
100
- assert_operator image.id, :start_with?, @job.reducer_image_id
99
+ assert_equal image.id, @job.reducer_image_id
101
100
 
102
101
  assert_nil @job.reducer_runner, "Reducer started prematurely"
103
102
 
104
- images = Docker::Image.all
105
- image = images.find { |i| i.id.start_with? @job.reducer_image_id }
103
+ image = Docker::Image.get @job.reducer_image_id
106
104
  assert image, 'Docker::Image in collection returned by Docker::Image.all'
107
105
  assert image.info['RepoTags'], "Image missing RepoTags: #{image.inspect}"
108
106
  assert_includes image.info['RepoTags'],
@@ -17,6 +17,22 @@ class TestJobLogic < MiniTest::Test
17
17
  assert_equal 'contained_mrtests/reducer.testjob', @job.reducer_image_tag
18
18
  end
19
19
 
20
+ def test_mapper_image_options
21
+ golden = {
22
+ t: 'contained_mrtests/mapper.testjob', forcerm: 1,
23
+ buildargs: '{"affinity:image":"=contained_mrtests/base.hello"}'
24
+ }
25
+ assert_equal golden, @job.mapper_image_options
26
+ end
27
+
28
+ def test_reducer_image_options
29
+ golden = {
30
+ t: 'contained_mrtests/reducer.testjob', forcerm: 1,
31
+ buildargs: '{"affinity:image":"=contained_mrtests/base.hello"}'
32
+ }
33
+ assert_equal golden, @job.reducer_image_options
34
+ end
35
+
20
36
  def test_mapper_container_options
21
37
  assert_equal @template, @job.template
22
38
  assert_equal 'contained_mrtests', @job.name_prefix
@@ -20,8 +20,7 @@ class TestTemplate < MiniTest::Test
20
20
  end
21
21
 
22
22
  def test_created_image_tags
23
- images = Docker::Image.all
24
- image = images.find { |i| i.id.start_with? @template.image_id }
23
+ image = Docker::Image.get @template.image_id
25
24
  assert image, 'Docker::Image in collection returned by Docker::Image.all'
26
25
  assert image.info['RepoTags'], "Image missing RepoTags: #{image.inspect}"
27
26
  assert_includes image.info['RepoTags'],
@@ -1,4 +1,5 @@
1
1
  FROM contained_mrtests/base.hello
2
+ ARG affinity:image=
2
3
  COPY input /usr/mrd/map-input
3
4
  WORKDIR /usr/mrd
4
5
  ENTRYPOINT ["/bin/sh","/usr/mrd/mapper.sh"]
@@ -1,4 +1,5 @@
1
1
  FROM contained_mrtests/base.hello
2
+ ARG affinity:image=
2
3
  COPY . /usr/mrd/
3
4
  WORKDIR /
4
5
  ENTRYPOINT ["/bin/sh","/usr/mrd/reducer.sh"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contained_mr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-29 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.24.1
19
+ version: 1.26.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.24.1
26
+ version: 1.26.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 11.1.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 11.1.2
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rdoc
99
113
  requirement: !ruby/object:Gem::Requirement