Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr: add the ip addr of standbys #16476

Merged
merged 1 commit into from Sep 5, 2017

Conversation

renhwztetecs
Copy link
Contributor

@renhwztetecs renhwztetecs commented Jul 21, 2017

we need to manage the ip addr of the "standbys" state,
because the hostname/gid is insufficient to locate the
Standby node.

[root@node173 build]# ceph mgr metadata
[
{
"id": "node173",
"addr": "10.118.202.173",
"arch": "x86_64",
"ceph_version": "ceph version 12.1.2-589-gc8c837f (c8c837f) luminous (rc)",
"cpu": "Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz",
"distro": "centos",
"distro_description": "CentOS Linux 7 (Core)",
"distro_version": "7",
"hostname": "node173",
"kernel_description": "#1 SMP Mon Jun 30 12:09:22 UTC 2014",
"kernel_version": "3.10.0-123.el7.x86_64",
"mem_swap_kb": "4079612",
"mem_total_kb": "3768768",
"os": "Linux"
}
]

Signed-off-by: huanwen ren ren.huanwen@zte.com.cn

@jcsp
Copy link
Contributor

jcsp commented Jul 21, 2017

I'm not sure why this is needed -- what is it that needs to see the address of the client?

For human eyes, the name is what is meant to act as the identifier.

@renhwztetecs renhwztetecs force-pushed the renhw-wip-mgr-standby-ip branch 3 times, most recently from 21dec25 to b29a658 Compare July 21, 2017 11:12
@renhwztetecs
Copy link
Contributor Author

@jcsp
Usually host hostname only one, but the corresponding IP address may exist more than one, we do not know the use of Mgr is that ip address

@liuchang0812
Copy link
Contributor

I think it would be better to put the IP informations to ceph mgr metadata. see liuchang0812#4

@renhwztetecs
Copy link
Contributor Author

@liuchang0812 👍
I would like to get the ip adds information from monc in simple way.

@liuchang0812
Copy link
Contributor

sage merged metadata command PR already, you could use pybind to get standby's addresses

@jcsp
Copy link
Contributor

jcsp commented Jul 27, 2017

I'm still not clear why this is needed. Your mgr daemon name is unique, and if it is a hostname then you can resolve it to an IP address (externally) if you need to.

Can you explain (beyond just saying that you want to know the IP address), why you need it. Is there some external piece of software that wants to know?

@renhwztetecs
Copy link
Contributor Author

@liuchang0812
thank you for your hint
@jcsp
yes, we have their own management system need to know all the state of mgr, including standby, and for our management system ip address is more intuitive than the host name

@tchaikov
Copy link
Contributor

@renhwztetecs why it's more intuitive ? is there any additional information that you cannot get by resolving the IP addresss?

@renhwztetecs
Copy link
Contributor Author

@tchaikov I'm later
If the standby provides ip address, we can directly through the MgrMap to obtain all the standby IP address in the cluster, if there is no standby IP address, you also need to go to hostname to find IP

@@ -157,7 +157,7 @@ void MgrStandby::send_beacon()
// as available in the map)
bool available = active_mgr != nullptr && active_mgr->is_initialized();

auto addr = available ? active_mgr->get_server_addr() : entity_addr_t();
auto addr = available ? active_mgr->get_server_addr() : monc.get_my_addr();
Copy link
Member

Choose a reason for hiding this comment

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

The risk here seems to be that someone might assume the standby addr will become the active addr when that's not actually the case. That aside I do'nt have a philosophical problem with this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for your suggest

@jcsp
Copy link
Contributor

jcsp commented Aug 9, 2017

Since 1bf4a89, the mgr has sent metadata to the mons -- I would be okay with adding the IP address there. But let's make it just the IP address, and not the whole entity_addr_t that comes out of monc.get_my_addr().

I prefer to use metadata rather than mgrmap, because the metadata's purpose is to hold advisory information that may be interesting to external systems, whereas the mgrmap is for information that Ceph needs internally.

@liewegas
Copy link
Member

liewegas commented Aug 9, 2017

👍

@renhwztetecs
Copy link
Contributor Author

I will change to metadata

@renhwztetecs
Copy link
Contributor Author

jenkins retest this please

@renhwztetecs
Copy link
Contributor Author

changed to metadata



const char *host_ip = NULL;
char addr_buf[129];
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid hardcoded buffer size, I guess this should be MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) + 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is more elegant.
For INET and INET6 do a different definition, but also do not need "+1"

default:
break;
};
metadata["addr"] = host_ip;
Copy link
Contributor

Choose a reason for hiding this comment

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

inet_ntop returns null on errors -- must check the return value to avoid possibility of assigning null to a std string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jcsp
I assigned a value of “0.0.0.0” when "host_ip" is NULL, and log it,
I'm not sure if there is a better way.
thank you

break;
};
if (NULL == host_ip) {
metadata["addr"] = "0.0.0.0";
Copy link
Contributor

Choose a reason for hiding this comment

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

If the addr isn't AF_INT or AF_INET6, then it's probably not IP at all (an RDMA messenger or something like that), so I'd just return an empty string rather than something IP-like.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes,""is good


switch(addr_standby.get_family()) {
case AF_INET:
char addr_buf_inet[INET_ADDRSTRLEN];
Copy link
Contributor

Choose a reason for hiding this comment

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

Defining the buffer inside the switch {} and then using the host_ip pointer to it from outside the {} seems incorrect -- I think the compiler is allowed to re-use that space after the end of the {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jcsp
Yes has this problem,thanks.
unified use char addr_buf[INET6_ADDRSTRLEN],
because INET6_ADDRSTRLEN=46 > INET_ADDRSTRLEN=16.
reference:https://linux.die.net/man/3/inet_pton

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jcsp
All changed it.

@renhwztetecs renhwztetecs force-pushed the renhw-wip-mgr-standby-ip branch 2 times, most recently from c1fc759 to c56a279 Compare August 15, 2017 11:28
@renhwztetecs
Copy link
Contributor Author

jenkins retest this please

INET6_ADDRSTRLEN);
break;
default:
break;
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this into an entity_addr_t method (msg/msg_types.h) called something like std::string ip_only_to_str() const?

Copy link
Member

Choose a reason for hiding this comment

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

Then the change to this files becomes a single line,

metadata["addr"] = monc.get_my_addr().ip_only_to_str();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liewegas
I have changed it

} else {
ip_str = host_ip;
}
return ip_str;
Copy link
Member

Choose a reason for hiding this comment

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

this can be simplified to


return host_ip ? host_ip : "";

and drop the ip_str decl

Otherwise, looks good, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liewegas
“Less is More” :-)
updated it

@renhwztetecs renhwztetecs force-pushed the renhw-wip-mgr-standby-ip branch 2 times, most recently from ae4c79a to 6fb8e48 Compare August 31, 2017 03:49
@@ -384,6 +385,24 @@ struct entity_addr_t {
}
}

std::string ip_only_to_str() {
Copy link
Contributor

@tchaikov tchaikov Aug 31, 2017

Choose a reason for hiding this comment

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

please mark this method const. and move the implementation to .cc file. as msg_types.h is included by quite a few places, put the implementation here could prolong the compiling time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first I also considered this problem, but found that all the implementation in "msg_types.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't get you. could you rephrase you reply?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I may not have described it clearly, I mean whether all the implementations in msg_types.h are placed in msg_types.cc?

Copy link
Contributor

Choose a reason for hiding this comment

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

not all.

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 put this one in the .cc file. we can move others later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liewegas
ok! updated it

@renhwztetecs renhwztetecs force-pushed the renhw-wip-mgr-standby-ip branch 2 times, most recently from da39c8b to d52781a Compare September 1, 2017 09:23
@@ -290,3 +290,22 @@ void entity_addrvec_t::generate_test_instances(list<entity_addrvec_t*>& ls)
ls.back()->v.push_back(entity_addr_t());
ls.back()->v.push_back(entity_addr_t());
}

const std::string ip_only_to_str()
Copy link
Contributor

@tchaikov tchaikov Sep 1, 2017

Choose a reason for hiding this comment

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

i mean, std::string ip_only_to_str() const. as this method is not changing in4_addr, IIUC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov
updated it, thank you

we need to manage the ip addr of the "standbys" state,
because the hostname/gid is insufficient to locate the
Standby node. we add ip of the mgr standby to metadata.

Signed-off-by: huanwen ren <ren.huanwen@zte.com.cn>
@tchaikov tchaikov merged commit c46220e into ceph:master Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants