Skip to content
This repository has been archived by the owner on Jul 29, 2018. It is now read-only.

Config + hook approach for restarting docker #54

Merged
merged 1 commit into from
Mar 1, 2016
Merged

Config + hook approach for restarting docker #54

merged 1 commit into from
Mar 1, 2016

Conversation

coolbrg
Copy link
Contributor

@coolbrg coolbrg commented Feb 17, 2016

Fix: #12 and #21.

With this approach Vagrantfile will look like

 Vagrant.configure(2) do |config|
  config.vm.box = "projectatomic/adb"
  config.vm.network "private_network", type: "dhcp"
  config.servicemanager.providers = 'docker'
end


config.vm.box = "projectatomic/adb"

config.vm.network "private_network", type: "dhcp"
Copy link
Contributor

Choose a reason for hiding this comment

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

This example should probably be the only line cited.

The Vagrantfile should contain comments with the list and format.

@bexelbie
Copy link
Contributor

Can we also get a changelog modification? Can you build a test ADB and gem that we can send out for use as a "nightly"?

@LalatenduMohanty
Copy link
Collaborator

We should squash the commits in to one.

@@ -1,9 +1,20 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

unless Vagrant.has_plugin?("vagrant-service-manager")
raise <<-MSG
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you examine this code relative to this: projectatomic/adb-atomic-developer-bundle#245

Can we do a cleaner error and exit?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd still like to see this as a print to STDERR and exit combination.

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 23, 2016

@LalatenduMohanty done with sqashing commit.

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 23, 2016

@bexelbie,

Latest changes includes provider centric service operation.

def validate_providers
errors = []

if !Set[@providers.split(',').map(&:strip)].subset?(Set[PROVIDERS])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If specified provider(s) in configuration is not listed in PROVIDERS then it errors out.

@coolbrg coolbrg mentioned this pull request Feb 23, 2016
config.vm.box = "projectatomic/adb"

config.vm.network "private_network", type: "dhcp"

# enable multiple providers as comma separated list. Eg: 'docker, openshift'
config.servicemanager.providers = 'docker'
Copy link
Contributor

Choose a reason for hiding this comment

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

why the need for explicitly enabling this? Does this also mean that the docker certificates are only generated if the docker provider is set? They should really be generated regardless.

The aim is zero conf Vagrantfile. I think this config should not be required.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this also mean that the docker certificates are only generated if the docker provider is set? They should really be generated regardless.

I agree.

The aim is zero conf Vagrantfile. I think this config should not be required.

For docker provider yes, for other providers we may need config in Vagrantfile.

Copy link
Contributor

Choose a reason for hiding this comment

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

For docker provider yes, for other providers we may need config in Vagrantfile.

Ok, seems reasonable. We seem to agree the proper configuration of Docker is a given. There is no need to explicitly configure it. What other providers are there? Kubernetes vs OpenShift? Is really OpenShift not a super-set of Kubernetes here? Also OpenShift is the default. It could be generated unless something else is explicitly configured. Again, the aim is zero config Vagrantfile. Let's discuss the need for configuring other providers, but Docker should just work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What other providers are there?

Apart from kube and openshift, Mesos-Marathon

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this also mean that the docker certificates are only generated if the docker provider is set? They should really be generated regardless.

Need to check if the approach we are following (config + hook) can trigger task of configuring-docker without any mention of config in Vagrantfile explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this also mean that the docker certificates are only generated if the docker provider is set? They should really be generated regardless.

@navidshaikh , @hferentschik
It is working. 😄 .
Just omit config line from Vagrantfile. This line is doing the trick for it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@budhrg

It is working. 😄 .
Just omit config line from Vagrantfile. This line is doing the trick for it.

Excellent!

@bexelbie
Copy link
Contributor

Should execute_docker_info in lib/vagrant-service-manager/command.rb actually be in lib/vagrant-service-manager/providers/docker.rb ?

@@ -1,3 +1,5 @@
require_relative 'providers/docker'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we require_relative 'providers/*' to eliminate the need to edit this file when adding new services?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should this be called services/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bexelbie , @navidshaikh :
Would it better if we use consistent naming? I would like to agree with the term service.
This line will be require_relative 'services/docker' or
Dir.glob('lib/*.rb') { |f| require_relative f }(best I could) for automatically adding new services.

Also, Vagrantfile line as:
config.servicemanager.services = 'openshift'(docker default hence this line will not be needed).

And class name Provider to Service.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 service(s) - it really opens up the options for this plugin and makes the language so much better

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 Service is the better term. I think we need to aim for a consistent terminology not only in this plugin, but across the whole ADB/CDK. "The CDK offers a OpenShift service" or "To enable the Kubernetes service ...", etc

@bexelbie
Copy link
Contributor

Can we somehow validate the commands in vagrant-service-manager/command.rb by using what is provided in the ruby file in providers?

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 24, 2016

Should execute_docker_info in lib/vagrant-service-manager/command.rb actually be in lib/vagrant-service-manager/providers/docker.rb ?

@bexelbie , @LalatenduMohanty , @navidshaikh : Let's discuss such changes as part of #49 . There are other more things I need to discuss as part of refactoring.

@bexelbie
Copy link
Contributor

@budhrg Can you think about this idea, even if it comes in a separate patch.

If projectatomic/adb-utils#45 merges, it would be nice to be able to do this in the vagrant file

config.vm.service-manager.openshift.image_name = "openshift/origin"
config.vm.service-manager.openshift.image_tag = "latest"
config.vm.service-manager.openshift.docker_registry = "docker.io"

And have those values available for a later provisioner shell call.

bonus points if the presence of any those caused to assume this line:

config.vm.service-manager.provision = 'openshift'

@hferentschik
Copy link
Contributor

Awesome. Now we start talking. This is exactly what I had in mind. The service-manager basically offering nice and simple extension/config options to handle some of these default things. Much better than fiddling around with sed and co in some shell provisioning script. It would be awesome, if we could get this all sorted for GA. Also needs of course be well documented.

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 26, 2016

@bexelbie , @hferentschik :

config.vm.service-manager.openshift.image_name = "openshift/origin"
config.vm.service-manager.openshift.image_tag = "latest"
config.vm.service-manager.openshift.docker_registry = "docker.io"
....... or more such lines possibly ....

How about this?

config.servicemanager.provision(or service) = 'openshift'   # enable openshift
config.servicemanager.service.openshift = { image: "openshift/origin", tag: "latest", docker_registry: "docker.io", (other values too...)}
# above values will be available to later provisioners

Above lines are just imaginary which I think possible and would be reference for my working.
Please correct me if I interpreted it differently.

@bexelbie
Copy link
Contributor

@budhrg I'm not a vagrant expert but it feels like making the user write json in the Vagrantfile is weird and an anti-pattern. The other feels cleaner to me. Why are you suggesting this?

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 26, 2016

@bexelbie Oh ok. I thought it would be only one line than having multiple lines.
Also agree that multi-line approach would be far more comfortable for users than json which would be syntax error prone.
Thanks for clarification.

@hferentschik
Copy link
Contributor

Also agree that multi-line approach would be far more comfortable for users than json

+1 We basically offer one option for everything we think is relevant and should be configurable.

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 26, 2016

@bexelbie

Can we somehow validate the commands in vagrant-service-manager/command.rb by using what is provided in the ruby file in providers?

Need more info about it. Could you elaborate it little bit?

@LalatenduMohanty
Copy link
Collaborator

Let's discuss such changes as part of #49 . There are other more things I need to discuss as part of refactoring.

Agree. We might want to do that in a separate PR

@LalatenduMohanty
Copy link
Collaborator

@budhrg I'm not a vagrant expert but it feels like making the user write json in the Vagrantfile is weird and an anti-pattern.

+1. We dont need json kind of structure

@bexelbie
Copy link
Contributor

@budhrg What I mean here is that it would be nice if the service could define what commands it could interact with. So for example if the foo service doesn't have an env verb then 'env foo' fails but we don't have to create a command table and order to know this. I suspect the word introspection somehow comes into play here.

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 26, 2016

+1 for the idea 😄 .
@bexelbie - This could be possible with Ruby Meta-programming(introspection) as what I could infer from your comment. Let's discuss it in the issue #79(Service driven command structure) as it has to be implemented well as it includes metaprogramming.*

  • Power comes with great responsibility

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 26, 2016

@bexelbie , @LalatenduMohanty , @navidshaikh - Done with suggested changes from my side.


vagrant plugin install vagrant-service-manager

2. Get the [Vagrantfile](Vagrantfile) and start the ADB using `vagrant up`. [More](https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/docs/installing.rst) documentation on setting up ADB.
2. Get the [Vagrantfile](Vagrantfile).
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a reference to the ADB repo. The Vagrantfile in this repo is for testing and should possibly be deleted or augmented.

I suggest:

  1. Get a Vagrantfile for your box. Users of the Atomic Developer Bundle (ADB) should download a Vagrantfile from the repository.

@bexelbie
Copy link
Contributor

I added some line notes.

@navidshaikh
Copy link
Collaborator

If we are looking for finding out the box OS, in case of non supported boxes, we should just return silently without any trace on the normal execution flow of vagrant up.

This should help user have the plugin installed and not having any interception while working with non-supported boxes.

@coolbrg
Copy link
Contributor Author

coolbrg commented Feb 29, 2016

@LalatenduMohanty , @navidshaikh , @bexelbie updated with changes. Now only adb and cdk boxes will run this plugin.

Also tested with "cdk" with box rhel-cdk-kubernetes-7.2-14.

@machine.communicate.execute(command) do |type, data|
if type == :stderr
@ui.error(data)
exit 126
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good!

@navidshaikh
Copy link
Collaborator

@LalatenduMohanty : Once you have tested the PR against non supported box, can you give feedback ?

@@ -1,5 +1,8 @@
# Changelog

## Unreleased
- Fix #12 and #21: Restart docker service on 'vagrant up' @budhrg
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kindly put this changelog on v0.0.3 release

@navidshaikh
Copy link
Collaborator

I tested this PR against projectatomic/adb and fedora/23-cloud-base for ensuring it identifies between supported and non supported boxes, works fine for me.

@navidshaikh
Copy link
Collaborator

LGTM!

* Updated README and CHANGELOG
* Checks dependency for vagrant-service-manager plugin in Vagrantfile
* Cleaner error and exit if plugin not found
* Added guest capability to know the box version(adb/cdk)
end

def call(env)
if SUPPORTED_BOXES.include? @machine.guest.capability(:flavor)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this inside of the docker hook and not at a higher level? This structure means that every time we add a new service we have to write this same code again.

I am going to LGTM this, but I am opening an issue to get this fixed as we need to get openshift, etc. added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed @bexelbie . Will work on it.

@bexelbie
Copy link
Contributor

bexelbie commented Mar 1, 2016

LGTM with new issue coming

bexelbie added a commit that referenced this pull request Mar 1, 2016
Config + hook approach for restarting docker
@bexelbie bexelbie merged commit 1e15105 into projectatomic:master Mar 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants