You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2020/07/27 17:19:26 UTC
[mesos] branch master updated (8e74d18 -> 3f95443)
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.
from 8e74d18 Fixed an example in the documentation.
new f78a6ea Deprecated tests plain text credential format.
new 3f95443 Remove credential text format support.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
CHANGELOG | 7 ++++++
src/credentials/credentials.hpp | 53 +++++++++++------------------------------
src/tests/credentials_tests.cpp | 47 ------------------------------------
src/tests/script.cpp | 13 +++++++---
4 files changed, 31 insertions(+), 89 deletions(-)
[mesos] 01/02: Deprecated tests plain text credential format.
Posted by bm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit f78a6eaca250a14ff660b09757e244ae25490811
Author: Dong Zhu <dz...@d2iq.com>
AuthorDate: Mon Jul 27 13:14:32 2020 -0400
Deprecated tests plain text credential format.
Review: https://reviews.apache.org/r/72620/
---
src/tests/credentials_tests.cpp | 47 -----------------------------------------
src/tests/script.cpp | 13 +++++++++---
2 files changed, 10 insertions(+), 50 deletions(-)
diff --git a/src/tests/credentials_tests.cpp b/src/tests/credentials_tests.cpp
index 8fa26df..02013da 100644
--- a/src/tests/credentials_tests.cpp
+++ b/src/tests/credentials_tests.cpp
@@ -70,53 +70,6 @@ TEST_F(CredentialsTest, AuthenticatedSlave)
ASSERT_NE("", slaveRegisteredMessage->slave_id().value());
}
-
-// Test verifing well executed credential authentication
-// using text formatted credentials so as to test
-// backwards compatibility.
-TEST_F(CredentialsTest, AuthenticatedSlaveText)
-{
- string path = path::join(os::getcwd(), "credentials");
-
- Try<int_fd> fd = os::open(
- path,
- O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
- S_IRUSR | S_IWUSR | S_IRGRP);
-
- ASSERT_SOME(fd);
-
- string credentials =
- DEFAULT_CREDENTIAL.principal() + " " + DEFAULT_CREDENTIAL.secret();
-
- ASSERT_SOME(os::write(fd.get(), credentials))
- << "Failed to write credentials to '" << path << "'";
-
- ASSERT_SOME(os::close(fd.get()));
-
- map<string, Option<string>> values{
- {"credentials", Some(uri::from_path(path))}};
-
- master::Flags masterFlags = CreateMasterFlags();
- masterFlags.load(values, true);
-
- Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
- ASSERT_SOME(master);
-
- Future<SlaveRegisteredMessage> slaveRegisteredMessage =
- FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
-
- slave::Flags slaveFlags = CreateSlaveFlags();
- slaveFlags.load(values, true);
-
- Owned<MasterDetector> detector = master.get()->createDetector();
- Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), slaveFlags);
- ASSERT_SOME(slave);
-
- AWAIT_READY(slaveRegisteredMessage);
- ASSERT_NE("", slaveRegisteredMessage->slave_id().value());
-}
-
-
// Using JSON base file for authentication without
// protobuf tools assistance.
TEST_F(CredentialsTest, AuthenticatedSlaveJSON)
diff --git a/src/tests/script.cpp b/src/tests/script.cpp
index 038519c..6aadb78 100644
--- a/src/tests/script.cpp
+++ b/src/tests/script.cpp
@@ -123,13 +123,20 @@ void execute(const string& script)
os::setenv("MESOS_REGISTRY", "replicated_log");
// Create test credentials.
- const string& credentials =
- DEFAULT_CREDENTIAL.principal() + " " + DEFAULT_CREDENTIAL.secret();
+ JSON::Object credential;
+ credential.values["principal"] = DEFAULT_CREDENTIAL.principal();
+ credential.values["secret"] = DEFAULT_CREDENTIAL.secret();
+
+ JSON::Array array;
+ array.values.push_back(credential);
+
+ JSON::Object credentials;
+ credentials.values["credentials"] = array;
const string& credentialsPath =
path::join(directory.get(), "credentials");
- CHECK_SOME(os::write(credentialsPath, credentials))
+ CHECK_SOME(os::write(credentialsPath, stringify(credentials)))
<< "Failed to write credentials to '" << credentialsPath << "'";
os::setenv("MESOS_CREDENTIALS", uri::from_path(credentialsPath));
[mesos] 02/02: Remove credential text format support.
Posted by bm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 3f9544390c89736b9cb5e177498cd67ff021bd93
Author: Dong Zhu <dz...@d2iq.com>
AuthorDate: Mon Jul 27 13:14:45 2020 -0400
Remove credential text format support.
Since text format for credential is no longer supported, remove it.
Review: https://reviews.apache.org/r/72600/
---
CHANGELOG | 7 ++++++
src/credentials/credentials.hpp | 53 +++++++++++------------------------------
2 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6e94a3f..ce7f697 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+Release Notes - Mesos - Version 1.11.0 (WIP)
+-------------------------------------------
+
+Additional API Changes:
+
+ * **Breaking change** Deprecated authentication credential text format support.
+
Release Notes - Mesos - Version 1.10.1 (WIP)
-------------------------------------------
* This is a bug fix release.
diff --git a/src/credentials/credentials.hpp b/src/credentials/credentials.hpp
index 6e9f4aa..c2cef69 100644
--- a/src/credentials/credentials.hpp
+++ b/src/credentials/credentials.hpp
@@ -54,30 +54,17 @@ inline Result<Credentials> read(const Path& path)
<< " credentials file is NOT accessible by others";
}
- // TODO(nfnt): Remove text format support at the end of the deprecation cycle
- // which started with version 1.0.
Try<JSON::Object> json = JSON::parse<JSON::Object>(read.get());
- if (!json.isError()) {
- Try<Credentials> credentials = ::protobuf::parse<Credentials>(json.get());
- if (!credentials.isError()) {
- return credentials.get();
- }
+ if (json.isError()) {
+ return Error("Invalid json format: " + json.error());
}
- Credentials credentials;
- foreach (const std::string& line, strings::tokenize(read.get(), "\n")) {
- const std::vector<std::string>& pairs = strings::tokenize(line, " ");
- if (pairs.size() != 2) {
- return Error("Invalid credential format at line " +
- stringify(credentials.credentials().size() + 1));
- }
-
- // Add the credential.
- Credential* credential = credentials.add_credentials();
- credential->set_principal(pairs[0]);
- credential->set_secret(pairs[1]);
+ Try<Credentials> credentials = ::protobuf::parse<Credentials>(json.get());
+ if (credentials.isError()) {
+ return Error("Failed to parse credentials: "
+ + credentials.error());
}
- return credentials;
+ return credentials.get();
}
@@ -104,28 +91,16 @@ inline Result<Credential> readCredential(const Path& path)
}
Try<JSON::Object> json = JSON::parse<JSON::Object>(read.get());
- if (!json.isError()) {
- Try<Credential> credential = ::protobuf::parse<Credential>(json.get());
- if (!credential.isError()) {
- return credential.get();
- }
+ if (json.isError()) {
+ return Error("Invalid json format: " + json.error());
}
- // TODO(nfnt): Remove text format support at the end of the deprecation cycle
- // which started with version 1.0.
- Credential credential;
- const std::vector<std::string>& line = strings::tokenize(read.get(), "\n");
- if (line.size() != 1) {
- return Error("Expecting only one credential");
+ Try<Credential> credential = ::protobuf::parse<Credential>(json.get());
+ if (credential.isError()) {
+ return Error("Failed to parse credential: "
+ + credential.error());
}
- const std::vector<std::string>& pairs = strings::tokenize(line[0], " ");
- if (pairs.size() != 2) {
- return Error("Invalid credential format");
- }
- // Add the credential.
- credential.set_principal(pairs[0]);
- credential.set_secret(pairs[1]);
- return credential;
+ return credential.get();
}
} // namespace credentials {