Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Fixes #147

Merged
merged 22 commits into from Jun 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
190ed7b
cleaning up rubocop errors and warnings
Apr 24, 2014
8ea4ff0
update to Berkshelf3
Apr 24, 2014
76ebb2d
added per-platform testing in cgroups
Apr 28, 2014
f1b10a3
added platform-specific tests to cgroup spec
Apr 28, 2014
2fda221
added platform-specific tests for default spec
Apr 28, 2014
503f99e
added platform-specific specs to lxc_spec
Apr 28, 2014
1b36d8f
added platform-specific specs to package_spec; fixed type in package …
Apr 28, 2014
f505399
moved git/golang install to source recipe; added checks for parameter…
Apr 28, 2014
af3f18d
adding platform specific tests to sysc_spec
Apr 28, 2014
7ad2619
adding platform specific tests for upstart_spec
Apr 28, 2014
6535ede
added dep_check recipe and specs so we can provide helpful error mess…
Apr 28, 2014
9479a07
testing overhaul - full suite of serverspec tests for test-kitchen
Apr 29, 2014
2547c39
adding dep_check recipe to default recipe
Apr 29, 2014
b594d86
adding error message if package method isn't supported for platform
Apr 29, 2014
409ebf0
finished chefspec tests for platforms
May 2, 2014
f1a568c
add warn/fatal option to dep_check
May 2, 2014
30ae065
added more complete binary installation based on docker docs
May 2, 2014
635f750
added note that source doesnt actually work
May 2, 2014
d61525f
added notes about status up to this point
May 2, 2014
470c823
Merge branch 'master' of github.com:bflad/chef-docker
Jun 4, 2014
be76e26
accidentally left merge stuff in there
Jun 4, 2014
218229d
bad dep check for RHEL
Jun 11, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
120 changes: 100 additions & 20 deletions .kitchen.yml
Expand Up @@ -5,42 +5,51 @@ driver_config:
customize:
memory: 1024

provisioner:
name: chef_zero
require_chef_omnibus: latest
data_path: test/shared
attributes:
docker:
container_cmd_timeout: 30


platforms:
- name: centos-6
- name: centos-6.5
run_list:
- recipe[build-essential]
driver_config:
box: opscode-centos-6.5
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box
require_chef_omnibus: latest
- name: debian-7
#- name: oracle-6
#- name: macosx-10.7
#- name: macosx-10.8
#- name: macosx-10.9
#- name: opensuse-12.3
- name: debian-7.2
driver_config:
box: opscode-debian-7.2.0
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.2.0_chef-provisionerless.box
require_chef_omnibus: latest
- name: debian-7.4
driver_config:
box: opscode-debian-7.4
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.4_chef-provisionerless.box
- name: fedora-19
driver_config:
box: opscode-fedora-19
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-19_chef-provisionerless.box
require_chef_omnibus: latest
- name: fedora-20
driver_config:
box: opscode-fedora-20
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-20_chef-provisionerless.box
require_chef_omnibus: latest
- name: ubuntu-12.04
driver_config:
box: opscode-ubuntu-12.04
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box
require_chef_omnibus: latest
- name: ubuntu-12.10
driver_config:
box: opscode-ubuntu-12.10
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.10_chef-provisionerless.box
require_chef_omnibus: latest
- name: ubuntu-13.04
driver_config:
box: opscode-ubuntu-13.04
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.04_chef-provisionerless.box
require_chef_omnibus: latest
- name: ubuntu-13.10
driver_config:
box: opscode-ubuntu-13.10
Expand All @@ -53,23 +62,94 @@ platforms:
require_chef_omnibus: latest

suites:
- name: docker-lwrp-native
#
# Package Installations
#
- name: package-native
run_list:
- recipe[minitest-handler]
- recipe[docker_test::default]
- recipe[docker_test::image_lwrp]
- recipe[docker_test::container_lwrp]
attributes:
docker:
container_cmd_timeout: 30
- name: docker-lwrp-lxc
install_type: package
- name: package-lxc
run_list:
- recipe[minitest-handler]
- recipe[lxc]
- recipe[docker_test::default]
- recipe[docker_test::image_lwrp]
- recipe[docker_test::container_lwrp]
attributes:
docker:
container_cmd_timeout: 30
install_type: package
exec_driver: lxc

#
# Binary Installations
#
- name: binary-native
excludes:
- centos-6.5
run_list:
- recipe[docker_test::default]
- recipe[docker_test::image_lwrp]
- recipe[docker_test::container_lwrp]
attributes:
docker:
install_type: binary
- name: binary-lxc
excludes:
- centos-6.5
run_list:
- recipe[docker_test::default]
- recipe[docker_test::image_lwrp]
- recipe[docker_test::container_lwrp]
attributes:
docker:
install_type: binary
exec_driver: lxc


#
# Source Installations
#
#- name: source-native
# excludes:
# - centos-6.5
# run_list:
# - recipe[docker_test::default]
# - recipe[docker_test::image_lwrp]
# - recipe[docker_test::container_lwrp]
# attributes:
# docker:
# install_type: source
#- name: source-lxc
# excludes:
# - centos-6.5
# run_list:
# - recipe[docker_test::default]
# - recipe[docker_test::image_lwrp]
# - recipe[docker_test::container_lwrp]
# attributes:
# docker:
# install_type: source
# exec_driver: lxc

#
# Archived Tests
#
#- name: docker-lwrp-native
# run_list:
# - recipe[minitest-handler]
# - recipe[docker_test::default]
# - recipe[docker_test::image_lwrp]
# - recipe[docker_test::container_lwrp]
#- name: docker-lwrp-lxc
# run_list:
# - recipe[minitest-handler]
# - recipe[lxc]
# - recipe[docker_test::default]
# - recipe[docker_test::image_lwrp]
# - recipe[docker_test::container_lwrp]
# attributes:
# docker:
# exec_driver: lxc
6 changes: 3 additions & 3 deletions .rubocop.yml
Expand Up @@ -5,9 +5,9 @@ AllCops:
- Guardfile
- Rakefile
Exclude:
- test/**
- vendor/**
- ruby/**
- test/**/*
- vendor/**/*
- ruby/**/*

AlignParameters:
Enabled: false
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Expand Up @@ -17,6 +17,21 @@ Attribute deprecations so you can be sure you can upgrade:
* container LWRP Fixnum port attribute: use full String notation from Docker documentation in port attribute instead
* container LWRP public_port attribute: use port attribute instead

## Development
* Binary Installation
* Added missing dependency resolution for using the binary.
* Dependency Checks
* Added `docker::dep_check` that will take an action if certain dependencies are not met.
* `node[docker][alert_on_error_action] = :fatal` will kill the chef run and print the error message.
* `node[docker][alert_on_error_action] = :warn` will print the error message but continue with the chef run. There is no guarantee that it will succeed though.
* KitchenCI
* Copied MiniTests to ServerSpec Tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a huge to-do for me to learn. I really appreciate the work here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're welcome!

* Added new platforms (Debian 7.4)
* Changed provisioner from chef-solo to chef-zero
* Removed Ubuntu 12.10 because it is not supported by Docker and the Kernel is bad and fails all the tests.
* Removed tests for the source recipe. The dotcloud/docker repo actually doesn’t build any Go deliverables.
* I think that the source recipe needs to be completely refactored.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely. I haven't really touched the source recipe since Docker 0.1 came out.


## 0.35.0 (unreleased)

