Skip to content

python-common/hostspec: normalize hostnames for case-insensitive matc… - #66820

Merged
rkachach merged 3 commits into
ceph:mainfrom
Shubhaj1810:fix-hostname-case-insensitive-v2
May 12, 2026
Merged

rkachach merged 3 commits into
ceph:mainfrom
Shubhaj1810:fix-hostname-case-insensitive-v2

Conversation

@Shubhaj1810

@Shubhaj1810 Shubhaj1810 commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Normalize hostnames at ingest to ensure case-insensitive handling in
python-common HostSpec and placement parsing logic.

Problem

Service placement could fail with "Unknown hosts" when mixed-case
hostnames were used in service specs while the host was registered
in lowercase.

Solution

  • Centralize hostname normalization
  • Apply consistently during placement parsing
  • Preserve existing failure semantics

Testing

  • Unit tests cover mixed-case hostname scenarios

Fixes: https://tracker.ceph.com/issues/74299
Signed-off-by: Shubha Jain [[email protected]]

Testing Logs
BEFORE FIX — Reproduce the Issue

1. Verify registered hostnames
ceph orch host ls

> ceph-node-00
> ceph-node-01
> ceph-node-02

2. Create a service spec with mixed-case hostname
cat > case-test.yaml << 'EOF'
service_type: nfs
service_id: case-test
placement:
  hosts:
    - Ceph-Node-00
EOF

3. Apply the spec (EXPECTED TO FAIL)
ceph orch apply -i case-test.yaml

Cannot place <NFSServiceSpec ...> on Ceph-Node-00: Unknown hosts

This is the reproduced issue.

AFTER FIX:

[ceph: root@ceph-node-00 /]# ceph orch host ls 
HOST          ADDR             LABELS  STATUS   
ceph-node-00  192.168.100.100  _admin          
ceph-node-01  192.168.100.101                   
ceph-node-02  192.168.100.102                   
3 hosts in cluster 
[ceph: root@ceph-node-00 /]# cat > case-test.yaml << 'EOF' service_type: nfs service_id: case-test placement: hosts: - Ceph-Node-00 EOF 
[ceph: root@ceph-node-00 /]# ceph orch apply -i case-test.yaml 
Scheduled nfs.case-test update... 

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@Shubhaj1810
Shubhaj1810 requested a review from a team as a code owner January 7, 2026 09:53
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

14 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

This PR replaces the previous one i.e
#66805
and is rebased cleanly onto upstream/main. The scope is limited to HostSpec and related placement parsing, and all requested review changes have been incorporated.

@phlogistonjohn phlogistonjohn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the future please do not close PRs and open new ones on the same topic because that breaks the flow of conversation. It could also be a seen as a way of "cheating" if somone asked for changes on the original PR but then didn't watch things closely enough to see the new PR appear. I doubt that's the case here, but it's a good reason not to open and close PRs for the same topic/branch.

If you are having trouble with git - ask for help first. Then if and only if nobody can help resolve the git issues should you consider opening a new PR for a topic that has already been discussed.

Comment on lines +360 to +361
# Type narrowing: all items are HostPlacementSpec
placement_hosts = cast(List[HostPlacementSpec], hosts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Huh?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I shouldn't be too cute in my reviews: what specifically happened that you think these lines are needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The cast was only needed due to a mypy type-narrowing limitation. I’ve now
restructured the code so each branch builds a well-typed list directly,
which avoids the cast and keeps the behavior unchanged.

@@ -98,6 +98,11 @@ class HostPlacementSpec(NamedTuple):
network: str
name: str

@classmethod

@phlogistonjohn phlogistonjohn Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this a classmethod? It is operating on the same fields that make up the named tuple, right?
Is there a fear to create an intermediate HostPlacementSpec with incorrect case vs just chaining methods like HostPlacementSpec(foo, bar, baz).normalized()?

@Shubhaj1810 Shubhaj1810 Jan 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the classmethod and now normalize the hostname directly in
from_json to keep the code simple and clearer.

@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

In the future please do not close PRs and open new ones on the same topic because that breaks the flow of conversation. It could also be a seen as a way of "cheating" if somone asked for changes on the original PR but then didn't watch things closely enough to see the new PR appear. I doubt that's the case here, but it's a good reason not to open and close PRs for the same topic/branch.

If you are having trouble with git - ask for help first. Then if and only if nobody can help resolve the git issues should you consider opening a new PR for a topic that has already been discussed.

Understood, thanks for the clarification.

Closing and reopening the PR was not intentional to bypass review — I ran
into local git issues and should have asked for help instead. I’ll keep all
future updates on a single PR and ask for guidance if I hit git problems
again.

@phlogistonjohn phlogistonjohn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks. it looks a lot better to me now.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Apr 17, 2026
…hing

Normalize HostSpec and related placement parsing to ensure hostnames
are treated case-insensitively when supplied via service specs.

This prevents service placement failures caused by mixed-case hostnames.

Fixes: https://tracker.ceph.com/issues/74299

Signed-off-by: Shubha Jain <[email protected]>
@Shubhaj1810
Shubhaj1810 force-pushed the fix-hostname-case-insensitive-v2 branch from 94f52d6 to c3d9bf0 Compare April 17, 2026 11:45
@github-actions github-actions Bot removed the stale label Apr 17, 2026
@rkachach

Copy link
Copy Markdown
Contributor

jenkins retest this please

@Shubhaj1810
Shubhaj1810 force-pushed the fix-hostname-case-insensitive-v2 branch from c3d9bf0 to b8a4f82 Compare April 29, 2026 12:56
@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@rkachach

Copy link
Copy Markdown
Contributor

@rkachach
rkachach merged commit 912b2b7 into ceph:main May 12, 2026
6 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I found one or more Fixes: tags in the commit messages in

git log 912b2b75284f95dbec766ebe17f4ba87c36e13ec^..912b2b75284f95dbec766ebe17f4ba87c36e13ec

The referenced tickets are:

Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them.

Update Log: https://github.com/ceph/ceph/actions/runs/25725706411

insatomcat added a commit to seapath/ansible that referenced this pull request Nov 19, 2026
From Ceph 21 on, cephadm lowercases the names of the hosts it manages
(ceph/ceph#66820) and the monitors it deploys take that name. With an
uppercase hostname in the inventory, "Confirm monitors are in monmap"
looks for HOST2 in a monmap that lists mon.host2 and fails after its
30 retries while the monitor is in quorum.

ceph orch ps reports lowercase host names as well, so the lookup of
the mgr running on each host finds nothing and mgr/prometheus
server_addr is silently left unset.

Compare the names without case in both places. Older Ceph releases
keep the case, which this also handles.

Signed-off-by: Florent Carli <[email protected]>
insatomcat added a commit to seapath/ansible that referenced this pull request Nov 19, 2026
From Ceph 21 on, cephadm lowercases the names of the hosts it manages
(ceph/ceph#66820) and the monitors it deploys take that name. With an
uppercase hostname in the inventory, "Confirm monitors are in monmap"
looks for HOST2 in a monmap that lists mon.host2 and fails after its
30 retries while the monitor is in quorum.

ceph orch ps reports lowercase host names as well, so the lookup of
the mgr running on each host finds nothing and mgr/prometheus
server_addr is silently left unset.

Compare the names without case in both places. Older Ceph releases
keep the case, which this also handles.

Signed-off-by: Florent Carli <[email protected]>
insatomcat added a commit to seapath/ansible that referenced this pull request Nov 19, 2026
From Ceph 21 on, cephadm lowercases the names of the hosts it manages
(ceph/ceph#66820) and the monitors it deploys take that name. With an
uppercase hostname in the inventory, "Confirm monitors are in monmap"
looks for HOST2 in a monmap that lists mon.host2 and fails after its
30 retries while the monitor is in quorum.

ceph orch ps reports lowercase host names as well, so the lookup of
the mgr running on each host finds nothing and mgr/prometheus
server_addr is silently left unset.

Compare the names without case in both places. Older Ceph releases
keep the case, which this also handles.

Signed-off-by: Florent Carli <[email protected]>
insatomcat added a commit to seapath/ansible that referenced this pull request Nov 20, 2026
From Ceph 21 on, cephadm lowercases the names of the hosts it manages
(ceph/ceph#66820) and the monitors it deploys take that name. With an
uppercase hostname in the inventory, "Confirm monitors are in monmap"
looks for HOST2 in a monmap that lists mon.host2 and fails after its
30 retries while the monitor is in quorum.

ceph orch ps reports lowercase host names as well, so the lookup of
the mgr running on each host finds nothing and mgr/prometheus
server_addr is silently left unset.

Compare the names without case in both places. Older Ceph releases
keep the case, which this also handles.

Signed-off-by: Florent Carli <[email protected]>
insatomcat added a commit to seapath/ansible that referenced this pull request Nov 20, 2026
From Ceph 21 on, cephadm lowercases the names of the hosts it manages
(ceph/ceph#66820) and the monitors it deploys take that name. With an
uppercase hostname in the inventory, "Confirm monitors are in monmap"
looks for HOST2 in a monmap that lists mon.host2 and fails after its
30 retries while the monitor is in quorum.

ceph orch ps reports lowercase host names as well, so the lookup of
the mgr running on each host finds nothing and mgr/prometheus
server_addr is silently left unset.

Compare the names without case in both places. Older Ceph releases
keep the case, which this also handles.

Signed-off-by: Florent Carli <[email protected]>
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.

4 participants