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

auth: tolerate missing mgr keys #11360

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/auth/cephx/CephxClientHandler.cc
Expand Up @@ -74,7 +74,11 @@ int CephxClientHandler::build_request(bufferlist& bl) const
return 0;
}

if (need) {
// do not bother (re)requesting tickets if we *only* need the MGR
// ticket; that can happen during an upgrade and we want to avoid a
// loop. we'll end up re-requesting it later when the secrets
// rotating.
if (need && need != CEPH_ENTITY_TYPE_MGR) {
/* get service tickets */
ldout(cct, 10) << "get service keys: want=" << want << " need=" << need << " have=" << have << dendl;

Expand Down
25 changes: 19 additions & 6 deletions src/auth/cephx/CephxServiceHandler.cc
Expand Up @@ -163,19 +163,32 @@ int CephxServiceHandler::handle_request(bufferlist::iterator& indata, bufferlist

ret = 0;
vector<CephXSessionAuthInfo> info_vec;
for (uint32_t service_id = 1; service_id <= ticket_req.keys; service_id <<= 1) {
int found_services = 0;
int service_err = 0;
for (uint32_t service_id = 1; service_id <= ticket_req.keys;
service_id <<= 1) {
if (ticket_req.keys & service_id) {
ldout(cct, 10) << " adding key for service " << ceph_entity_type_name(service_id) << dendl;
ldout(cct, 10) << " adding key for service "
<< ceph_entity_type_name(service_id) << dendl;
CephXSessionAuthInfo info;
int r = key_server->build_session_auth_info(service_id, auth_ticket_info, info);
int r = key_server->build_session_auth_info(service_id,
auth_ticket_info, info);
// tolerate missing MGR rotating key for the purposes of upgrades.
if (r < 0) {
ret = r;
break;
}
ldout(cct, 10) << " missing key for service "
<< ceph_entity_type_name(service_id) << dendl;
service_err = r;
continue;
}
info.validity += cct->_conf->auth_service_ticket_ttl;
info_vec.push_back(info);
++found_services;
}
}
if (!found_services && service_err) {
ldout(cct, 10) << __func__ << " did not find any service keys" << dendl;
ret = service_err;
}
CryptoKey no_key;
build_cephx_response_header(cephx_header.request_type, ret, result_bl);
cephx_build_service_ticket_reply(cct, auth_ticket_info.session_key, info_vec, false, no_key, result_bl);
Expand Down