You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/12/09 02:54:48 UTC
[1/7] mesos git commit: Changed `framework_id` to optional for offer
oporations in RP API.
Repository: mesos
Updated Branches:
refs/heads/master 2fed8cc85 -> 3f9ab9744
Changed `framework_id` to optional for offer oporations in RP API.
Review: https://reviews.apache.org/r/64474/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3f9ab974
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3f9ab974
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3f9ab974
Branch: refs/heads/master
Commit: 3f9ab97442defd97c6da9eb116896d6bec6d01af
Parents: 54422d5
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:31:33 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800
----------------------------------------------------------------------
include/mesos/resource_provider/resource_provider.proto | 4 ++--
.../mesos/v1/resource_provider/resource_provider.proto | 4 ++--
src/resource_provider/storage/provider.cpp | 11 +++++++----
3 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3f9ab974/include/mesos/resource_provider/resource_provider.proto
----------------------------------------------------------------------
diff --git a/include/mesos/resource_provider/resource_provider.proto b/include/mesos/resource_provider/resource_provider.proto
index 360d862..7ec6936 100644
--- a/include/mesos/resource_provider/resource_provider.proto
+++ b/include/mesos/resource_provider/resource_provider.proto
@@ -48,7 +48,7 @@ message Event {
// Received when the master wants to send an operation to the
// resource provider.
message ApplyOfferOperation {
- required FrameworkID framework_id = 1;
+ optional FrameworkID framework_id = 1;
required Offer.Operation info = 2;
// This is the internal UUID for the operation, which is kept
@@ -126,7 +126,7 @@ message Call {
// Notify the master about the status of an offer operation.
message UpdateOfferOperationStatus {
- required FrameworkID framework_id = 1;
+ optional FrameworkID framework_id = 1;
required OfferOperationStatus status = 2;
optional OfferOperationStatus latest_status = 3;
http://git-wip-us.apache.org/repos/asf/mesos/blob/3f9ab974/include/mesos/v1/resource_provider/resource_provider.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/resource_provider/resource_provider.proto b/include/mesos/v1/resource_provider/resource_provider.proto
index 3e799f3..31e8954 100644
--- a/include/mesos/v1/resource_provider/resource_provider.proto
+++ b/include/mesos/v1/resource_provider/resource_provider.proto
@@ -48,7 +48,7 @@ message Event {
// Received when the master wants to send an operation to the
// resource provider.
message ApplyOfferOperation {
- required FrameworkID framework_id = 1;
+ optional FrameworkID framework_id = 1;
required Offer.Operation info = 2;
// This is the internal UUID for the operation, which is kept
@@ -126,7 +126,7 @@ message Call {
// Notify the master about the status of an operation.
message UpdateOfferOperationStatus {
- required FrameworkID framework_id = 1;
+ optional FrameworkID framework_id = 1;
required OfferOperationStatus status = 2;
optional OfferOperationStatus latest_status = 3;
http://git-wip-us.apache.org/repos/asf/mesos/blob/3f9ab974/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index 6013bfe..e806f44 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -2347,9 +2347,12 @@ Try<Nothing> StorageLocalResourceProviderProcess::applyResourceConversions(
Call::UpdateOfferOperationStatus* update =
call.mutable_update_offer_operation_status();
- update->mutable_framework_id()->CopyFrom(operation.framework_id());
update->set_operation_uuid(operation.operation_uuid());
+ if (operation.has_framework_id()) {
+ update->mutable_framework_id()->CopyFrom(operation.framework_id());
+ }
+
OfferOperationStatus* status = update->mutable_status();
status->set_status_uuid(UUID::random().toBytes());
@@ -2448,9 +2451,9 @@ void StorageLocalResourceProviderProcess::sendResourceProviderStateUpdate()
protobuf::createOfferOperationStatus(
OFFER_OPERATION_PENDING,
operation.info().has_id()
- ? Option<OfferOperationID>(operation.info().id())
- : None()),
- operation.framework_id(),
+ ? operation.info().id() : Option<OfferOperationID>::none()),
+ operation.has_framework_id()
+ ? operation.framework_id() : Option<FrameworkID>::none(),
slaveId,
uuid));
}
[4/7] mesos git commit: Removed a CHECK that should not be there in
SLRP.
Posted by ji...@apache.org.
Removed a CHECK that should not be there in SLRP.
Review: https://reviews.apache.org/r/64441/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6f33a1f2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6f33a1f2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6f33a1f2
Branch: refs/heads/master
Commit: 6f33a1f2d02a8cb450aea757833b58bdef6ae66d
Parents: 2fed8cc
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:12:13 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800
----------------------------------------------------------------------
src/resource_provider/storage/provider.cpp | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/6f33a1f2/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index 2193866..baa3a36 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -879,8 +879,6 @@ Future<Nothing> StorageLocalResourceProviderProcess::reconcile()
Resources stripped;
foreach (const Resource& resource, totalResources) {
- CHECK(resource.disk().source().has_id());
-
stripped += createRawDiskResource(
resource.provider_id(),
resource.scalar().value(),
[3/7] mesos git commit: Added missing filesystem isolation for SLRP
tests.
Posted by ji...@apache.org.
Added missing filesystem isolation for SLRP tests.
Review: https://reviews.apache.org/r/64437/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4c5c7ce0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4c5c7ce0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4c5c7ce0
Branch: refs/heads/master
Commit: 4c5c7ce03e854818814a7327f62231825337190e
Parents: 6f33a1f
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:12:17 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800
----------------------------------------------------------------------
src/Makefile.am | 6 +++++-
src/tests/storage_local_resource_provider_tests.cpp | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4c5c7ce0/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 1620b2a..47f4528 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2617,9 +2617,13 @@ if ENABLE_GRPC
mesos_tests_SOURCES += \
tests/csi_client_tests.cpp \
tests/mock_csi_plugin.cpp \
- tests/mock_csi_plugin.hpp \
+ tests/mock_csi_plugin.hpp
+
+if OS_LINUX
+mesos_tests_SOURCES += \
tests/storage_local_resource_provider_tests.cpp
endif
+endif
if ENABLE_SSL
mesos_tests_SOURCES += \
http://git-wip-us.apache.org/repos/asf/mesos/blob/4c5c7ce0/src/tests/storage_local_resource_provider_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/storage_local_resource_provider_tests.cpp b/src/tests/storage_local_resource_provider_tests.cpp
index 0f0c627..e5868bf 100644
--- a/src/tests/storage_local_resource_provider_tests.cpp
+++ b/src/tests/storage_local_resource_provider_tests.cpp
@@ -64,7 +64,7 @@ public:
"name": "test",
"default_reservations": [
{
- "type": "STATIC",
+ "type": "DYNAMIC",
"role": "storage"
}
],
@@ -120,6 +120,7 @@ TEST_F(StorageLocalResourceProviderTest, ROOT_CreateVolumeAndDestroyVolume)
Owned<MasterDetector> detector = master.get()->createDetector();
slave::Flags flags = CreateSlaveFlags();
+ flags.isolation = "filesystem/linux";
// Disable HTTP authentication to simplify resource provider interactions.
flags.authenticate_http_readwrite = false;
@@ -297,6 +298,7 @@ TEST_F(StorageLocalResourceProviderTest, ROOT_LaunchAndDestroyVolume)
Owned<MasterDetector> detector = master.get()->createDetector();
slave::Flags flags = CreateSlaveFlags();
+ flags.isolation = "filesystem/linux";
// Disable HTTP authentication to simplify resource provider interactions.
flags.authenticate_http_readwrite = false;
[2/7] mesos git commit: Added `MODIFY_RESOURCE_PROVIDER_CONFIG`
authorization.
Posted by ji...@apache.org.
Added `MODIFY_RESOURCE_PROVIDER_CONFIG` authorization.
The new authorization is for authorizing `ADD_RESOURCE_PROVIDER_CONFIG`,
`UPDATE_RESOURCE_PROVIDER_CONFIG`, and `REMOVE_RESOURCE_PROVIDER_CONFIG`
agent API calls.
Review: https://reviews.apache.org/r/64440/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8de5b27d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8de5b27d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8de5b27d
Branch: refs/heads/master
Commit: 8de5b27df8cfaac374b5d1602fe07fcb62c7ce95
Parents: 1088a54
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:12:26 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800
----------------------------------------------------------------------
include/mesos/authorizer/acls.proto | 15 +++++++++++++++
include/mesos/authorizer/authorizer.proto | 5 +++++
src/authorizer/local/authorizer.cpp | 15 +++++++++++++++
3 files changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8de5b27d/include/mesos/authorizer/acls.proto
----------------------------------------------------------------------
diff --git a/include/mesos/authorizer/acls.proto b/include/mesos/authorizer/acls.proto
index 6f36470..aca9aa8 100644
--- a/include/mesos/authorizer/acls.proto
+++ b/include/mesos/authorizer/acls.proto
@@ -467,6 +467,20 @@ message ACL {
// SOME particular operating system users (e.g., linux users).
required Entity users = 2;
}
+
+ // Which principals are authorized to add, update and remove resource
+ // provider config files.
+ message ModifyResourceProviderConfig {
+ // Subjects: HTTP Username.
+ required Entity principals = 1;
+
+ // Objects: Given implicitly.
+ // Use Entity type ANY or NONE to allow or deny access.
+ //
+ // TODO(chhsiao): Consider allowing granular permission to act upon
+ // SOME particular operating system users (e.g., linux users).
+ required Entity users = 2;
+ }
}
@@ -542,4 +556,5 @@ message ACLs {
repeated ACL.KillStandaloneContainer kill_standalone_container = 42;
repeated ACL.WaitStandaloneContainer wait_standalone_container = 43;
repeated ACL.RemoveStandaloneContainer remove_standalone_container = 44;
+ repeated ACL.ModifyResourceProviderConfig modify_resource_provider_config = 45;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/8de5b27d/include/mesos/authorizer/authorizer.proto
----------------------------------------------------------------------
diff --git a/include/mesos/authorizer/authorizer.proto b/include/mesos/authorizer/authorizer.proto
index d84295f..7db5fb3 100644
--- a/include/mesos/authorizer/authorizer.proto
+++ b/include/mesos/authorizer/authorizer.proto
@@ -241,6 +241,11 @@ enum Action {
//
// TODO(josephw): This should set the operating system user in the object.
REMOVE_STANDALONE_CONTAINER = 38;
+
+ // This action will not fill in any object fields. A principal is either
+ // allowed to add, update and remove resource provider config files or is
+ // unauthorized.
+ MODIFY_RESOURCE_PROVIDER_CONFIG = 39;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/8de5b27d/src/authorizer/local/authorizer.cpp
----------------------------------------------------------------------
diff --git a/src/authorizer/local/authorizer.cpp b/src/authorizer/local/authorizer.cpp
index e07f57e..809c2e4 100644
--- a/src/authorizer/local/authorizer.cpp
+++ b/src/authorizer/local/authorizer.cpp
@@ -410,6 +410,7 @@ public:
case authorization::START_MAINTENANCE:
case authorization::STOP_MAINTENANCE:
case authorization::UPDATE_MAINTENANCE_SCHEDULE:
+ case authorization::MODIFY_RESOURCE_PROVIDER_CONFIG:
aclObject.set_type(ACL::Entity::ANY);
break;
@@ -715,6 +716,7 @@ public:
case authorization::VIEW_TASK:
case authorization::WAIT_NESTED_CONTAINER:
case authorization::WAIT_STANDALONE_CONTAINER:
+ case authorization::MODIFY_RESOURCE_PROVIDER_CONFIG:
case authorization::UNKNOWN:
UNREACHABLE();
}
@@ -931,6 +933,7 @@ public:
case authorization::VIEW_TASK:
case authorization::WAIT_NESTED_CONTAINER:
case authorization::WAIT_STANDALONE_CONTAINER:
+ case authorization::MODIFY_RESOURCE_PROVIDER_CONFIG:
UNREACHABLE();
}
@@ -1141,6 +1144,7 @@ public:
case authorization::VIEW_TASK:
case authorization::WAIT_NESTED_CONTAINER:
case authorization::WAIT_STANDALONE_CONTAINER:
+ case authorization::MODIFY_RESOURCE_PROVIDER_CONFIG:
case authorization::UNKNOWN: {
Result<vector<GenericACL>> genericACLs =
createGenericACLs(action, acls);
@@ -1474,6 +1478,17 @@ private:
}
return acls_;
+ case authorization::MODIFY_RESOURCE_PROVIDER_CONFIG:
+ foreach (const ACL::ModifyResourceProviderConfig& acl,
+ acls.modify_resource_provider_config()) {
+ GenericACL acl_;
+ acl_.subjects = acl.principals();
+ acl_.objects = acl.users();
+
+ acls_.push_back(acl_);
+ }
+
+ return acls_;
case authorization::REGISTER_FRAMEWORK:
case authorization::CREATE_VOLUME:
case authorization::RESERVE_RESOURCES:
[6/7] mesos git commit: Implemented API for modifying resource
provider configs.
Posted by ji...@apache.org.
Implemented API for modifying resource provider configs.
This patch adds the implementation for `ADD_RESOURCE_PROVIDER_CONFIG`,
`UPDATE_RESOURCE_PROVIDER_CONFIG` and `REMOVE_RESOURCE_PROVIDER_CONFIG`,
which call the corresponding methods of `LocalResourceProviderDaemon`.
The implementation of the methods is in the following patch.
Review: https://reviews.apache.org/r/64438/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/54422d59
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/54422d59
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/54422d59
Branch: refs/heads/master
Commit: 54422d591a5d3a970b1a009d10b4c91ad015e431
Parents: 8de5b27
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:17:25 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800
----------------------------------------------------------------------
src/resource_provider/daemon.cpp | 21 ++++
src/resource_provider/daemon.hpp | 6 ++
src/slave/http.cpp | 177 ++++++++++++++++++++++++++++++++++
src/slave/http.hpp | 12 +++
4 files changed, 216 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/54422d59/src/resource_provider/daemon.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/daemon.cpp b/src/resource_provider/daemon.cpp
index 354054e..6159982 100644
--- a/src/resource_provider/daemon.cpp
+++ b/src/resource_provider/daemon.cpp
@@ -320,5 +320,26 @@ void LocalResourceProviderDaemon::start(const SlaveID& slaveId)
dispatch(process.get(), &LocalResourceProviderDaemonProcess::start, slaveId);
}
+
+Future<bool> LocalResourceProviderDaemon::add(const ResourceProviderInfo& info)
+{
+ return Failure("Unimplemented");
+}
+
+
+Future<bool> LocalResourceProviderDaemon::update(
+ const ResourceProviderInfo& info)
+{
+ return Failure("Unimplemented");
+}
+
+
+Future<bool> LocalResourceProviderDaemon::remove(
+ const string& type,
+ const string& name)
+{
+ return Failure("Unimplemented");
+}
+
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/54422d59/src/resource_provider/daemon.hpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/daemon.hpp b/src/resource_provider/daemon.hpp
index 14bc41f..7c513a2 100644
--- a/src/resource_provider/daemon.hpp
+++ b/src/resource_provider/daemon.hpp
@@ -59,6 +59,12 @@ public:
void start(const SlaveID& slaveId);
+ process::Future<bool> add(const ResourceProviderInfo& info);
+ process::Future<bool> update(const ResourceProviderInfo& info);
+ process::Future<bool> remove(
+ const std::string& type,
+ const std::string& name);
+
private:
LocalResourceProviderDaemon(
const process::http::URL& url,
http://git-wip-us.apache.org/repos/asf/mesos/blob/54422d59/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 3de874c..738786f 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -101,6 +101,7 @@ using process::TLDR;
using process::http::Accepted;
using process::http::BadRequest;
+using process::http::Conflict;
using process::http::Connection;
using process::http::Forbidden;
using process::http::NotFound;
@@ -614,6 +615,15 @@ Future<Response> Http::_api(
case mesos::agent::Call::REMOVE_CONTAINER:
return removeContainer(call, mediaTypes.accept, principal);
+
+ case mesos::agent::Call::ADD_RESOURCE_PROVIDER_CONFIG:
+ return addResourceProviderConfig(call, principal);
+
+ case mesos::agent::Call::UPDATE_RESOURCE_PROVIDER_CONFIG:
+ return updateResourceProviderConfig(call, principal);
+
+ case mesos::agent::Call::REMOVE_RESOURCE_PROVIDER_CONFIG:
+ return removeResourceProviderConfig(call, principal);
}
UNREACHABLE();
@@ -3113,6 +3123,173 @@ Future<Response> Http::attachContainerInput(
}
+Future<Response> Http::addResourceProviderConfig(
+ const mesos::agent::Call& call,
+ const Option<Principal>& principal) const
+{
+ CHECK_EQ(mesos::agent::Call::ADD_RESOURCE_PROVIDER_CONFIG, call.type());
+ CHECK(call.has_add_resource_provider_config());
+
+ Future<Owned<ObjectApprover>> approver;
+
+ if (slave->authorizer.isSome()) {
+ Option<authorization::Subject> subject = createSubject(principal);
+
+ approver = slave->authorizer.get()->getObjectApprover(
+ subject,
+ authorization::MODIFY_RESOURCE_PROVIDER_CONFIG);
+ } else {
+ approver = Owned<ObjectApprover>(new AcceptingObjectApprover());
+ }
+
+ return approver
+ .then(defer(slave->self(), [=](
+ const Owned<ObjectApprover>& approver) -> Future<Response> {
+ Try<bool> approved = approver->approved(ObjectApprover::Object());
+ if (approved.isError()) {
+ return InternalServerError("Authorization error: " + approved.error());
+ } else if (!approved.get()) {
+ return Forbidden();
+ }
+
+ const ResourceProviderInfo& info =
+ call.add_resource_provider_config().info();
+
+ LOG(INFO)
+ << "Processing ADD_RESOURCE_PROVIDER_CONFIG call with type '"
+ << info.type() << "' and name '" << info.name() << "'";
+
+ return slave->localResourceProviderDaemon->add(info)
+ .then([](bool added) -> Response {
+ if (!added) {
+ return Conflict();
+ }
+
+ return OK();
+ })
+ .repair([info](const Future<Response>& future) {
+ LOG(ERROR)
+ << "Failed to add resource provider config with type '"
+ << info.type() << "' and name '" << info.name() << "': "
+ << future.failure();
+
+ return InternalServerError(future.failure());
+ });
+ }));
+}
+
+
+Future<Response> Http::updateResourceProviderConfig(
+ const mesos::agent::Call& call,
+ const Option<Principal>& principal) const
+{
+ CHECK_EQ(mesos::agent::Call::UPDATE_RESOURCE_PROVIDER_CONFIG, call.type());
+ CHECK(call.has_update_resource_provider_config());
+
+ Future<Owned<ObjectApprover>> approver;
+
+ if (slave->authorizer.isSome()) {
+ Option<authorization::Subject> subject = createSubject(principal);
+
+ approver = slave->authorizer.get()->getObjectApprover(
+ subject,
+ authorization::MODIFY_RESOURCE_PROVIDER_CONFIG);
+ } else {
+ approver = Owned<ObjectApprover>(new AcceptingObjectApprover());
+ }
+
+ return approver
+ .then(defer(slave->self(), [=](
+ const Owned<ObjectApprover>& approver) -> Future<Response> {
+ Try<bool> approved = approver->approved(ObjectApprover::Object());
+ if (approved.isError()) {
+ return InternalServerError("Authorization error: " + approved.error());
+ } else if (!approved.get()) {
+ return Forbidden();
+ }
+
+ const ResourceProviderInfo& info =
+ call.update_resource_provider_config().info();
+
+ LOG(INFO)
+ << "Processing UPDATE_RESOURCE_PROVIDER_CONFIG call with type '"
+ << info.type() << "' and name '" << info.name() << "'";
+
+ return slave->localResourceProviderDaemon->update(info)
+ .then([](bool updated) -> Response {
+ if (!updated) {
+ return NotFound();
+ }
+
+ return OK();
+ })
+ .repair([info](const Future<Response>& future) {
+ LOG(ERROR)
+ << "Failed to update resource provider config with type '"
+ << info.type() << "' and name '" << info.name() << "': "
+ << future.failure();
+
+ return InternalServerError(future.failure());
+ });
+ }));
+}
+
+
+Future<Response> Http::removeResourceProviderConfig(
+ const mesos::agent::Call& call,
+ const Option<Principal>& principal) const
+{
+ CHECK_EQ(mesos::agent::Call::REMOVE_RESOURCE_PROVIDER_CONFIG, call.type());
+ CHECK(call.has_remove_resource_provider_config());
+
+ Future<Owned<ObjectApprover>> approver;
+
+ if (slave->authorizer.isSome()) {
+ Option<authorization::Subject> subject = createSubject(principal);
+
+ approver = slave->authorizer.get()->getObjectApprover(
+ subject,
+ authorization::MODIFY_RESOURCE_PROVIDER_CONFIG);
+ } else {
+ approver = Owned<ObjectApprover>(new AcceptingObjectApprover());
+ }
+
+ return approver
+ .then(defer(slave->self(), [=](
+ const Owned<ObjectApprover>& approver) -> Future<Response> {
+ Try<bool> approved = approver->approved(ObjectApprover::Object());
+ if (approved.isError()) {
+ return InternalServerError("Authorization error: " + approved.error());
+ } else if (!approved.get()) {
+ return Forbidden();
+ }
+
+ const string& type = call.remove_resource_provider_config().type();
+ const string& name = call.remove_resource_provider_config().name();
+
+ LOG(INFO)
+ << "Processing REMOVE_RESOURCE_PROVIDER_CONFIG call with type '" << type
+ << "' and name '" << name << "'";
+
+ return slave->localResourceProviderDaemon->remove(type, name)
+ .then([](bool removed) -> Response {
+ if (!removed) {
+ return NotFound();
+ }
+
+ return OK();
+ })
+ .repair([type, name](const Future<Response>& future) {
+ LOG(ERROR)
+ << "Failed to remove resource provider config with type '" << type
+ << "' and name '" << name << "': " << future.failure();
+
+ return InternalServerError(future.failure());
+ });
+ }));
+}
+
+
// Helper that reads data from `writer` and writes to `reader`.
// Returns a failed future if there are any errors reading or writing.
// The future is satisfied when we get a EOF.
http://git-wip-us.apache.org/repos/asf/mesos/blob/54422d59/src/slave/http.hpp
----------------------------------------------------------------------
diff --git a/src/slave/http.hpp b/src/slave/http.hpp
index 5eecb2a..9ca0617 100644
--- a/src/slave/http.hpp
+++ b/src/slave/http.hpp
@@ -306,6 +306,18 @@ private:
const mesos::agent::Call& call,
const RequestMediaTypes& mediaTypes) const;
+ process::Future<process::http::Response> addResourceProviderConfig(
+ const mesos::agent::Call& call,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> updateResourceProviderConfig(
+ const mesos::agent::Call& call,
+ const Option<process::http::authentication::Principal>& principal) const;
+
+ process::Future<process::http::Response> removeResourceProviderConfig(
+ const mesos::agent::Call& call,
+ const Option<process::http::authentication::Principal>& principal) const;
+
Slave* slave;
// Used to rate limit the statistics endpoint.
[5/7] mesos git commit: SLRP reconciliation only preserves missing
resources that are converted.
Posted by ji...@apache.org.
SLRP reconciliation only preserves missing resources that are converted.
When SLRP's checkpointed total resources is inconsistent with CSI
plugin's reported resources, we still want to keep the missing resources
that have been converted through an offer operation before, such that
we can have an consistent view with the frameworks consuming the
resource offers. It is safe to remove unconverted missing resources from
SLRP's checkpointed total.
Review: https://reviews.apache.org/r/64468/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ec4560e4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ec4560e4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ec4560e4
Branch: refs/heads/master
Commit: ec4560e412de6c2244f067520dd9f5dad3d19e49
Parents: 4c5c7ce
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:12:20 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800
----------------------------------------------------------------------
src/resource_provider/storage/provider.cpp | 55 +++++++++++++++++--------
1 file changed, 38 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ec4560e4/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index baa3a36..6013bfe 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -238,17 +238,20 @@ static inline http::Headers getAuthHeader(const Option<string>& authToken)
static inline Resource createRawDiskResource(
- const ResourceProviderID& resourceProviderId,
+ const ResourceProviderInfo& info,
double capacity,
const Option<string>& profile,
const Option<string>& id = None(),
const Option<Labels>& metadata = None())
{
+ CHECK(info.has_id());
+
Resource resource;
resource.set_name("disk");
resource.set_type(Value::SCALAR);
resource.mutable_scalar()->set_value(capacity);
- resource.mutable_provider_id()->CopyFrom(resourceProviderId),
+ resource.mutable_provider_id()->CopyFrom(info.id()),
+ resource.mutable_reservations()->CopyFrom(info.default_reservations());
resource.mutable_disk()->mutable_source()
->set_type(Resource::DiskInfo::Source::RAW);
@@ -870,17 +873,24 @@ void StorageLocalResourceProviderProcess::doReliableRegistration()
Future<Nothing> StorageLocalResourceProviderProcess::reconcile()
{
return importResources()
- .then(defer(self(), [=](Resources imported) {
- // NOTE: We do not support decreasing the total resources for now.
- // Any resource in the checkpointed state will be reported to the
- // resource provider manager, even if it is missing in the
- // imported resources from the plugin. Additional resources from
- // the plugin will be reported with the default reservation.
-
- Resources stripped;
+ .then(defer(self(), [=](Resources importedResources) {
+ // NODE: If a resource in the checkpointed total resources is
+ // missing in the imported resources, we will still keep it if it
+ // is converted by an offer operation before (i.e., has extra info
+ // other than the default reservations). The reason is that we
+ // want to maintain a consistent view with frameworks, and do not
+ // want to lose any data on persistent volumes due to some
+ // temporarily CSI plugin faults. Other missing resources that are
+ // "unconverted" by any framework will be removed from the total
+ // resources. Then, any new imported resource will be reported
+ // under the default reservations.
+
+ Resources result;
+ Resources unconvertedTotal;
+
foreach (const Resource& resource, totalResources) {
- stripped += createRawDiskResource(
- resource.provider_id(),
+ Resource unconverted = createRawDiskResource(
+ info,
resource.scalar().value(),
resource.disk().source().has_profile()
? resource.disk().source().profile() : Option<string>::none(),
@@ -888,10 +898,22 @@ Future<Nothing> StorageLocalResourceProviderProcess::reconcile()
? resource.disk().source().id() : Option<string>::none(),
resource.disk().source().has_metadata()
? resource.disk().source().metadata() : Option<Labels>::none());
+ if (importedResources.contains(unconverted)) {
+ // The checkponited resource appears in the imported resources.
+ result += resource;
+ unconvertedTotal += unconverted;
+ } else if (!totalResources.contains(unconverted)) {
+ // The checkpointed resource is missing but converted by a
+ // framework or the operator before, so we keep it.
+ result += resource;
+
+ LOG(WARNING)
+ << "Missing converted resource '" << resource
+ << "'. This might cause further offer operations to fail.";
+ }
}
- Resources result = totalResources;
- foreach (Resource resource, imported - stripped) {
+ foreach (Resource resource, importedResources - unconvertedTotal) {
if (resource.disk().source().has_id() &&
!volumes.contains(resource.disk().source().id())) {
csi::state::VolumeState volumeState;
@@ -911,7 +933,6 @@ Future<Nothing> StorageLocalResourceProviderProcess::reconcile()
checkpointVolumeState(resource.disk().source().id());
}
- resource.mutable_reservations()->CopyFrom(info.default_reservations());
result += resource;
LOG(INFO) << "Adding new resource '" << resource << "'";
@@ -1547,7 +1568,7 @@ Future<Resources> StorageLocalResourceProviderProcess::importResources()
foreach (const auto& entry, response.entries()) {
resources += createRawDiskResource(
- info.id(),
+ info,
entry.volume_info().capacity_bytes(),
volumesToProfiles.contains(entry.volume_info().id())
? volumesToProfiles.at(entry.volume_info().id())
@@ -1621,7 +1642,7 @@ Future<Resources> StorageLocalResourceProviderProcess::importResources()
}
return createRawDiskResource(
- info.id(),
+ info,
response.available_capacity(),
profile.empty() ? Option<string>::none() : profile);
}));
[7/7] mesos git commit: Added operator API to update and remove
resource provider configs.
Posted by ji...@apache.org.
Added operator API to update and remove resource provider configs.
This patch addes API calls to add, update and remove config files for
local resource providers, and asynchronously reload or terminates them.
Review: https://reviews.apache.org/r/63901/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1088a54e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1088a54e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1088a54e
Branch: refs/heads/master
Commit: 1088a54ebb76987bb5bc4da02e03df99cf1f09ad
Parents: ec4560e
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Dec 8 18:12:23 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 8 18:54:43 2017 -0800
----------------------------------------------------------------------
include/mesos/agent/agent.proto | 62 +++++++++++++++++++++++++++++++++
include/mesos/v1/agent/agent.proto | 62 +++++++++++++++++++++++++++++++++
src/slave/validation.cpp | 37 ++++++++++++++++++++
3 files changed, 161 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1088a54e/include/mesos/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/agent/agent.proto b/include/mesos/agent/agent.proto
index eb5f1b4..d464afe 100644
--- a/include/mesos/agent/agent.proto
+++ b/include/mesos/agent/agent.proto
@@ -89,6 +89,10 @@ message Call {
WAIT_CONTAINER = 23; // See 'WaitContainer' below.
KILL_CONTAINER = 24; // See 'KillContainer' below.
REMOVE_CONTAINER = 25; // See 'RemoveContainer' below.
+
+ ADD_RESOURCE_PROVIDER_CONFIG = 27; // See 'AddResourceProviderConfig' below. // NOLINT
+ UPDATE_RESOURCE_PROVIDER_CONFIG = 28; // See 'UpdateResourceProviderConfig' below. // NOLINT
+ REMOVE_RESOURCE_PROVIDER_CONFIG = 29; // See 'RemoveResourceProviderConfig' below. // NOLINT
}
// Provides a snapshot of the current metrics tracked by the agent.
@@ -282,6 +286,60 @@ message Call {
required ContainerID container_id = 1;
}
+ // Adds a new resource provider config file.
+ //
+ // The content of the 'info' field will be written into a new config
+ // file in the resource provider config directory. The 'info.id' field
+ // should not be set. A resource provider will be launched based on
+ // the new config asynchronously. Note that only config files that
+ // exist at agent startup will be checked against this call.
+ //
+ // Returns 200 OK if a new config file is created.
+ // Returns 400 Bad Request if 'info' is not well-formed.
+ // Returns 403 Forbidden if the call is not authorized.
+ // Returns 409 Conflict if another config file that describes a
+ // resource provider of the same type and name exists.
+ // Returns 500 Internal Server Error if anything goes wrong.
+ message AddResourceProviderConfig {
+ required ResourceProviderInfo info = 1;
+ }
+
+ // Updates an existing resource provider config file.
+ //
+ // The content of the 'info' field will be written into an existing
+ // config file that describes a resource provider of the specified
+ // type and name in the resource provider config directory. The
+ // 'info.id' field should not be set. The resource provider will be
+ // relaunched asynchoronously to reflect the changes in its config.
+ // Note that only config files that exist at agent startup can be
+ // updated though this call.
+ //
+ // Returns 200 OK if an existing config file is updated.
+ // Returns 400 Bad Request if 'info' is not well-formed.
+ // Returns 403 Forbidden if the call is not authorized.
+ // Returns 404 Not Found if no config file describes a resource
+ // provider of the same type and name exists.
+ // Returns 500 Internal Server Error if anything goes wrong.
+ message UpdateResourceProviderConfig {
+ required ResourceProviderInfo info = 1;
+ }
+
+ // Removes a config file from the resource provider config directory.
+ //
+ // The config file that describes the resource provider of the
+ // specified type and name will be removed. The resource provider will
+ // be terminated asynchronously. Note that only config files that
+ // exists at agent startup can be removed though this call.
+ //
+ // Returns 200 OK if the config file is removed.
+ // Returns 403 Forbidden if the call is not authorized.
+ // Returns 404 Not Found if the config file does not exist.
+ // Returns 500 Internal Server Error if anything goes wrong.
+ message RemoveResourceProviderConfig {
+ required string type = 1;
+ required string name = 2;
+ }
+
optional Type type = 1;
optional GetMetrics get_metrics = 2;
@@ -304,6 +362,10 @@ message Call {
optional WaitContainer wait_container = 14;
optional KillContainer kill_container = 15;
optional RemoveContainer remove_container = 16;
+
+ optional UpdateResourceProviderConfig add_resource_provider_config = 17;
+ optional UpdateResourceProviderConfig update_resource_provider_config = 18;
+ optional RemoveResourceProviderConfig remove_resource_provider_config = 19;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/1088a54e/include/mesos/v1/agent/agent.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/agent/agent.proto b/include/mesos/v1/agent/agent.proto
index 3aedfe8..91fe5e1 100644
--- a/include/mesos/v1/agent/agent.proto
+++ b/include/mesos/v1/agent/agent.proto
@@ -89,6 +89,10 @@ message Call {
WAIT_CONTAINER = 23; // See 'WaitContainer' below.
KILL_CONTAINER = 24; // See 'KillContainer' below.
REMOVE_CONTAINER = 25; // See 'RemoveContainer' below.
+
+ ADD_RESOURCE_PROVIDER_CONFIG = 27; // See 'AddResourceProviderConfig' below. // NOLINT
+ UPDATE_RESOURCE_PROVIDER_CONFIG = 28; // See 'UpdateResourceProviderConfig' below. // NOLINT
+ REMOVE_RESOURCE_PROVIDER_CONFIG = 29; // See 'RemoveResourceProviderConfig' below. // NOLINT
}
// Provides a snapshot of the current metrics tracked by the agent.
@@ -282,6 +286,60 @@ message Call {
required ContainerID container_id = 1;
}
+ // Adds a new resource provider config file.
+ //
+ // The content of the 'info' field will be written into a new config
+ // file in the resource provider config directory. The 'info.id' field
+ // should not be set. A resource provider will be launched based on
+ // the new config asynchronously. Note that only config files that
+ // exist at agent startup will be checked against this call.
+ //
+ // Returns 200 OK if a new config file is created.
+ // Returns 400 Bad Request if 'info' is not well-formed.
+ // Returns 403 Forbidden if the call is not authorized.
+ // Returns 409 Conflict if another config file that describes a
+ // resource provider of the same type and name exists.
+ // Returns 500 Internal Server Error if anything goes wrong.
+ message AddResourceProviderConfig {
+ required ResourceProviderInfo info = 1;
+ }
+
+ // Updates an existing resource provider config file.
+ //
+ // The content of the 'info' field will be written into an existing
+ // config file that describes a resource provider of the specified
+ // type and name in the resource provider config directory. The
+ // 'info.id' field should not be set. The resource provider will be
+ // relaunched asynchoronously to reflect the changes in its config.
+ // Note that only config files that exist at agent startup can be
+ // updated though this call.
+ //
+ // Returns 200 OK if an existing config file is updated.
+ // Returns 400 Bad Request if 'info' is not well-formed.
+ // Returns 403 Forbidden if the call is not authorized.
+ // Returns 404 Not Found if no config file describes a resource
+ // provider of the same type and name exists.
+ // Returns 500 Internal Server Error if anything goes wrong.
+ message UpdateResourceProviderConfig {
+ required ResourceProviderInfo info = 1;
+ }
+
+ // Removes a config file from the resource provider config directory.
+ //
+ // The config file that describes the resource provider of the
+ // specified type and name will be removed. The resource provider will
+ // be terminated asynchronously. Note that only config files that
+ // exists at agent startup can be removed though this call.
+ //
+ // Returns 200 OK if the config file is removed.
+ // Returns 403 Forbidden if the call is not authorized.
+ // Returns 404 Not Found if the config file does not exist.
+ // Returns 500 Internal Server Error if anything goes wrong.
+ message RemoveResourceProviderConfig {
+ required string type = 1;
+ required string name = 2;
+ }
+
optional Type type = 1;
optional GetMetrics get_metrics = 2;
@@ -304,6 +362,10 @@ message Call {
optional WaitContainer wait_container = 14;
optional KillContainer kill_container = 15;
optional RemoveContainer remove_container = 16;
+
+ optional UpdateResourceProviderConfig add_resource_provider_config = 17;
+ optional UpdateResourceProviderConfig update_resource_provider_config = 18;
+ optional RemoveResourceProviderConfig remove_resource_provider_config = 19;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/1088a54e/src/slave/validation.cpp
----------------------------------------------------------------------
diff --git a/src/slave/validation.cpp b/src/slave/validation.cpp
index 4a3a78a..17cabd1 100644
--- a/src/slave/validation.cpp
+++ b/src/slave/validation.cpp
@@ -488,6 +488,43 @@ Option<Error> validate(
return None();
}
+
+ case mesos::agent::Call::ADD_RESOURCE_PROVIDER_CONFIG: {
+ if (!call.has_add_resource_provider_config()) {
+ return Error(
+ "Expecting 'add_resource_provider_config' to be present");
+ }
+
+ if (call.add_resource_provider_config().info().has_id()) {
+ return Error(
+ "Expecting 'add_resource_provider_config.info.id' to be unset");
+ }
+
+ return None();
+ }
+
+ case mesos::agent::Call::UPDATE_RESOURCE_PROVIDER_CONFIG: {
+ if (!call.has_update_resource_provider_config()) {
+ return Error(
+ "Expecting 'update_resource_provider_config' to be present");
+ }
+
+ if (call.update_resource_provider_config().info().has_id()) {
+ return Error(
+ "Expecting 'update_resource_provider_config.info.id' to be unset");
+ }
+
+ return None();
+ }
+
+ case mesos::agent::Call::REMOVE_RESOURCE_PROVIDER_CONFIG: {
+ if (!call.has_remove_resource_provider_config()) {
+ return Error(
+ "Expecting 'remove_resource_provider_config' to be present");
+ }
+
+ return None();
+ }
}
UNREACHABLE();