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

reorganize var defaults #11840

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KubeKyrie
Copy link
Contributor

@KubeKyrie KubeKyrie commented Dec 29, 2024

What type of PR is this?
/kind flake

What this PR does / why we need it:
reorganize var defaults, and have a default value defined only once
Which issue(s) this PR fixes:

#11822

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Reorganize variable defaults

Signed-off-by: KubeKyrie <[email protected]>
@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 29, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 29, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @KubeKyrie. 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.

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.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 29, 2024
@VannTen
Copy link
Contributor

VannTen commented Dec 29, 2024 via email

@k8s-ci-robot k8s-ci-robot 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 Dec 29, 2024
@@ -9,7 +9,7 @@
- name: Generate etcd certs
include_tasks: "gen_certs_script.yml"
when:
- cert_management | d('script') == "script"
- cert_management == "script"
Copy link
Contributor

@ant31 ant31 Jan 6, 2025

Choose a reason for hiding this comment

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

would it fails if cert_management is undefined ?
If yes that would change the behavior of using script by default when undefined

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this would need a default value for cert_management in kubespray-defaults

@@ -437,15 +437,15 @@ argocd_enabled: false

## When OpenStack is used, Cinder version can be explicitly specified if autodetection fails (Fixed in 1.9: https://github.com/kubernetes/kubernetes/issues/50461)
# openstack_blockstorage_version: "v1/v2/auto (default)"
openstack_blockstorage_ignore_volume_az: "{{ volume_cross_zone_attachment | default('false') }}"
openstack_blockstorage_ignore_volume_az: "{{ volume_cross_zone_attachment }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

when this role is executed, nothing say that volume_cross_zone_attachment is defined.
this variable eventually is defined but from another role/inventory.
We shouldn't remove it there

Copy link
Contributor

Choose a reason for hiding this comment

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

Default variables are lazily interpreted though, aren't they ? (-> meaning this will work if the value is defined when the variable is used)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing tells you it will be defined for sure.
Maybe it's defined in the openstack role that is not included when not using openstack,
Maybe the playbook ran with --tags X,Y and the role where "volume_cross_zone_attachment" is not executed.

Copy link
Contributor

Choose a reason for hiding this comment

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

We're mostly doing role imports rather than include, though, don't we ?

If I'm not mistaken, the tags don't affect roles variables, only the tasks (unless using include, which is dynamic).

However, in any case, I agree it's better than a variable dependent on another should live nearby, ideally in the same file. ~~

Actually, this variable is not used anywhere since 437026f (AFAICS), so we should just delete it :

$ grep -R openstack_blockstorage_ignore roles/
roles/kubespray-defaults/defaults/main/main.yml:openstack_blockstorage_ignore_volume_az: "{{ volume_cross_zone_attachment | default('false') }}"

Copy link
Contributor

@ant31 ant31 Jan 7, 2025

Choose a reason for hiding this comment

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

@VannTen yes, but not all runs imports all roles.

Short test:

role A define "var_a: "I'm var a"
role B define "var_ab: "I'm b and {{var_a}}"

In the test playbook, the install kubernetes nodes run will work (even if role a is not executed) , but not the install control plane.

---
- name: Install Kubernetes nodes
  hosts: localhost
  gather_facts: true
  roles:
    - { role: a, tags: ['a'], when: false}
    - { role: b, tags: ['b'] }


- name: Install the control plane
  hosts: localhost
  gather_facts: true
  roles:
    - { role: b, tags: ['b'] }

Selecting subset of roles is used a lot in kubespray (see cluster.yml)
image

@ant31
Copy link
Contributor

ant31 commented Jan 6, 2025

Hi thank you for the PR.

But I think the default are good and shouldn't be remove as it change behavior and also increase dependencies between roles.

@ant31 ant31 added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 6, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 24, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants