8000 Added state-file driver validation by superstes · Pull Request #3429 · ansible/molecule · GitHub
[go: up one dir, main page]

Skip to content

Added state-file driver validation - #3429

Merged
ssbarnea merged 6 commits into
ansible:mainfrom
superstes:statefile-driver-validation-1
Mar 20, 2022
Merged

ssbarnea merged 6 commits into
ansible:mainfrom
superstes:statefile-driver-validation-1

Conversation

@superstes
Copy link
Copy Markdown
Contributor

It seems the driver pulled from existing state-file(s) was not yet validated against the available drivers.

This was problematic for me as I previously used 'vagrant' and changed it to use 'docker'.
That simple check (as already used in the molecule.yml schema-validation) should fix this behaviour.

I pulled my hair out yesterday trying to understand why the configured 'docker' driver was not used by molecule.
There was no transparent way to know why molecule did not use my configuration. (as an user)

@superstes
superstes marked this pull request as ready for review February 8, 2022 17:15
@ssbarnea ssbarnea added the bug label Feb 8, 2022
@ssbarnea
ssbarnea commented Feb 8, 2022
Copy link
Copy Markdown
Member

@superstes Is my impression or this should fix #2540 ?

Comment thread src/molecule/config.py Outdated
driver_from_cli = self.command_args.get("driver_name")

if driver_from_state_file:
if driver_from_state_file and driver_from_state_file in api.drivers():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I'm seeing problems where there are none because I've not understood what it's doing... I'm wondering if the check is enough. For instance, the scenario is configured to use driver "foo", the user installs driver "bar" and modify the configuration to use driver "bar" but doesn't uninstall the driver "foo", will the driver change get noticed ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those are two different problems. "We are missing a driver that initialized scenario is using" is one and the other is "Scenario and its initialized instance diverged."

Current PR is trying to solve the first issue (making sure we can still converge, etc., against an initialized scenario) and does not tackle the second issue.

I am not sure if it is even possible to solve the second problem without making some severe changes to Molecule's internals. Why? It seems to me that once we initialize the scenario, Molecule should ignore changes to the source configuration and always use configuration from the initialized instance. But currently, Molecule does not distinguish this and always uses source config as a fallback configuration.

Comment thread src/molecule/config.py Resolved
@superstes
superstes commented Feb 11, 2022 •
Copy link
Copy Markdown
Contributor Author

@ssbarnea

This issue is related to #2540, yes.

I completely agree with you that the user should at least get a warning when the cache might be 'invalid'.

I'll give my input if I've found a good way of solving this.

Removing temp files of molecule does solve the issue, most users do not even know where these are located.

So true. I only found it after looking into the code.

Moved validation of driver pulled from state-file to the end of 'get_driver_name' to throw an error.
@ssbarnea
Copy link
Copy Markdown
Member

@superstes If you find the approval annoying please find a very simple fix, like a typo and propose it. This approval appears only for those that never contributed and cannot be disabled.

@ssbarnea
Copy link
Copy Markdown
Member

@superstes Any chance to revive this?

@superstes
Copy link
Copy Markdown
Contributor Author

@ssbarnea Sorry for the delay - updated the test.

@ssbarnea
ssbarnea merged commit e4f0359 into ansible:main Mar 20, 2022
@superstes
superstes deleted the statefile-driver-validation-1 branch March 20, 2022 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0