saltstack-formulas / mongodb-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
31 stars 121 forks source link

fix(systemd): fix service detection #94

Open ze42 opened 3 years ago

ze42 commented 3 years ago

Fix service detection to properly ensure the service is running. Command also updated at other service.running/dead onlyif.

Fixes https://github.com/saltstack-formulas/mongodb-formula/issues/93 with the change suggested there

noelmcloughlin commented 3 years ago

Not sure why Amazonlinux fails.

ze42 commented 3 years ago

mmm... might be a bug in salt I've seen some time ago, and might still be there.

Enabling and launching at the same time fails. Splitting into 2 states (service.enabled and service.running) might do the trick.

daks commented 2 years ago

HI, this PR is quite old now but I' interested in reviewing it to merge it if possible because I'm facing the same bug.

daks commented 2 years ago

I rebased this branch on master, added an Inspec test

diff --git a/test/integration/default/controls/archive_spec.rb b/test/integration/default/controls/archive_spec.rb
index 432ad9a..a2a2c24 100644
--- a/test/integration/default/controls/archive_spec.rb
+++ b/test/integration/default/controls/archive_spec.rb
@@ -3,6 +3,9 @@
 control 'mongodb components' do
   title 'should be installed'

+  describe service('mongod') do
+    it { should be_running }
+  end
   # describe package('unzip') do
   #   it { should be_installed }
   # end

and I still have a problem with service not running

  ×  mongodb components: should be installed (1 failed)
     ×  Service mongod is expected to be running
     expected that `Service mongod` is running
daks commented 2 years ago

FYI: even removing those onlyif, I don't have mongod service running, even if the converge pass

ze42 commented 2 years ago

Testing daks test, and getting the same error, but...

Salt states in is running while applying...

                 ID: mongodb-service-running-database-mongod
           Function: service.running
               Name: mongod
             Result: True
            Comment: Service mongod has been enabled, and is running
            Started: 12:46:32.712630
           Duration: 637.408 ms
            Changes:   
              ----------
              mongod:
                  True

And tests states it is not

  ×  mongodb components: should be installed (1 failed)
     ×  Service mongod is expected to be running
     expected that `Service mongod` is running

Removing that test. If anyone has ideas about it...