mdsol / mesos_cookbook

Chef cookbook for installing Apache Mesos
Other
78 stars 71 forks source link

Installation fails if java was already installed #139

Open eyalzek opened 8 years ago

eyalzek commented 8 years ago

Since the file /etc/profile.d/jdk.sh exists before the installation, apt-get is prompting for replacing the file:

           Error executing action `install` on resource 'apt_package[mesos]'
           ================================================================================

           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '100'
           ---- Begin output of apt-get -q -y --no-install-recommends install mesos=1.0.1* ----
           STDOUT: Reading package lists...
           Building dependency tree...
           Reading state information...
           mesos is already the newest version.
           0 upgraded, 0 newly installed, 0 to remove and 68 not upgraded.
           1 not fully installed or removed.
           After this operation, 0 B of additional disk space will be used.
           Setting up oracle-java8-set-default (8u111+8u111arm-1~webupd8~0) ...
           STDERR: perl: warning: Setting locale failed.
           perl: warning: Please check that your locale settings:
            LANGUAGE = "C.UTF-8",
            LC_ALL = (unset),
            LC_TIME = "de_DE.UTF-8",
            LC_MONETARY = "de_DE.UTF-8",
            LC_ADDRESS = "de_DE.UTF-8",
            LC_TELEPHONE = "de_DE.UTF-8",
            LC_NAME = "de_DE.UTF-8",
            LC_MEASUREMENT = "de_DE.UTF-8",
            LC_IDENTIFICATION = "de_DE.UTF-8",
            LC_NUMERIC = "de_DE.UTF-8",
            LC_PAPER = "de_DE.UTF-8",
            LANG = "C.UTF-8"
        are supported and installed on your system.
           perl: warning: Falling back to the standard locale ("C").
           locale: Cannot set LC_ALL to default locale: No such file or directory

           Configuration file '/etc/profile.d/jdk.sh'
            ==> File on system created by you or by a script.
            ==> File also in package provided by package maintainer.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions
          Z     : start a shell to examine the situation
            The default action is to keep your current version.
           *** jdk.sh (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing package oracle-java8-set-default (--configure):
            EOF on stdin at conffile prompt
           Errors were encountered while processing:
            oracle-java8-set-default
           E: Sub-process /usr/bin/dpkg returned an error code (1)
           ---- End output of apt-get -q -y --no-install-recommends install mesos=1.0.1* ----
           Ran apt-get -q -y --no-install-recommends install mesos=1.0.1* returned 100

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/mesos/recipes/install.rb

            40:   package 'mesos' do
            41:     action :install
            42:     # --no-install-recommends to skip installing zk. unnecessary.
            43:     options '--no-install-recommends'
            44:     # Glob is necessary to select the deb version string
            45:     version "#{node['mesos']['version']}*"
            46:   end
            47: when 'rhel'

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/mesos/recipes/install.rb:40:in `from_file'

           apt_package("mesos") do
             package_name "mesos"
             action [:install]
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             declared_type :package
             cookbook_name "mesos"
             recipe_name "install"
             version "1.0.1*"
             options "--no-install-recommends"
           end

I don't know why it started happening all of a sudden, but currently to bypass it I have to:

file '/etc/profile.d/jdk.sh' do
  action :delete
end

before calling include_recipe 'mesos::master' ...

eyalzek commented 7 years ago

Would it be possible to turn this into an attribute? https://github.com/mdsol/mesos_cookbook/blob/master/recipes/install.rb#L43 I can make a PR if necessary...

rveznaver commented 7 years ago

@eyalzek What would that fix?

eyalzek commented 7 years ago

Here is an example from the docker cookbook: https://github.com/chef-cookbooks/docker/blob/master/libraries/docker_installation_package.rb#L19 and to install with options (from README.md):

docker_installation_package 'default' do
  version '1.8.3'
  action :create
  package_options %q|--force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-all'| # if Ubuntu for example
end
rveznaver commented 7 years ago

@eyalzek Thanks, I am aware how package options work :) My question remains: Why would you want to change those options and what would you fix by changing them?

eyalzek commented 7 years ago

Huh sorry, misread your question :) It'll give me the option to pass -o Dpkg::Options::='--force-confold' which will prevent the error described in my first message.

I am in mind to do the following on all my nodes anyway:

file '/etc/apt/apt.conf.d/99conf-default' do
  action :create
  content <<-EOS
Dpkg::Options {
   "--force-confdef";
   "--force-confold";
}
  EOS
end

In which case, the changes to this cookbook won't be necessary for me (but I still believe it's good to have the option to customize these parameters).

rveznaver commented 7 years ago

This seems like an issue with the java cookbook not setting up the Java package properly. Installing the mesos package should not pull oracle-java8-set-default as it is supposed to be installed by the aforementioned cookbook.