* [#142][]: Bugfix: Redeploy breaks when a link is present
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org'
gem 'rake'

group :test, :integration do
gem 'berkshelf', '~> 2.0.14'
gem 'berkshelf', '~> 3.0'
end

group :test do
Expand Down
34 changes: 34 additions & 0 deletions TESTING.md
Expand Up @@ -45,3 +45,37 @@ Development
- `bundle exec kitchen test`

7. Assuming the tests pass, open a Pull Request on GitHub

Instance Status Reason
package-native-centos-65 pass
package-native-debian-72 pass
package-native-debian-74 pass
package-native-fedora-19 pass
package-native-fedora-20 pass
package-native-ubuntu-1204 pass
package-native-ubuntu-1304 pass
package-native-ubuntu-1310 pass
package-lxc-centos-65 pass
package-lxc-debian-72 pass
package-lxc-debian-74 pass
package-lxc-fedora-19 fail fedora doesn’t like lxc
package-lxc-fedora-20 fail fedora doesn’t like lxc
package-lxc-ubuntu-1204 pass
package-lxc-ubuntu-1304 pass
package-lxc-ubuntu-1310 pass
binary-native-centos-65 fail bad kernel 2.6.32
binary-native-debian-72 pass
binary-native-debian-74 pass
binary-native-fedora-19 pass
binary-native-fedora-20 pass
binary-native-ubuntu-1204 pass
binary-native-ubuntu-1304 pass
binary-native-ubuntu-1310 pass
binary-lxc-centos-65 (skipped) bad kernel
binary-lxc-debian-72 unstable
binary-lxc-debian-74 pass
binary-lxc-fedora-19 fail
binary-lxc-fedora-20 fail
binary-lxc-ubuntu-1204 pass
binary-lxc-ubuntu-1304 pass
binary-lxc-ubuntu-1310 pass
6 changes: 5 additions & 1 deletion attributes/default.rb
Expand Up @@ -23,7 +23,7 @@
'default' => 'upstart'
)
default['docker']['install_type'] = value_for_platform(
%w(amazon centos debian fedora redhat ubuntu) => {
%w(centos debian fedora redhat ubuntu mac_os_x) => {
'default' => 'package'
},
'default' => 'binary'
Expand All @@ -39,6 +39,9 @@
default['docker']['logfile'] = nil
default['docker']['version'] = nil

# Actions: :warn, :fatal
default['docker']['alert_on_error_action'] = :fatal

## Binary installation attributes

default['docker']['binary']['version'] = node['docker']['version'] || 'latest'
Expand Down Expand Up @@ -143,3 +146,4 @@
## docker_registry attributes

default['docker']['registry_cmd_timeout'] = 60

65 changes: 65 additions & 0 deletions libraries/helpers.rb
Expand Up @@ -3,6 +3,31 @@

# Helpers module
module Helpers

def binary_installed?(bin)
!shell_out("which #{bin}").error?
end

#
# Pairs with the dep_check recipe.
#
# Parameters:
# @execption - DockerCookbook exception to throw
# @action - symbol representing which action to take
# @msg - string of message to print
#
def alert_on_error(exception, action, msg)
case action
when :warn
Chef::Log.warn <<-MSG
WARNING: #{exception}
#{msg}
MSG
when :fatal
fail exception, msg
end
end

# Helpers::Docker module
module Docker
# Exception to signify that the Docker daemon is not yet ready to handle
Expand Down Expand Up @@ -251,3 +276,43 @@ def execute_cmd!(cmd, timeout = new_resource.cmd_timeout)
end
end
end

class Chef
class Node

def has_recipe?(recipe_name)
loaded_recipes.include?(with_default(recipe_name))
end

private

#
# Automatically appends "+::default+" to recipes that need them.
#
# @param [String] name
#
# @return [String]
#
def with_default(name)
name.include?('::') ? name : "#{name}::default"
end

#
# The list of loaded recipes on the Chef run (normalized)
#
# @return [Array<String>]
#
def loaded_recipes
node.run_context.loaded_recipes.map { |name| with_default(name) }
end
end
end

class DockerCookbook
class Exceptions
class MissingDependency < RuntimeError; end
class InvalidPlatformVersion < StandardError; end
class InvalidArchitecture < StandardError; end
class InvalidKernelVersion < StandardError; end
end
end
1 change: 1 addition & 0 deletions metadata.rb
Expand Up @@ -36,6 +36,7 @@
depends 'git'
depends 'golang'
depends 'homebrew'
depends 'iptables'
depends 'lxc', '>= 1.1.6'
depends 'modules'
depends 'runit'
Expand Down