Repository navigation
[action] [PR:28441] kubesonic: fix k8s node lookup using lowercase hostname - #1480
Merged
Merged
Conversation
### Description of PR
Summary:
Fixes a flaky/always-failing `test_kubesonic_join_and_disjoin` on DUTs with mixed-case hostnames (e.g. Nokia platforms like `str4-Nokia-7220-Th6p-1`).
### Type of change
- [x] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
- [ ] Skipped for non-supported platforms
- [ ] Test case improvement
### Back port request
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [ ] 202511
- [ ] 202512
- [ ] 202605
### Approach
#### What is the motivation for this PR?
`tests/kubesonic/test_k8s_join_disjoin.py::test_kubesonic_join_and_disjoin` fails with a join timeout on DUTs whose hostname contains uppercase characters (e.g. `str4-Nokia-7220-Th6p-1`). Kubelet registers k8s node names in lowercase per RFC-1123 (e.g. `str4-nokia-7220-th6p-1`), but the test used the raw mixed-case `duthost.hostname` for all `kubectl get nodes`/`label node`/`field-selector spec.nodeName=` lookups. These lookups therefore always returned `NotFound`/empty results, even though the DUT had actually joined the k8s cluster successfully, masquerading as a join failure.
#### How did you do it?
Introduced `k8s_node_name = duthost.hostname.lower()` and used it everywhere a kubectl command looks up the node by name: `trigger_join_and_check`, `trigger_disjoin_and_check`, `_get_daemonset_pod_status`, `deploy_daemonset_pod_and_check`, `delete_daemonset_pod_and_check`.
#### How did you verify/test it?
Reproduced the original failure live on testbed `vms13-lt2-nokia-th6-1` (DUT `str4-Nokia-7220-Th6p-1`, Nokia TH6-O256). After applying the fix, `test_kubesonic_join_and_disjoin` passed (166.57s), where it previously failed with a join timeout. `flake8`/pre-commit checks pass.
#### Any platform specific information?
Affects any DUT whose hostname contains uppercase letters (commonly seen on Nokia platforms in this environment). No impact on DUTs with already-lowercase hostnames, since `.lower()` is a no-op there.
#### Supported testbed topology if it's a new test case?
N/A (existing test, no topology change).
### Documentation
N/A
Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
Collaborator
Author
|
Original PR: sonic-net/sonic-mgmt#28441 |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
Author
|
/azp run |
1 similar comment
Collaborator
Author
|
/azp run |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
1 of 12 tasks
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fixes a flaky/always-failing
test_kubesonic_join_and_disjoinon DUTs with mixed-case hostnames (e.g. Nokia platforms likestr4-Nokia-7220-Th6p-1).Type of change
Back port request
Approach
What is the motivation for this PR?
tests/kubesonic/test_k8s_join_disjoin.py::test_kubesonic_join_and_disjoinfails with a join timeout on DUTs whose hostname contains uppercase characters (e.g.str4-Nokia-7220-Th6p-1). Kubelet registers k8s node names in lowercase per RFC-1123 (e.g.str4-nokia-7220-th6p-1), but the test used the raw mixed-caseduthost.hostnamefor allkubectl get nodes/label node/field-selector spec.nodeName=lookups. These lookups therefore always returnedNotFound/empty results, even though the DUT had actually joined the k8s cluster successfully, masquerading as a join failure.How did you do it?
Introduced
k8s_node_name = duthost.hostname.lower()and used it everywhere a kubectl command looks up the node by name:trigger_join_and_check,trigger_disjoin_and_check,_get_daemonset_pod_status,deploy_daemonset_pod_and_check,delete_daemonset_pod_and_check.How did you verify/test it?
Reproduced the original failure live on testbed
vms13-lt2-nokia-th6-1(DUTstr4-Nokia-7220-Th6p-1, Nokia TH6-O256). After applying the fix,test_kubesonic_join_and_disjoinpassed (166.57s), where it previously failed with a join timeout.flake8/pre-commit checks pass.Any platform specific information?
Affects any DUT whose hostname contains uppercase letters (commonly seen on Nokia platforms in this environment). No impact on DUTs with already-lowercase hostnames, since
.lower()is a no-op there.Supported testbed topology if it's a new test case?
N/A (existing test, no topology change).
Documentation
N/A
Signed-off-by: Sonic Build Admin sonicbld@microsoft.com