You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2019/03/05 04:50:45 UTC
[mesos] 04/04: Converted `UUID` proto messages to `id::UUID` in the
RP manager.
This is an automated email from the ASF dual-hosted git repository.
chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 120fab6af265fa65dcfaf0c6ca37a276b9b6714f
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Fri Mar 1 12:08:01 2019 -0800
Converted `UUID` proto messages to `id::UUID` in the RP manager.
Since the RP manager might interact with an arbitrary resource provider,
it should convert a `UUID` proto message received in a
`UPDATE_PUBLISH_RESOURCES_STATUS` call into a `id::UUID`, and ignore the
call if its `UUID` is not valid.
Review: https://reviews.apache.org/r/70082
---
src/resource_provider/manager.cpp | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/resource_provider/manager.cpp b/src/resource_provider/manager.cpp
index 876a8b2..7d3338e 100644
--- a/src/resource_provider/manager.cpp
+++ b/src/resource_provider/manager.cpp
@@ -173,7 +173,7 @@ struct ResourceProvider
ResourceProviderInfo info;
HttpConnection http;
- hashmap<UUID, Owned<Promise<Nothing>>> publishes;
+ hashmap<id::UUID, Owned<Promise<Nothing>>> publishes;
};
@@ -702,12 +702,13 @@ Future<Nothing> ResourceProviderManagerProcess::publishResources(
foreachpair (const ResourceProviderID& resourceProviderId,
const Resources& resources,
providedResources) {
- UUID uuid = protobuf::createUUID();
+ id::UUID uuid = id::UUID::random();
Event event;
event.set_type(Event::PUBLISH_RESOURCES);
- event.mutable_publish_resources()->mutable_uuid()->CopyFrom(uuid);
- event.mutable_publish_resources()->mutable_resources()->CopyFrom(resources);
+ *event.mutable_publish_resources()->mutable_uuid() =
+ protobuf::createUUID(uuid);
+ *event.mutable_publish_resources()->mutable_resources() = resources;
ResourceProvider* resourceProvider =
resourceProviders.subscribed.at(resourceProviderId).get();
@@ -960,30 +961,39 @@ void ResourceProviderManagerProcess::updatePublishResourcesStatus(
ResourceProvider* resourceProvider,
const Call::UpdatePublishResourcesStatus& update)
{
- const UUID& uuid = update.uuid();
+ Try<id::UUID> uuid = id::UUID::fromBytes(update.uuid().value());
+
+ if (uuid.isError()) {
+ LOG(ERROR)
+ << "Ignoring UpdatePublishResourcesStatus from resource provider "
+ << resourceProvider->info.id() << ": " << uuid.error();
+
+ return;
+ }
+
+ if (!resourceProvider->publishes.contains(uuid.get())) {
+ LOG(ERROR)
+ << "Ignoring UpdatePublishResourcesStatus from resource provider "
+ << resourceProvider->info.id() << ": Unknown UUID " << uuid.get();
- if (!resourceProvider->publishes.contains(uuid)) {
- LOG(ERROR) << "Ignoring UpdatePublishResourcesStatus from resource"
- << " provider " << resourceProvider->info.id()
- << " because UUID " << uuid << " is unknown";
return;
}
LOG(INFO)
<< "Received UPDATE_PUBLISH_RESOURCES_STATUS call for PUBLISH_RESOURCES"
- << " event " << uuid << " with " << update.status()
+ << " event " << uuid.get() << " with " << update.status()
<< " status from resource provider " << resourceProvider->info.id();
if (update.status() == Call::UpdatePublishResourcesStatus::OK) {
- resourceProvider->publishes.at(uuid)->set(Nothing());
+ resourceProvider->publishes.at(uuid.get())->set(Nothing());
} else {
// TODO(jieyu): Consider to include an error message in
// 'UpdatePublishResourcesStatus' and surface that to the caller.
- resourceProvider->publishes.at(uuid)->fail(
+ resourceProvider->publishes.at(uuid.get())->fail(
"Received " + stringify(update.status()) + " status");
}
- resourceProvider->publishes.erase(uuid);
+ resourceProvider->publishes.erase(uuid.get());
}