Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Molecule 5.0 Failing on GitHub Action #3883

Closed
dgibbs64 opened this issue Apr 20, 2023 · 7 comments
Closed

Molecule 5.0 Failing on GitHub Action #3883

dgibbs64 opened this issue Apr 20, 2023 · 7 comments
Labels

Comments

@dgibbs64
Copy link

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version && molecule --version
ansible-7.4.0
molecule-5.0.0

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

Desired Behavior

Molecule not failing to run.

Actual Behaviour

Since release of molecule 5.0 my github action is failing with the following error:
https://github.com/dgibbs64/ansible-role-linux_admin_packages/actions/runs/4759492512/jobs/8458829447

Traceback (most recent call last):
File "/home/runner/.local/bin/molecule", line 8, in
sys.exit(main())
File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/test.py", line 113, in test
base.execute_cmdline_scenarios(scenario_name, args, command_args, ansible_args)
File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/base.py", line 94, in execute_cmdline_scenarios
get_configs(args, command_args, ansible_args, glob_str),
File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/base.py", line 185, in get_configs
configs = [
File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/base.py", line 186, in
config.Config(
File "/home/runner/.local/lib/python3.10/site-packages/molecule/config.py", line 64, in call
obj.after_init()
File "/home/runner/.local/lib/python3.10/site-packages/molecule/config.py", line 116, in after_init
self.config = self._reget_config()
File "/home/runner/.local/lib/python3.10/site-packages/molecule/config.py", line 306, in _reget_config
env = util.merge_dicts(os.environ, self.env)
File "/home/runner/.local/lib/python3.10/site-packages/molecule/config.py", line 201, in env
"MOLECULE_INSTANCE_CONFIG": self.driver.instance_config,
File "/usr/lib/python3.10/functools.py", line 981, in get
val = self.func(instance)
File "/home/runner/.local/lib/python3.10/site-packages/molecule/config.py", line 185, in driver
driver = api.drivers(config=self)[driver_name]
File "/home/runner/.local/lib/python3.10/site-packages/molecule/api.py", line 30, in getitem
return self.dict[i]
KeyError: 'docker'

@dgibbs64 dgibbs64 added the bug label Apr 20, 2023
@kmezynski
Copy link

kmezynski commented Apr 20, 2023

I could have observed the same bug on my GitHub action: https://github.com/kmezynski/ansible-role-ohmyzsh/actions/runs/4756760785/jobs/8452737921. No changes to the role itself were made since last successful build on 19th April. By just looking on the traceback and most recent changes to the molecule's code, I'd start debugging from #3874.

@ssbarnea
Copy link
Member

ssbarnea commented Apr 21, 2023

PRs are more than welcomed but support questions should go to discussions. I am not sure if this counts as support or a real bug so I will not move it to discussions yet.

@vitabaks
Copy link

vitabaks added a commit to vitabaks/postgresql_cluster that referenced this issue Apr 21, 2023
Molecule 5.0 Failing on GitHub Action: ansible/molecule#3883
Frzk added a commit to Frzk/ansible-role-chrony that referenced this issue Apr 23, 2023
zerwes added a commit to Rosa-Luxemburgstiftung-Berlin/ansible-role-opera-dns-ui that referenced this issue Apr 24, 2023
zerwes added a commit to Rosa-Luxemburgstiftung-Berlin/ansible-role-gns3 that referenced this issue Apr 24, 2023
@ktdreyer
Copy link
Contributor

The original reporter had a GitHub Action that ran pip install molecule[docker]. This no longer works in Molecule 5.0.

The same is true for the podman driver. This used to work:

pip install install molecule[podman]==4.0.4

This no longer works in 5.0.0:

pip install install molecule[podman]==5.0.0
WARNING: molecule 5.0.0 does not provide the extra 'podman'

The replacement is documented:

pip install molecule-plugins[podman]

It would be nice if the error message was clearer instead of simply raising KeyError. If you raise MoleculeDriverNotFound (maybe with a link to the Molecule installation docs) it would be easier for users to search with Google.

eifelmicha added a commit to Rheinwerk/molecule that referenced this issue Apr 26, 2023
eifelmicha added a commit to Rheinwerk/molecule that referenced this issue Apr 26, 2023
- ansible/molecule#3883
- Ansible Compat PIN, da neuere Versionen Ansible > 2.12 erfordern
eifelmicha added a commit to Rheinwerk/molecule that referenced this issue Apr 26, 2023
- ansible/molecule#3883
- Ansible Compat PIN, da neuere Versionen Ansible > 2.12 erfordern, ansible/ansible-compat#215
eifelmicha added a commit to Rheinwerk/molecule that referenced this issue Apr 26, 2023
- ansible/molecule#3883
- Ansible Compat PIN, da neuere Versionen Ansible > 2.12 erfordern, ansible/ansible-compat#215
eifelmicha added a commit to Rheinwerk/molecule that referenced this issue Apr 26, 2023
- ansible/molecule#3883
- Ansible Compat PIN, da neuere Versionen Ansible > 2.12 erfordern, ansible/ansible-compat#215
@fauust
Copy link
Contributor

fauust commented Apr 26, 2023

I was also impacted by this today and here is a proposition to make it clear in the documentation (#3899).

fauust added a commit to fauust/molecule that referenced this issue Apr 26, 2023
If one upgrade from previous molecule versions, and since drivers are now
provided by the molecule-plugins, molecule-podman|docker|vagrant
packages needs to be removed.

See:
- ansible#3883
- ansible#3895
fauust added a commit to fauust/molecule that referenced this issue Apr 26, 2023
If one upgrade from previous molecule versions, and since drivers are now
provided by the molecule-plugins, molecule-podman|docker|vagrant
packages needs to be removed.

See:
- ansible#3883
- ansible#3895
@apatard
Copy link
Contributor

apatard commented Apr 26, 2023

A crude hack for this would be something like:

--- a/molecule/config.py	2023-04-26 08:12:23.747331357 +0000
+++ b/molecule/config.py	2023-04-26 15:33:04.084062504 +0000
@@ -182,7 +182,12 @@ class Config(metaclass=NewInitCaller):
         driver_name = self._get_driver_name()
         driver = None
 
-        driver = api.drivers(config=self)[driver_name]
+        api_drivers = api.drivers(config=self)
+        if 'driver_name' not in api_drivers:
+            msg = f"Failed to find driver {driver_name}. Maybe missing 'molecule-plugins\[{driver_name}]' ?\n"
+            util.sysexit_with_message(msg)
+
+        driver = api_drivers[driver_name]
         driver.name = driver_name
 
         return driver

This would improve the situation, as a backtrace for missing driver is bad.
@ssbarnea would you accept a PR with this change or is there a better way to do it ?

@dgibbs64
Copy link
Author

So to confirm the fix is to change molecule[docker] to molecule-plugins in my github action.

It would be good to have some sort of error message when the failure happens

apatard added a commit to apatard/molecule that referenced this issue Apr 28, 2023
If someone try installing plugins (say docker) with molecule[docker],
nothing will get installed as it should be molecule-plugins or
molecule-plugins[docker].
This leads to a python backtrace similar to the one found in
ansible#3883.
This should be handled properly, so check that the driver is in
api.drivers() before trying to get the value.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
samdbmg added a commit to samdbmg/ansible-traefik-auth-proxy that referenced this issue May 1, 2023
samdbmg added a commit to samdbmg/ansible-traefik-auth-proxy that referenced this issue May 1, 2023
Molecule has moved the various drivers into a new molecule-plugins
package, see ansible/molecule#3883
apatard added a commit to apatard/molecule that referenced this issue May 10, 2023
If someone try installing plugins (say docker) with molecule[docker],
nothing will get installed as it should be molecule-plugins or
molecule-plugins[docker].
This leads to a python backtrace similar to the one found in
ansible#3883.
This should be handled properly, so check that the driver is in
api.drivers() before trying to get the value.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
dbrennand added a commit to dbrennand/ansible-role-k3s that referenced this issue May 12, 2023
onedr0p pushed a commit to PyratLabs/ansible-role-k3s that referenced this issue May 13, 2023
…itHub Actions (#202)

* fix(ansible-lint): FQDN and `name`

* fix(ansible-lint): add `name` and FQDN for module call

* fix(ansible-lint): add `name` to tasks and FQDN for module

* fix(ansible-lint): add task `name` and FQDN for module calls

* fix(ansible-lint): last `include_tasks`

* fix(ansible-lint): add task names and FQDN

* refactor: `Ensure` to `Run`

* [skip ci]refactor: add exist and seperate ensure installed node task, mention build cluster

* [skip ci]refactor: Pipe seperator

* [skip ci]refactor: run

* refactor: remove quotes as other files don't use them

For templated vars in task name

* [skip ci]refactor: task names, use `Run`

* [skip ci]refactor: use variable name in task name

* [skip ci]refactor: task names

* [skip ci]refactor: add service mgr in task name

* [skip ci]refactor: add task names and module FQDNs

* [skip ci]refactor: fix task name

* [skip ci]refactor: add -

* [skip ci]refactor: include task names and FQDNs

* [skip ci]refactor: add task names and FQDNs

* [skip ci]: ignore `name[template]`

* refactor: `when` clause for `block` should be before `block`

* fix: ansible/molecule#3883

* refactor: molecule lint command was removed in version `5.0.0`

Use separate CI job step to run linting instead.

* [skip ci]refactor: noqa for command tasks

Subject to change

* refactor: use Ubuntu 22.04

Suspect issues with Molecule tests are related to cgroups v2.
samdbmg added a commit to samdbmg/ansible-traefik-auth-proxy that referenced this issue May 20, 2023
Molecule has moved the various drivers into a new molecule-plugins
package, see ansible/molecule#3883
samdbmg added a commit to samdbmg/ansible-traefik-auth-proxy that referenced this issue May 20, 2023
Molecule has moved the various drivers into a new molecule-plugins
package, see ansible/molecule#3883
samdbmg added a commit to samdbmg/ansible-schedule-duplicity that referenced this issue May 21, 2023
Molecule has moved the various drivers into a new molecule-plugins
package, see ansible/molecule#3883
Frzk added a commit to Frzk/ansible-role-chrony that referenced this issue May 31, 2023
ziegenberg added a commit that referenced this issue Jun 7, 2023
If one upgrade from previous molecule versions, and since drivers are now
provided by the molecule-plugins, molecule-podman|docker|vagrant
packages needs to be removed.

See:
- #3883
- #3895

Co-authored-by: Daniel Ziegenberg <daniel@ziegenberg.at>
ssbarnea added a commit that referenced this issue Jun 13, 2023
If someone try installing plugins (say docker) with molecule[docker],
nothing will get installed as it should be molecule-plugins or
molecule-plugins[docker].
This leads to a python backtrace similar to the one found in
#3883.
This should be handled properly, so check that the driver is in
api.drivers() before trying to get the value.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
Co-authored-by: Daniel Ziegenberg <daniel@ziegenberg.at>
Co-authored-by: Sorin Sbarnea <ssbarnea@redhat.com>
@ansible ansible locked and limited conversation to collaborators Jun 23, 2023
@ssbarnea ssbarnea converted this issue into discussion #3943 Jun 23, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

7 participants