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

update logic for cloud-init and variable names for resolving ambiguity #1636

Merged
merged 1 commit into from
Mar 9, 2020

Conversation

samvarankashyap
Copy link
Contributor

$subject
#1630

@johnbieren Please check if this patch works for you.


- name: "check cloud_config is used or not"
set_fact:
cloud_config_used: "{{ true if (cloud_config['users'] == [] and cloud_config['run_commands'] == []) else false }}"
cloud_init_used: "{{ true if (cloud_config['users'] != [] and cloud_config['run_commands'] == []) else false }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

This line still looks wrong to me. Shouldn't you correct the check on run_commands and is and still the correct logic? Wouldn't it be correct if either you had users or run_commands defined?

Has this passed your unit tests for cloud-init??

Why change the variable name when it has nothing to do with the logic fix? it makes a one line patch much bigger than it needs to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@p3ck
There are two ways to one can use cloud_config in linchpin
cloud_config variable that contains virt-type as one of the parameters that determine whether we use cloud-init or virt-customize. It defaults to cloud-init.
when using cloud-init does not have an option for run_commands since it is provided by virt-customize.
the above condition checks if run_commands empty or not.
Thinking of the above maybe we should check if run_commands parameter is defined or not.

I am afraid we do not have any unit tests for cloud-init but I tested it with libvirt-custom-xml target
from the libvirt workspace.

cloud_config_used variable is used to only check for the case when is cloud-init is used.
That's the reason I renamed cloud_config used to cloud_init used.

Copy link
Contributor

Choose a reason for hiding this comment

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

The logic seems to work, but there may be a more elegant way of solving the issue. In order to determine if you run cloud-init or virt-customize, do you just check whether run_commands exists?

I do see SK's point about changing the variable name. It makes the PR longer but definitely makes the code easier to understand

Copy link
Contributor

Choose a reason for hiding this comment

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

"I am afraid we do not have any unit tests for cloud-init but I tested it with libvirt-custom-xml target
from the libvirt workspace." <- Is adding unit tests for it and CI testing for libvirt overall on the near term roadmap? I know of at least three teams that rely on libvirt in linchpin working and this latest release bit us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@johnbieren We will try to re-enable to ci for libvirt on one distro,
however, I am not sure how easy or difficult the task would be we faced multiple (networking) problems with libvirt provisioning with existing ci. Which made us disable libvirt testing.
I am currently, working on #1542 for libvirt that simulates one of the scenarios of libvirt.
provisioning which might help partially with testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I don't follow. I have been using libvirt from linchpin for over a year now in my projects and with each linchpin release it either works exactly as I expect or doesn't work at all. There are no inconsistencies. What networking problems come up? I have not hit any networking problems ever using linchpin when I am on a working release

@p3ck
Copy link
Contributor

p3ck commented Feb 27, 2020

It's no wonder I'm confused. Looking at the code there is virt_type which can be virt-customize or cloud-init, but then there is more logic in the latest version with cloud_config_used which is now called cloud_init_used.

@johnbieren
Copy link
Contributor

No, this patch does not work

@johnbieren
Copy link
Contributor

"msg": "AnsibleUndefinedVariable: 'cloud_config_used' is undefined"}
linchpin-workspace]# grep -r cloud_config_used ../
../lib/python3.6/site-packages/linchpin/provision/roles/libvirt/templates/libvirt_node.xml.j2:{% if virt_type == 'cloud-init' and cloud_config_used %}

@johnbieren
Copy link
Contributor

ssh now works with the latest version of the patch

@14rcole
Copy link
Contributor

14rcole commented Feb 28, 2020

@samvarankashyap Can you rebase this against the latest version of develop?

@samvarankashyap
Copy link
Contributor Author

@14rcole rebased

@samvarankashyap
Copy link
Contributor Author

[test]

@samvarankashyap
Copy link
Contributor Author

[merge]

@adl-bot adl-bot merged commit a7d84b3 into CentOS-PaaS-SIG:develop Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants