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
Conversation
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. |
21dec25
to
b29a658
Compare
@jcsp |
I think it would be better to put the IP informations to |
b29a658
to
9cd8c73
Compare
@liuchang0812 👍 |
sage merged metadata command PR already, you could use pybind to get standby's addresses |
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? |
@liuchang0812 |
@renhwztetecs why it's more intuitive ? is there any additional information that you cannot get by resolving the IP addresss? |
@tchaikov I'm later |
src/mgr/MgrStandby.cc
Outdated
@@ -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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your suggest
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. |
👍 |
I will change to metadata |
9cd8c73
to
be62513
Compare
jenkins retest this please |
changed to metadata |
src/mgr/MgrStandby.cc
Outdated
|
||
|
||
const char *host_ip = NULL; | ||
char addr_buf[129]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"
src/mgr/MgrStandby.cc
Outdated
default: | ||
break; | ||
}; | ||
metadata["addr"] = host_ip; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
be62513
to
97ff0c7
Compare
src/mgr/MgrStandby.cc
Outdated
break; | ||
}; | ||
if (NULL == host_ip) { | ||
metadata["addr"] = "0.0.0.0"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes,""is good
src/mgr/MgrStandby.cc
Outdated
|
||
switch(addr_standby.get_family()) { | ||
case AF_INET: | ||
char addr_buf_inet[INET_ADDRSTRLEN]; |
There was a problem hiding this comment.
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 {}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcsp
All changed it.
c1fc759
to
c56a279
Compare
jenkins retest this please |
src/mgr/MgrStandby.cc
Outdated
INET6_ADDRSTRLEN); | ||
break; | ||
default: | ||
break; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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();
There was a problem hiding this comment.
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
c56a279
to
fa107a5
Compare
src/msg/msg_types.h
Outdated
} else { | ||
ip_str = host_ip; | ||
} | ||
return ip_str; |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
ae4c79a
to
6fb8e48
Compare
src/msg/msg_types.h
Outdated
@@ -384,6 +385,24 @@ struct entity_addr_t { | |||
} | |||
} | |||
|
|||
std::string ip_only_to_str() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not all.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liewegas
ok! updated it
da39c8b
to
d52781a
Compare
src/msg/msg_types.cc
Outdated
@@ -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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
d52781a
to
389d676
Compare
we need to manage the ip addr of the "standbys" state,
because the hostname/gid is insufficient to locate the
Standby node.
Signed-off-by: huanwen ren ren.huanwen@zte.com.cn