question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testinfra is choosing Upstart for CentOS 6 as service provider

See original GitHub issue

Hello,

I’ve been tracking down some failing tests and I’ve noticed that testinfra 1.6.5 is picking up the Upstart service provider for my test case for CentOS 6, which feels wrong and it should be choosing the SysvService instead.

Here’s an example:

    @pytest.mark.docker_images('centos:6')
    def test_httpd_service_starts_up_through_etc_initd(host, wait_for_svc):
        svc = host.run('/etc/init.d/httpd start')
        wait_for_svc(host, 'start', timeout=5)
    
        assert svc.rc == 0
>       assert host.service('httpd').is_running
E       AssertionError: assert False
E        +  where False = <service httpd>.is_running
E        +    where <service httpd> = <class 'testinfra.modules.base.UpstartService'>('httpd')
E        +      where <class 'testinfra.modules.base.UpstartService'> = <testinfra.host.Host object at 0x7fd013d85310>.service

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:19 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
elliotweisercommented, Mar 1, 2018

@codylane Thanks for the nod. These were the underlying motivations for my earlier comment:

  1. Don’t reinvent the wheel over logic that Ansible has already painstakingly implemented
  2. Less code to maintain (i.e. less tests to write and smaller code changes re: @codylane’s arguments)
  3. There is already precedent to use Ansible library code in this code-base.

My opinion may be in the minority. I’m curious to hear others’ thoughts on the matter.

1reaction
codylanecommented, Mar 1, 2018

It’s not a hard requirement and is left to the package maintainer but most package maintainers do adhere to security requirements. Not all service bootstrapping has to happen from init but those that do should 98% of the time always be started from as the root user to avoid problems. If the service shouldn’t be run as root, the service should su the affective user and spawn the service with that user.

My point above only corresponds to this ticket which we are talking about a RHEL based distro that uses SysV startup scripts or Systemd. There are other init style based services with their own execution models but for the sake of this ticket and this potential bug, I feel that we should at the very least agree that anything service related through init or systemd should be invoked as root and make no other assumptions. Just my 2$. Feel free to disagree or provide different context.

I’m happy to share any other ideas or things to try.

A different context of thought:

If I was going to do a refactor of this of any kind, I would be looking to see what Ansible and Salt do as @elliotweiser suggests. I also wonder if it would be possible without to much work to just piggy back off the core library of Ansible or Salt and take advantage of fact gathering, service management… etc. I have a feeling this would be a significant re-write/refactor however. I may even explore this on my own fork.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testinfra is choosing Upstart for CentOS 6 as service provider
Hello, I've been tracking down some failing tests and I've noticed that testinfra 1.6.5 is picking up the Upstart service provider for my ......
Read more >
Modules — testinfra 7.0.2.dev1+gfc4bfd1.d20221210 ...
Network namespaces can only be used if ip command is available because in this case, the module ... version: default 4 (iptables), optionally...
Read more >
testing Archives - ericsysmin's DevOps Blog
I'd like to share with you another design in testing your Ansible collections, modules, playbooks, and roles. Molecule used to include a file...
Read more >
service provider should default to upstart in RHEL6 and greater
In puppet, when osfamily = redhat,suse, the provider for the service type defaults to the redhat type, which uses chkconfig.
Read more >
Molecule Documentation - Release 2.13.1 AUTHORS.rst
1 Providers can be bare-metal, virtual, cloud or containers. ... To start a service which requires systemd, configure molecule.yml with a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found