🌱 Small refactoring in the ironic startup scripts and template#787
🌱 Small refactoring in the ironic startup scripts and template#787metal3-io-bot merged 2 commits intometal3-io:mainfrom
Conversation
|
Hi @mchiappero. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
Rozzii
left a comment
There was a problem hiding this comment.
Thanks for the refactor, I also not a fun of complex jinja templates so I support the idea but I would like to point out a few shellcheck issues and nits.
284ed37 to
b81d0f9
Compare
5eaafa0 to
8e987bf
Compare
|
Same as #788 ? |
8e987bf to
50b86cd
Compare
|
|
||
| if [[ "$#" -gt 2 ]]; then | ||
| echo "ERROR: ${FUNCNAME[0]}: too many parameters" >&2 | ||
| return 1 |
There was a problem hiding this comment.
not sure we want a return here, let's just use exit ?
maybe also for the other return statements
unless you really want to capture the exit code, then use echo, but I don't see the point
There was a problem hiding this comment.
Whether to exit or not is not a decision to be made at this scope. The caller could, and probably should, use exit, but there is no homogeneous error handling in general across these scripts.
There was a problem hiding this comment.
Sorry, I thought it was a different error test... Yes we could exit here in this case since it would be an invalid use of the function rather than invalid input. I don't mind, it's an unfortunate side effect of using the wrong tool for the job, it doesn't make much of a difference.
| local PARSED_IP | ||
| PARSED_IP="$(parse_ip_address "${PROVISIONING_IP}")" | ||
| if [[ -z "${IRONIC_IP}" ]]; then | ||
| return 1 |
There was a problem hiding this comment.
we should probably provide an error message here ?
There was a problem hiding this comment.
By the way, we could wrap it in a "parse_or_die" sort of function, and avoid the test here.
There was a problem hiding this comment.
By the way, we could wrap it in a "parse_or_die" sort of function, and avoid the test here.
E.g.:
parse_ip_address_or_die()
{
local RESULT
RESULT="$(parse_ip_address $@)"
if [[ -z "${RESULT}" ]]; then
echo "ERROR: \"$@\" is not a valid IP address, failed to start ironic"
exit 1
fi
echo "${RESULT}"
}
3c0fbf5 to
0979ec7
Compare
|
I think the code now is a good shape, let me know how we can unblock this, if there is any other change you would like to see. |
|
/retest |
|
/retest |
|
Sorry, the grep bit in get_interface_of_ip is wrong for some reason, just noticing now. Let me fix it. |
Sorry for the delay, I'll change the grep command a bit, but I have tested the current version against a number of different containers, from SUSE images to Ubuntu without any problem. Let's see... |
0979ec7 to
354f16c
Compare
|
/retest |
|
Honestly, the commits here seem to be reasonable deliniated, I'm not sure where the requests to squash them is coming from. Unlike in gerrit, we don't have any "single PR - single commit" rule. |
| wait_for_interface_or_ip | ||
|
|
||
| if [[ "$(echo "${LISTEN_ALL_INTERFACES}" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then | ||
| export IRONIC_HOST_IP="::" |
There was a problem hiding this comment.
I wonder if this one will be easy to confuse with the existing IRONIC_URL_HOST. I'm not sure what a better alternative would be, but I'm worried about this change deepening the confusion. If we cannot find an alternative, I'd rather leave the "if" condition in the template.
There was a problem hiding this comment.
Since IRONIC_URL_HOST can be different from the actual listening address, we could change IRONIC_HOST_IP to IRONIC_LISTEN_ADDRESS/IRONIC_BIND_ADDRESS (BTW, it could actually be a hostname too). And/or limit the scope of IRONIC_URL_HOST to ironic-common.sh, which is probably not a bad thing anyway. Along with some documentation.
There was a problem hiding this comment.
I don't know if you guys had the chance to have a think about it, but the more I think about it the more I believe we should address this "globally": it's not very clear from the outside what controls what when it comes to IP addresses, for instance IRONIC_IP is not even mentioned in the README file. I can drop this specific commit from the PR, but if so we should take the chance to review the root problem of ease of understanding of which variable affects what and their documentation.
There was a problem hiding this comment.
I would say let's address the naming of the IP variable separately. At least that would be my preference @mchiappero , I agree with you that the naming has to be handled globally and I think a separate independent PR would be the way to go for the sake of clarity and ease of reviewing.
| wait_for_interface_or_ip | ||
|
|
||
| if [[ "$(echo "${LISTEN_ALL_INTERFACES}" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then | ||
| export IRONIC_HOST_IP="::" |
There was a problem hiding this comment.
I would say let's address the naming of the IP variable separately. At least that would be my preference @mchiappero , I agree with you that the naming has to be handled globally and I think a separate independent PR would be the way to go for the sake of clarity and ease of reviewing.
06ff57e to
3b0da3e
Compare
|
I have dropped the templating related commit and squashed the last two commits. Edit: and rebased. Sorry for the confusion but the content of the commits has not changed. |
Whether IRONIC_IP or PROVISIONIG_IP is provided to ironic-image, any such address should be checked for validity and, if needed, properly formatted. For this reason, this commit introduces parse_ip_address to be consumed inside wait_for_interface_or_ip. Signed-off-by: Marco Chiappero <marco.chiappero@suse.com>
Add a new get_interface_of_ip function that returns the name of the interface of a given IP, and use it to determine if the PROVISIONING_IP address is actually present on a network interface. This improves the code readability and enables additional debugging output. This function supersedes a similar check present in get_provisioning_interface, hence this commit also reverts commit 2742439. Signed-off-by: Marco Chiappero <marco.chiappero@suse.com>
3b0da3e to
8c478b4
Compare
|
We should be good to merge now, let me know so that we can start closing these old MR. Thank you! |
|
/test metal3-centos-e2e-integration-test-main |
|
/retest |
|
/retest |
|
I think we can now lift the block, @elfosardo? |
|
/unhold |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: elfosardo, Rozzii The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ackport Bug OCPBUGS-76547: Bump 4.20 ironic-image to include firmware update fixes
What this PR does / why we need it:
This PR introduces a set of code refactoring, aiming at making the code more readable but extracting common logic that may become useful with future code additions. Most notably:
In the future a matching utility function to retrieve the (first) IP address assigned to an interface will also be added, but implies more changes and will be introduced along with other functional changes.
Checklist: