Skip to content

[action] [PR:28441] kubesonic: fix k8s node lookup using lowercase hostname - #1480

Merged
mssonicbld merged 1 commit into
Azure:202608from
mssonicbld:cherry/msft-202608/28441
Oct 11, 2026
Merged

mssonicbld merged 1 commit into
Azure:202608from
mssonicbld:cherry/msft-202608/28441

Conversation

@mssonicbld

Copy link
Copy Markdown
Collaborator

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

  • 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

### 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>
@mssonicbld

Copy link
Copy Markdown
Collaborator Author

Original PR: sonic-net/sonic-mgmt#28441

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator Author

/azp run

1 similar comment
@mssonicbld

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@mssonicbld
mssonicbld merged commit daa572c into Azure:202608 Oct 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant