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

Fix linting issues #147

Merged
merged 1 commit into from
Jul 12, 2023
Merged

Conversation

staticdev
Copy link
Contributor

@staticdev staticdev commented Jul 6, 2023

I had a couple issues trying to run ansible-lint and molecule locally direct from a clone and install dependencies, that are fixed in this PR.

Namely:

  1. ansible lint does not find role declared in converge:

    % ansible-lint
    WARNING  Skipped installing collection dependencies due to running in offline mode.
    WARNING  Listing 1 violation(s) that are fatal
    syntax-check[specific]: the role 'ansible-role-nix' was not found in /home/user/workspace/ansible-role-nix/molecule   /default/roles:/home/user/.cache/ansible-compat/1a0050/roles:/home/user/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/user/workspace/ansible-role-nix/molecule/default
    molecule/default/converge.yml:10:7
    
  2. docker-py fails running molecule with (check urllib3 v2 incompatibility docker/docker-py#3113):

    Error while fetching server API version: request() got an unexpected keyword argument 'chunked'
    

    Adding a restriction to urllib3 solves the issue.

  3. errors pointed by molecule/default/coverage.yml are also fixed, so the file does not need to be ignored anymore.

@staticdev staticdev requested a review from a team as a code owner July 6, 2023 10:48
@staticdev staticdev requested review from nre-ableton and removed request for a team July 6, 2023 10:48
@nre-ableton
Copy link
Contributor

nre-ableton commented Jul 6, 2023

@ablbot runci

Copy link
Contributor

@nre-ableton nre-ableton left a comment

Choose a reason for hiding this comment

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

Hi there! 👋 Thanks for the PR. 👍 The actual changes LGTM, but there are some other issues that need to be resolved.

First, before we get to the technical issues, our company requires a CLA to be digitally signed by any external contributors. Just to be clear, all personal information is protected under the GDPR, since Ableton is based in Germany and the data isn't added to any customer mailing lists or anything like that. It's only stored by our legal team. Also, you only need to sign the CLA once, then you can submit as many PRs as you like to any of our repos. 🙂


Ok, as for the technical stuff... so unfortunately CI failed (sorry, you won't be able to see the results page since the Jenkins server is firewalled off to the outside world), but basically the error is:

ERROR! the role 'ableton.nix' was not found in /home/nre/Code/Ableton/ansible-role-nix/molecule/default/roles:/home/nre/.cache/ansible-compat/1a0050/roles:/home/nre/.cache/molecule/ansible-role-nix/default/roles:/home/nre/Code/Ableton:/home/nre/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/nre/Code/Ableton/ansible-role-nix/molecule/default

The error appears to be in '/home/nre/Code/Ableton/ansible-role-nix/molecule/default/converge.yml': line 10, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
    - ableton.nix
      ^ here

I can also reproduce this locally when checking out your PR branch and running molecule test locally. However, when I run molecule test locally I don't have any problems. Likewise, I don't have the issue with docker-py that you mentioned, but I don't mind pinning the package to work around a known issue. How exactly are you running molecule?

As for the ansible-lint changes, thanks, I don't remember why we excluded the molecule converge playbook, but IIRC it had to do with a bug in some old ansible-lint version.

I think the easiest way to proceed with this PR would be to drop the change from ansible-role-nix to ableton.nix and just merge the linter fixes. Then we can figure out how to change the role name. I agree that it would be better to use the canonical role name for molecule, since this resembles how you'd use this role in actual playbooks, but we've struggled to find a solution that satisfies molecule, developer workstations, CI, and other scenarios. This has been a problem since Ansible changed their role name requirements.

@staticdev
Copy link
Contributor Author

staticdev commented Jul 6, 2023

@nre-ableton no problem, CLA signed. Regarding the molecule, developer workstations, CI, and other scenarios I have created a dozen Ansible roles that work everywhere following this approach, you can also see an example:
https://github.com/staticdev/ansible-role-python-developer/blob/main/molecule/default/converge.yml#L23
Also the most popular roles on Ansible Galaxy follow this approach:
https://github.com/geerlingguy/ansible-role-docker/blob/master/molecule/default/converge.yml#L24

One thing I could do is check maybe what problem you have on Jenkins (if you send a Jenkinsfile) or on workstation and I can also try to help.

@nre-ableton
Copy link
Contributor

nre-ableton commented Jul 7, 2023

One thing I could do is check maybe what problem you have on Jenkins (if you send a Jenkinsfile) or on workstation and I can also try to help.

The root of the problem we have is that our Jenkins nodes don't check out repositories with unique names. It's unfortunately a bit of a difficult problem to fix. Basically, when "normal people" clone the repository, it gets cloned to ansible-role-nix, and the ansible-compat tools anticipate this by basically copying the role to ~/.cache/ansible-compat/<hash> and set ANSIBLE_ROLES_PATH accordingly.

However, our CI nodes must check out all repositories to a directory named /jenkins/workspace, for reasons that aren't worth going into here but is not something we can change just for the benefit of these Ansible roles. The problem is that ansible-compat calculates the above hash very naively by using current directory basename. This means that all CI jobs for Ansible roles use workspace as the cache key, which inevitably clashes with other roles or dependencies from ansible-galaxy etc.

Although it should theoretically be possible to override this with ANSIBLE_ROLES_PATH or ANSIBLE_COLLECTIONS_PATH, it's not. I've filed bug reports with varying degrees of success in both molecule and ansible-lint about this to try to get them to work around the behavior.

Currently, we work around this by manually creating a symlink in ~/.cache/ansible-compat to "fool" these tools, but it's a bit of a hack. I have a few ideas for workarounds that I have been meaning to test, but I haven't had the time recently. Since I've been doing more Ansible role stuff this week, I'll give it a try and hopefully come up with a solution. Let me get back to you on this...

@staticdev
Copy link
Contributor Author

No problem, there is nothing critical in this PR anyway. I wait as much as needed.

@nre-ableton
Copy link
Contributor

nre-ableton commented Jul 11, 2023

@staticdev We've fixed the CI issues on our side. Can you please rebase and force-push? This PR should be good to go after that.

@staticdev
Copy link
Contributor Author

@nre-ableton I am sorry I used github sync branch functionality and it actually does merge instead of rebase.

@nre-ableton
Copy link
Contributor

nre-ableton commented Jul 11, 2023

Ok, the code changes look fine, but can you squash all commits so there's only a single one? Thanks. 👍

If you're unsure how to do this, just let me know and I'll force-push to your branch.

@staticdev
Copy link
Contributor Author

@nre-ableton hope it is correct now ;)

Copy link
Contributor

@nre-ableton nre-ableton left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! 👍 I'll run it through CI, just to make sure, but I don't anticipate any problems.

@nre-ableton
Copy link
Contributor

nre-ableton commented Jul 11, 2023

@ablbot runci

@nre-ableton
Copy link
Contributor

CI failed due to a race condition that occurs when setting up the Ansible role symlink. I need to make another fix to our systems before this job can build. 😅

@nre-ableton
Copy link
Contributor

nre-ableton commented Jul 12, 2023

@ablbot runci

@nre-ableton
Copy link
Contributor

@staticdev Ok, finally passing CI. 😌 Thanks again for your contribution! 👍

@nre-ableton nre-ableton merged commit b60770e into Ableton:main Jul 12, 2023
3 checks passed
@staticdev staticdev deleted the bugfix/linting-issues branch July 12, 2023 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants