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

source install method starts diamond before writing /etc/diamond/ #27

Open
mgruberman opened this issue Jun 9, 2022 · 0 comments
Open

Comments

@mgruberman
Copy link

mgruberman commented Jun 9, 2022

The source install method tries to start the service[diamond] before it installs the configuration and the systemd service fails to start.

================================================================================
           Error executing action `run` on resource 'execute[install diamond]'
================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of cd /usr/local/share/diamond_src;dpkg -i build/diamond_*_all.deb ----
    STDOUT: Selecting previously unselected package diamond.
    (Reading database ... 115322 files and directories currently installed.)
    Preparing to unpack build/diamond_4.0.905_all.deb ...
    Unpacking diamond (4.0.905) ...
    Setting up diamond (4.0.905) ...
    ● diamond.service - diamond - A system statistics collector for graphite
Loaded: loaded (/usr/lib/systemd/system/diamond.service; disabled; vendor preset: enabled)
Active: failed (Result: protocol) since Thu 2022-06-09 03:24:58 UTC; 20ms ago
      Process: 10404 ExecStart=/usr/bin/python /usr/bin/diamond (code=exited, status=0/SUCCESS)

    Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   -v, --version         display the version and exit
    Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   --skip-pidfile        Skip creating PID file
    Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   -u USER, --user=USER  Change to specified unprivilegd user
    Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   -g GROUP, --group=GROUP
    Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:                         Change to specified unprivilegd group
    Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   --skip-change-user    Skip changing to an unprivilegd user
    Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   --skip-fork           Skip forking (damonizing) process
    Jun 09 03:24:58 qa-cxcp1.sea1.....com systemd[1]: diamond.service: Can't open PID file /var/run/diamond.pid (yet?) after start: No such file or directory
    Jun 09 03:24:58 qa-cxcp1.sea1.....com systemd[1]: diamond.service: Failed with result 'protocol'.
    Jun 09 03:24:58 qa-cxcp1.sea1.....com systemd[1]: Failed to start diamond - A system statistics collector for graphite.
    Processing triggers for ureadahead (0.100.0-21) ...
    Processing triggers for systemd (237-3ubuntu10.53) ...
    STDERR: Job for diamond.service failed because the service did not take the steps required by its unit configuration.
    See "systemctl status diamond.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript diamond, action "start" failed.
    dpkg: error processing package diamond (--install):
     installed diamond package post-installation script subprocess returned error exit status 1
    Errors were encountered while processing:
     diamond
    ---- End output of cd /usr/local/share/diamond_src;dpkg -i build/diamond_*_all.deb ----
    Ran cd /usr/local/share/diamond_src;dpkg -i build/diamond_*_all.deb returned 1

    Resource Declaration:
    ---------------------
    # In /tmp/kitchen/cache/cookbooks/diamond/recipes/_install_source.rb

     54:   execute 'install diamond' do
     55:     command "cd #{node['diamond']['source_path']};dpkg -i build/diamond_*_all.deb"
     56:     action :nothing
     57:     notifies :restart, 'service[diamond]'
     58:   end
     59:

    Compiled Resource:
    ------------------
    # Declared in /tmp/kitchen/cache/cookbooks/diamond/recipes/_install_source.rb:54:in `from_file'

    execute("install diamond") do
      action [:nothing]
      retries 0
      retry_delay 2
      default_guard_interpreter :execute
      command "cd /usr/local/share/diamond_src;dpkg -i build/diamond_*_all.deb"
      backup 5
      returns 0
      user nil
      declared_type :execute
      cookbook_name "diamond"
      recipe_name "_install_source"
    end

    System Info:
    ------------
    chef_version=12.22.5
    platform=ubuntu
    platform_version=18.04
    ruby=ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-linux]
    program_name=chef-client worker: ppid=2543;start=03:23:13;
    executable=/opt/chef/bin/chef-client

[2022-06-09T03:24:59+00:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers:
[2022-06-09T03:24:59+00:00] ERROR: Running exception handlers
Running handlers complete
[2022-06-09T03:24:59+00:00] ERROR: Exception handlers complete
Chef Client failed. 19 resources updated in 01 minutes 46 seconds
[2022-06-09T03:24:59+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2022-06-09T03:24:59+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2022-06-09T03:24:59+00:00] ERROR: execute[install diamond] (diamond::_install_source line 54) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of cd /usr/local/share/diamond_src;dpkg -i build/diamond_*_all.deb ----
STDOUT: Selecting previously unselected package diamond.
(Reading database ... 115322 files and directories currently installed.)
Preparing to unpack build/diamond_4.0.905_all.deb ...
Unpacking diamond (4.0.905) ...
Setting up diamond (4.0.905) ...
● diamond.service - diamond - A system statistics collector for graphite
   Loaded: loaded (/usr/lib/systemd/system/diamond.service; disabled; vendor preset: enabled)
   Active: failed (Result: protocol) since Thu 2022-06-09 03:24:58 UTC; 20ms ago
  Process: 10404 ExecStart=/usr/bin/python /usr/bin/diamond (code=exited, status=0/SUCCESS)

Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   -v, --version         display the version and exit
Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   --skip-pidfile        Skip creating PID file
Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   -u USER, --user=USER  Change to specified unprivilegd user
Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   -g GROUP, --group=GROUP
Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:                         Change to specified unprivilegd group
Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   --skip-change-user    Skip changing to an unprivilegd user
Jun 09 03:24:58 qa-cxcp1.sea1.....com python[10404]:   --skip-fork           Skip forking (damonizing) process
Jun 09 03:24:58 qa-cxcp1.sea1.....com systemd[1]: diamond.service: Can't open PID file /var/run/diamond.pid (yet?) after start: No such file or directory
Jun 09 03:24:58 qa-cxcp1.sea1.....com systemd[1]: diamond.service: Failed with result 'protocol'.
Jun 09 03:24:58 qa-cxcp1.sea1.....com systemd[1]: Failed to start diamond - A system statistics collector for graphite.
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.53) ...
STDERR: Job for diamond.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status diamond.service" and "journalctl -xe" for details.
invoke-rc.d: initscript diamond, action "start" failed.
dpkg: error processing package diamond (--install):
 installed diamond package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 diamond
---- End output of cd /usr/local/share/diamond_src;dpkg -i build/diamond_*_all.deb ----
Ran cd /usr/local/share/diamond_src;dpkg -i build/diamond_*_all.deb returned 1

This can be worked around by preventing the service from starting before installation and then fixing the previous stop-gap once it is installed:

systemd_unit 'diamond.service' do
  # Mask the systemd "diamond.service" service only when debian
  # "diamond" package is not installed.
  action :mask
  not_if 'dpkg -s diamond'
end
systemd_unit 'diamond.service' do
  # Unmask the systemd diamond service if/when the execute[install
  # diamond] step completes.
  action :nothing
  subscribes :unmask, 'execute[install diamond]', :immediately
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant