Skip to content

mgr/volumes/nfs: Add cluster show info command#35743

Merged
batrick merged 2 commits intoceph:masterfrom
varshar16:wip-nfs-cluster-show-info
Jul 7, 2020
Merged

mgr/volumes/nfs: Add cluster show info command#35743
batrick merged 2 commits intoceph:masterfrom
varshar16:wip-nfs-cluster-show-info

Conversation

@varshar16
Copy link
Contributor

@varshar16 varshar16 commented Jun 24, 2020

[root@varsha build]# ./bin/ceph nfs cluster info vstart
*** DEVELOPER MODE: setting PATH, PYTHONPATH and LD_LIBRARY_PATH ***
2020-06-29T14:22:26.634+0530 7fe5a2c21700 -1 WARNING: all dangerous and experimental features are enabled.
2020-06-29T14:22:26.649+0530 7fe5a2c21700 -1 WARNING: all dangerous and experimental features are enabled.
{
    "hostname": "smithi112",
    "IP": [
        "172.21.15.112"
    ],
    "Port": 2049
}

Fixes: https://tracker.ceph.com/issues/45743
Signed-off-by: Varsha Rao varao@redhat.com

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@varshar16
Copy link
Contributor Author

jenkins retest this please

"""
result = {'IP': [ip[4][0] for ip in socket.getaddrinfo(cluster.hostname, 2049,
flags=socket.AI_CANONNAME, type=socket.SOCK_STREAM)],
'port': 2049 # Default ganesha port
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work right when ganesha is running on a different port?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently cephadm does not deploy ganesha on non-standard port.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's think about this. Cephadm doesn't (and hopefully never will) need the raw IP address. On the other hand. in case we want to do enhance cephadm, there is another option:

  1. Add a new property ip or something similar to

  1. Enhance

def _refresh_hosts_and_daemons(self):

to run also getaddrinfo for the host. (Do it here, to be able to return the current IP of a host)

  1. update the IP in the inventory, similar to

def set_addr(self, host, addr):
self.assert_host(host)
self._inventory[host]['addr'] = addr
self.save()

  1. let ceph orch host ls also return this attribute

  2. change this code here to also call self.mgr.get_hosts()

This way, everyone would benefit from this information.

But I'm perfectly happy with keeping this code here in show_nfs_cluster_info

Copy link
Member

Choose a reason for hiding this comment

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

Let's think about this. Cephadm doesn't (and hopefully never will) need the raw IP address.

I imagine what cephadm has for a hostname is just whatever gets passed to getaddrinfo (in ssh or elsewhere). Whether that "hostname" is also just a numeric one (i.e. an IP address) is irrelevant to it. (Edit:) Actually, I think it did matter because what I ended up doing in ceph-linode was lookup the FQDN for each VM:

https://github.com/batrick/ceph-linode/blob/cephadm/cephadm.yml#L63-L69

Which does not thrill me. I do think cephadm should be willing to take an IP address for the host so it works with private LANs. IMO, there really should not be any requirement that the cluster have hostnames which can be looked up via DNS.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's think about this. Cephadm doesn't (and hopefully never will) need the raw IP address.

I imagine what cephadm has for a hostname is just whatever gets passed to getaddrinfo (in ssh or elsewhere). Whether that "hostname" is also just a numeric one (i.e. an IP address) is irrelevant to it. (Edit:) Actually, I think it did matter because what I ended up doing in ceph-linode was lookup the FQDN for each VM:

https://github.com/batrick/ceph-linode/blob/cephadm/cephadm.yml#L63-L69

Which does not thrill me. I do think cephadm should be willing to take an IP address for the host so it works with private LANs.

you can do that already:

ceph orch host add <name> <addr>
# e.g.
ceph orch host add myhostname 1.2.3.4
# or
ceph orch host add myhostname myhostname.domain.tld

cephadm will then use the addr to connect to the host.

IMO, there really should not be any requirement that the cluster have hostnames which can be looked up via DNS.

yup. that was the reason we added the addr field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer moving this to cephadm and do name resolution only if ip is not specified.

@jtlayton
Copy link
Contributor

jenkins test docs

@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch from 27912a4 to c017bd2 Compare June 25, 2020 15:07
@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch from c017bd2 to c3d4565 Compare June 29, 2020 09:03
@varshar16
Copy link
Contributor Author

@sebastian-philipp @mgfritch Is there a way to list hosts for only nfs service type ?

@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch from c3d4565 to ceb2a98 Compare July 1, 2020 11:41
@varshar16 varshar16 marked this pull request as ready for review July 1, 2020 11:44
@varshar16
Copy link
Contributor Author

As per conversation with @sebastian-philipp hostname resolution in cephadm
requires further discussion. For now resolution will be done in volumes nfs
interface.

@varshar16
Copy link
Contributor Author

jenkins retest this please

@batrick
Copy link
Member

batrick commented Jul 1, 2020

jenkins retest this please

@varshar16
Copy link
Contributor Author

Test Failed: http://qa-proxy.ceph.com/teuthology/varsha-2020-07-01_15:28:24-rados-wip-nfs-cluster-show-info-distro-basic-smithi/5194588/

2020-07-01T15:51:32.209 INFO:tasks.cephfs_test_runner:Traceback (most recent call last):
2020-07-01T15:51:32.209 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-c_wip-nfs-cluster-show-info/qa/tasks/cephfs/test_nfs.py", line 374, in test_cluster_info
2020-07-01T15:51:32.210 INFO:tasks.cephfs_test_runner:    self.assertDictEqual(info_output, host_details)
2020-07-01T15:51:32.210 INFO:tasks.cephfs_test_runner:AssertionError: {'hostname': 'smithi096', 'IP': ['172.21.15.96', '172.21.15.96'], 'Port': 2049} != {'hostname': 'smithi096', 'IP': ['172.21.15.96'], 'Port': 2049}
2020-07-01T15:51:32.210 INFO:tasks.cephfs_test_runner:- {'IP': ['172.21.15.96', '172.21.15.96'], 'Port': 2049, 'hostname': 'smithi096'}
2020-07-01T15:51:32.210 INFO:tasks.cephfs_test_runner:?         ----------------
2020-07-01T15:51:32.211 INFO:tasks.cephfs_test_runner:
2020-07-01T15:51:32.211 INFO:tasks.cephfs_test_runner:+ {'IP': ['172.21.15.96'], 'Port': 2049, 'hostname': 'smithi096'}
2020-07-01T15:51:32.211 INFO:tasks.cephfs_test_runner:
2020-07-01T15:51:32.212 INFO:tasks.cephfs_test_runner:----------------------------------------------------------------------
2020-07-01T15:51:32.212 INFO:tasks.cephfs_test_runner:Ran 1 test in 25.595s
2020-07-01T15:51:32.212 INFO:tasks.cephfs_test_runner:
2020-07-01T15:51:32.212 INFO:tasks.cephfs_test_runner:FAILED (failures=1)

Test Passed: http://pulpito.ceph.com/varsha-2020-07-01_15:28:24-rados-wip-nfs-cluster-show-info-distro-basic-smithi/5194589/

@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch from ceb2a98 to 93fcb21 Compare July 1, 2020 16:33
@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch from 93fcb21 to 2483c57 Compare July 1, 2020 18:09
@varshar16
Copy link
Contributor Author

Rebased

return (0, json.dumps(host_ip, indent=4), '')
except socket.gaierror:
continue
return 0, "", ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Return an empty dictionary if there are no NFS clusters?

{}

and if the NFS cluster is defined, but no daemons are running?

{
    "ganesha-foo": {}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Return an empty dictionary if there are no NFS clusters?

{}

Done.

and if the NFS cluster is defined, but no daemons are running?

{
    "ganesha-foo": {}
}

I prefer not listing it if no daemons are present.

@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch from 2483c57 to 63e6d7d Compare July 2, 2020 15:22
@varshar16 varshar16 requested a review from mgfritch July 2, 2020 15:26
Copy link
Contributor

@mgfritch mgfritch left a comment

Choose a reason for hiding this comment

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

minor nits, but generally looks good 👍

"Port": 2049 # Default ganesha port
}
except socket.gaierror:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe still report the daemon exists, but set the IP to a NoneType?

Copy link
Contributor Author

@varshar16 varshar16 Jul 3, 2020

Choose a reason for hiding this comment

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

Let's not add daemon if we cannot resolve its hostname.

('2404:6800:4009:80d::200e', 2049, 0, 0))]
"""
try:
host_ip[cluster.daemon_id] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

on second thought, is the daemon_id useful in this context? maybe return a List instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right daemon_id is not instead I have added cluster_id

{
    "vstart": [
        {
            "hostname": "varsha",
            "IP": [
                "::1",
                "127.0.0.1"
            ],
            "Port": 2049
        }
    ]
}

@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch 2 times, most recently from 8af6d68 to e365dd5 Compare July 6, 2020 05:36
@varshar16
Copy link
Contributor Author

Rebased

@varshar16
Copy link
Contributor Author

varshar16 added 2 commits July 7, 2020 10:50
Signed-off-by: Varsha Rao <varao@redhat.com>
@varshar16 varshar16 force-pushed the wip-nfs-cluster-show-info branch from e365dd5 to 93aa5e4 Compare July 7, 2020 05:20
@varshar16 varshar16 requested a review from batrick July 7, 2020 05:22
@batrick batrick merged commit 1dbad70 into ceph:master Jul 7, 2020
@varshar16 varshar16 deleted the wip-nfs-cluster-show-info branch July 16, 2020 16:44
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.

5 participants