-
Notifications
You must be signed in to change notification settings - Fork 16
Config + hook approach for restarting docker #54
Conversation
|
||
config.vm.box = "projectatomic/adb" | ||
|
||
config.vm.network "private_network", type: "dhcp" |
There was a problem hiding this comment.
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.
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"? |
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@LalatenduMohanty done with sqashing commit. |
Latest changes includes provider centric service operation. |
def validate_providers | ||
errors = [] | ||
|
||
if !Set[@providers.split(',').map(&:strip)].subset?(Set[PROVIDERS]) |
There was a problem hiding this comment.
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.
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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is working. 😄 .
Just omit config line from Vagrantfile. This line is doing the trick for it.
Excellent!
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' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/ ?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Can we somehow validate the commands in vagrant-service-manager/command.rb by using what is provided in the ruby file in providers? |
@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. |
@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
|
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. |
How about this?
Above lines are just imaginary which I think possible and would be reference for my working. |
@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? |
@bexelbie Oh ok. I thought it would be only one line than having multiple lines. |
+1 We basically offer one option for everything we think is relevant and should be configurable. |
Need more info about it. Could you elaborate it little bit? |
Agree. We might want to do that in a separate PR |
+1. We dont need json kind of structure |
@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. |
+1 for the idea 😄 .
|
@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). |
There was a problem hiding this comment.
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:
- Get a Vagrantfile for your box. Users of the Atomic Developer Bundle (ADB) should download a Vagrantfile from the repository.
I added some line notes. |
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 This should help user have the plugin installed and not having any interception while working with non-supported boxes. |
@LalatenduMohanty , @navidshaikh , @bexelbie updated with changes. Now only Also tested with "cdk" with box |
@machine.communicate.execute(command) do |type, data| | ||
if type == :stderr | ||
@ui.error(data) | ||
exit 126 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
@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 |
There was a problem hiding this comment.
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
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. |
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
LGTM with new issue coming |
Config + hook approach for restarting docker
Fix: #12 and #21.
With this approach
Vagrantfile
will look like