Skip to content

Fix lint violation: jinja[invalid] to make pre-commit pass - #13337

Open
manzsolutions-aleski wants to merge 1 commit into
kubernetes-sigs:masterfrom
manzsolutions-aleski:fix-lint-violation
Open

Fix lint violation: jinja[invalid] to make pre-commit pass#13337
manzsolutions-aleski wants to merge 1 commit into
kubernetes-sigs:masterfrom
manzsolutions-aleski:fix-lint-violation

Conversation

@manzsolutions-aleski

Copy link
Copy Markdown

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:
/kind cleanup

What this PR does / why we need it:
You use pre-commit as an early quality gate. For everyone working on the file in question, they would be unable to commit their changes without skipping test(s). This is not ideal because it lets other flaws through more easily. Hence, fix the violation despite the kubernetes guidance being hesitant on fixing lint violations with PRs.

I encountered this while working on #13333

Which issue(s) this PR fixes:

None.

Special notes for your reviewer:
There's an alternative solution to this as well: Ensure only valid IP addresses go through - I think that's not what you want because I don't know whether external_apiserver_address is guaranteed to be an IP or if it can be a DNS name, given you're prepending https:// to it.

-  - "{{ admin_kubeconfig['clusters'][0] | combine({'name': cluster_name, 'cluster': admin_kubeconfig['clusters'][0]['cluster'] | combine({'server': 'https://' + (external_apiserver_address | string | ansible.utils.ipwrap) + ':' + (external_apiserver_port | string)})}, recursive=true) }}"
+  - "{{ admin_kubeconfig['clusters'][0] | combine({'name': cluster_name, 'cluster': admin_kubeconfig['clusters'][0]['cluster'] | combine({'server': 'https://' + (external_apiserver_address | string | ansible.utils.ipaddr | ansible.utils.ipwrap) + ':' + (external_apiserver_port | string)})}, recursive=true) }}"

Note that ansible.utils.ipwrap can take a list or a string but for this section a string looks like the logical choice.

Does this PR introduce a user-facing change?:

NONE

Example output:

before

kubespray on  fix-lint-violation [!?] is 📦 v0.1.0 via 🐍 v3.14.6 via ⍱ 🪝 OFF
❯ uv run ansible-lint --offline
WARNING  Ignored exception from ArgsRule.matchtasks while processing playbooks/internal_facts.yml (playbook): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/etcd/handlers/backup.yml (handlers): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/centos.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/main.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/network_facts/tasks/main.yaml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/opensuse.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/system_packages/tasks/main.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/rhel.yml (tasks): attempted relative import with no known parent package
WARNING  /Users/Alexander/Documents/Repositories/kubespray/.venv/lib/python3.12/site-packages/jmespath/lexer.py:169 PendingDeprecationWarning deprecated string literal syntax
WARNING  Listing 1 violation(s) that are fatal
jinja[invalid]: An unhandled exception occurred while templating '{'clusters': ["{{ admin_kubeconfig['clusters'][0] | combine({'name': cluster_name, 'cluster': admin_kubeconfig['clusters'][0]['cluster'] | combine({'server': 'https://' + (external_apiserver_address | ansible.utils.ipwrap) + ':' + (external_apiserver_port | string)})}, recursive=true) }}"], 'contexts': ["{{ admin_kubeconfig['contexts'][0] | combine({'name': context, 'context': admin_kubeconfig['contexts'][0]['context'] | combine({'cluster': cluster_name})}, recursive=true) }}"], 'current-context': '{{ context }}'}'. Error was a <class 'ansible.errors.AnsibleFilterError'>, original message: Unrecognized type <<class 'ansible.template.native_helpers.AnsibleUndefined'>> for ipwrap filter <value>[/]

after

kubespray on  fix-lint-violation [!?] is 📦 v0.1.0 via 🐍 v3.14.6 via ⍱ 🪝 OFF took 41s
❯ uv run ansible-lint --offline
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/system_packages/tasks/main.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/main.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/opensuse.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/network_facts/tasks/main.yaml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing playbooks/internal_facts.yml (playbook): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/etcd/handlers/backup.yml (handlers): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/rhel.yml (tasks): attempted relative import with no known parent package
WARNING  Ignored exception from ArgsRule.matchtasks while processing roles/bootstrap_os/tasks/centos.yml (tasks): attempted relative import with no known parent package
WARNING  /Users/Alexander/Documents/Repositories/kubespray/.venv/lib/python3.12/site-packages/jmespath/lexer.py:169 PendingDeprecationWarning deprecated string literal syntax

Passed: 0 failure(s), 0 warning(s) in 927 files processed of 1231 encountered. Last profile that met the validation criteria was 'production'.

@kubernetes-prow kubernetes-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Jul 1, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 1, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: manzsolutions-aleski / name: Alexander Skiba (544c851)

@kubernetes-prow
kubernetes-prow Bot requested review from VannTen and mzaian July 1, 2026 08:57
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: manzsolutions-aleski
Once this PR has been reviewed and has the lgtm label, please assign yankay for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 1, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @manzsolutions-aleski. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 1, 2026
@manzsolutions-aleski

Copy link
Copy Markdown
Author

I don't know why the EasyCLA is not working in this PR while it is working in my first one. :(

@yankay

yankay commented Jul 2, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@kubernetes-prow kubernetes-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 2, 2026
@guoard

guoard commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

/retest

@manzsolutions-aleski

Copy link
Copy Markdown
Author

/easycla

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 15, 2026
@manzsolutions-aleski

Copy link
Copy Markdown
Author

Is there anything left to do from my side?

@guoard

guoard commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@VannTen PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants