vagrant-service-manager icon indicating copy to clipboard operation
vagrant-service-manager copied to clipboard

For CDK vagrant-service-manager should print OpenShift setup information during `vagrant up`

Open LalatenduMohanty opened this issue 8 years ago • 22 comments

Vagrant-service-manager (1.0.0) should print OpenShift setup information during vagrant up for CDK.

For CDK, vagrant-service-manager should print the below OpenShift information as it is the default in CDK.

==> default: 
==> default: Successfully started and provisioned VM with 2 cores and 3072 MB of memory.
==> default: To modify the number of cores and/or available memory set the environment variables
==> default: VM_CPU respectively VM_MEMORY.
==> default: 
==> default: You can now access the OpenShift console on: https://10.1.2.2:8443/console
==> default: 
==> default: To use OpenShift CLI, run:
==> default: $ vagrant ssh
==> default: $ oc login 10.1.2.2:8443
==> default: 
==> default: Configured users are (<username>/<password>):
==> default: openshift-dev/devel
==> default: admin/admin
==> default: 
==> default: If you have the oc client library on your host, you can also login from your host.

LalatenduMohanty avatar Apr 11 '16 07:04 LalatenduMohanty

Looks like lib/vagrant-service-manager/services/open_shift.rb needs to print the stdout

module Vagrant
  module ServiceManager
    class OpenShift
      def initialize(machine, ui)
        @machine = machine
        @ui = ui
        @extra_cmd = build_extra_command
      end

      def execute
        full_cmd = "#{@extra_cmd} sccli openshift"

        @machine.communicate.sudo(full_cmd) do |type, data|
          if type == :stderr
            @ui.error(data)
            exit 126
          end
        end
      end

      private

      def build_extra_command
        cmd = ''
        CONFIG_KEYS.select {|e| e[/^openshift_/] }.each do |key|
          unless @machine.config.servicemanager.send(key).nil?
            env_name = key.to_s.gsub(/openshift_/,'').upcase
            cmd += "#{env_name}='#{@machine.config.servicemanager.send(key)}' "
          end
        end
        cmd.chop
      end
    end
  end
end

LalatenduMohanty avatar Apr 11 '16 07:04 LalatenduMohanty

Now, whether the service-manager does print this setup information or not is debatable, but how is this going to solve the issue? There is nothing wrong with the current Vagrantfile afaict. It should be possible to add the script provisioning at this step. We need to find the underlying reason why Vagrant exits prematurely.

hferentschik avatar Apr 11 '16 08:04 hferentschik

@hferentschik Agree.

It does not solve https://github.com/projectatomic/adb-atomic-developer-bundle/issues/337.

But IMO it should print required openshift info. It is a step towards having a minimal Vagrantfile.

Ideall sccli openshift should print the info in stdout and vsm should pick them and display to user.

LalatenduMohanty avatar Apr 11 '16 11:04 LalatenduMohanty

Ideall sccli openshift should print the info in stdout and vsm should pick them and display to user.

+1 , this should also help handling services by one single component than having multiple components (sccli, vsm, Vagrantfile) configuring a single service. This helps configuring a service completely by one component, ensuring the rest part of configuration is not left over by another components and also not having the dependency on other components to do the rest of configuration.

navidshaikh avatar Apr 11 '16 11:04 navidshaikh

@LalatenduMohanty @navidshaikh : Moreover, we found that vagrant service-manager plugin is not executing extra provisioners present in Vagrantfile (https://github.com/projectatomic/vagrant-service-manager/issues/166).

brgnepal avatar Apr 11 '16 11:04 brgnepal

Moreover, we found that vagrant service-manager plugin is not executing extra provisioners present in Vagrantfile (#166)

Because proper exit codes were not returned from the opensihft configuration commands from sccli

navidshaikh avatar Apr 11 '16 15:04 navidshaikh

It does not solve projectatomic/adb-atomic-developer-bundle#337.

Ok, as long as we agree on that, I am fine :-)

But IMO it should print required openshift info.

Sounds reasonable. We just have to make sure that 'vagrant up' completes successfully and that potential additional provisioning steps get executed as expected.

It is a step towards having a minimal Vagrantfile.

+1

hferentschik avatar Apr 11 '16 18:04 hferentschik

Corresponding issue in adb-utils https://github.com/projectatomic/adb-utils/issues/55

LalatenduMohanty avatar Apr 12 '16 09:04 LalatenduMohanty

and for removing the lines from Vagrantfile https://github.com/projectatomic/adb-atomic-developer-bundle/issues/341

navidshaikh avatar Apr 12 '16 09:04 navidshaikh

BTW, the Vagrantfile is not such a bad location for this final access information, especially if we can get it into the box'es Vagrantfile. Just wondering whether it is really the responsibility of sccli or the plugin really. Also there is already vagrant service-manager env openshift.

hferentschik avatar Apr 12 '16 10:04 hferentschik

@hferentschik We should not put the OpenShift access information in to the Vagrantbox's Vagrantfile. Because that would mean always getting OpenShift information even if we just want docker , k8s or mesos. Though we can put complex ruby code in the Vagrantfile too to handle. But IMO code outside of the Vagrantfile (i.e. VSM) is better.

I think VSM/SCCLI should have this info as these are interfaces to CDK/ADB.

LalatenduMohanty avatar Apr 12 '16 10:04 LalatenduMohanty

We should not put the OpenShift access information in to the Vagrantbox's Vagrantfile.

true, true

So why not call service-manager env openshift and displaying its content instead of adding more logging elsewhere?

hferentschik avatar Apr 12 '16 10:04 hferentschik

So why not call service-manager env openshift and displaying its content instead of adding more logging elsewhere?

I am not opposed to the idea. The end result is vagrant up should have the required information.

LalatenduMohanty avatar Apr 12 '16 11:04 LalatenduMohanty

I am not opposed to the idea

:-)

hferentschik avatar Apr 12 '16 11:04 hferentschik

There is a drawback though, unless we have an explicit command which we can call at the very end, we might not get the desired output at the end of the provisioning. In this case the information might get lost among other messages.

hferentschik avatar May 30 '16 12:05 hferentschik

@LalatenduMohanty @navidshaikh @hferentschik Since, now the idea is to auto-generate Vagrantfiles, this can be implemented along with https://github.com/projectatomic/vagrant-service-manager/issues/163

brgnepal avatar Jul 07 '16 04:07 brgnepal

Since, now the idea is to auto-generate Vagrantfiles, this can be implemented along with #163

not quite sure I see the connection here.

hferentschik avatar Jul 07 '16 08:07 hferentschik

@hferentschik , if it is only moving print message part then it is different than #163.

Then, it means that the shell provisioning part will be migrated to vagrant-service-manager, right?

brgnepal avatar Jul 07 '16 09:07 brgnepal

Then, it means that the shell provisioning part will be migrated to vagrant-service-manager, right?

I guess that was the intend.

hferentschik avatar Jul 07 '16 09:07 hferentschik

Even if we add feature for auto-generating Vagrantfile, having the openshift information message print part should be moved to vagrant-service-manager from Vagrantfile. As Hardy said, there is no connection.

navidshaikh avatar Jul 08 '16 12:07 navidshaikh

@navidshaikh @hferentschik : If we go this way of printing the message, then we need to remove the shell provisioning lines from provided Vagrantfiles since vagrant up process will print duplicate messages.

What is your opinions?

brgnepal avatar Sep 16 '16 07:09 brgnepal

If we go this way of printing the message, then we need to remove the shell provisioning lines from provided Vagrantfiles since vagrant up process will print duplicate messages.

We remove the one which is extra! We remove the shell provisioning part from Vagrantfile.

navidshaikh avatar Sep 16 '16 11:09 navidshaikh