Skip to content

Commit

Permalink
Merge remote-tracking branch 'couchbase/cheshire-cat'
Browse files Browse the repository at this point in the history
* couchbase/cheshire-cat:
  MB-46363: Remove for pre epoch CCCP [2/2]

Change-Id: If2fd8055d5cac1c599b8bc0c34d02b9c36e239b3
  • Loading branch information
trondn committed Jul 8, 2021
2 parents afc6023 + 0b13879 commit 8c55d2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 52 deletions.
47 changes: 11 additions & 36 deletions daemon/mcbp_validators.cc
Expand Up @@ -1055,19 +1055,13 @@ static Status get_cluster_config_validator(Cookie& cookie) {
}

static Status set_cluster_config_validator(Cookie& cookie) {
// @todo until ns_server supports the new format we need backward
// compat
auto& header = cookie.getHeader();
uint8_t extlen = header.getExtlen();

using cb::mcbp::request::DeprecatedSetClusterConfigPayload;
using cb::mcbp::request::SetClusterConfigPayload;

// @todo extlen should be set to sizeof(SetClusterConfigPayload) once
// ns_server adds support for it
auto status = McbpValidator::verify_header(
cookie,
extlen,
sizeof(SetClusterConfigPayload),
ExpectedKeyLen::Any,
ExpectedValueLen::NonZero,
ExpectedCas::Any,
Expand All @@ -1077,37 +1071,18 @@ static Status set_cluster_config_validator(Cookie& cookie) {
return status;
}

// @todo remove when ns_server supports the format
if (extlen == sizeof(DeprecatedSetClusterConfigPayload)) {
auto extdata = header.getExtdata();
const auto& payload =
*reinterpret_cast<const DeprecatedSetClusterConfigPayload*>(
extdata.data());
if (payload.getRevision() < 0) {
cookie.setErrorContext("Revision number must not be less than 0");
return Status::Einval;
}
return Status::Success;
auto extdata = header.getExtdata();
const auto& payload =
*reinterpret_cast<const SetClusterConfigPayload*>(extdata.data());
if (payload.getRevision() < 1) {
cookie.setErrorContext("Revision number must not be less than 1");
return Status::Einval;
}

if (extlen == sizeof(SetClusterConfigPayload)) {
auto extdata = header.getExtdata();
const auto& payload = *reinterpret_cast<const SetClusterConfigPayload*>(
extdata.data());
if (payload.getRevision() < 1) {
cookie.setErrorContext("Revision number must not be less than 1");
return Status::Einval;
}
if (payload.getEpoch() < 1) {
cookie.setErrorContext("Epoch must not be less than 1");
return Status::Einval;
}
return Status::Success;
if (payload.getEpoch() < 1) {
cookie.setErrorContext("Epoch must not be less than 1");
return Status::Einval;
}

cookie.setErrorContext(
"Extras should contain 64 bit Epoch and 64 bit Revision");
return Status::Einval;
return Status::Success;
}

static Status verbosity_validator(Cookie& cookie) {
Expand Down
19 changes: 3 additions & 16 deletions daemon/protocol/mcbp/cluster_config_executor.cc
Expand Up @@ -226,24 +226,11 @@ void set_cluster_config_executor(Cookie& cookie) {
return;
}

ClustermapVersion version;

// Is this a new or an old-style message
auto extras = req.getExtdata();
using cb::mcbp::request::DeprecatedSetClusterConfigPayload;
using cb::mcbp::request::SetClusterConfigPayload;
if (extras.size() == sizeof(DeprecatedSetClusterConfigPayload)) {
// @todo remove once ns_server is up to date!
const auto& ext = *reinterpret_cast<
const cb::mcbp::request::DeprecatedSetClusterConfigPayload*>(
extras.data());
version = {0, ext.getRevision()};
} else {
const auto& ext = *reinterpret_cast<
const cb::mcbp::request::SetClusterConfigPayload*>(
extras.data());
version = {ext.getEpoch(), ext.getRevision()};
}
const auto& ext = *reinterpret_cast<
const cb::mcbp::request::SetClusterConfigPayload*>(extras.data());
const ClustermapVersion version = {ext.getEpoch(), ext.getRevision()};

bool failed = false;
try {
Expand Down

0 comments on commit 8c55d2b

Please sign in to comment.