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

sds: clusters and listeners read static secrets from Bootstrap.static_resources #3378

Closed

Conversation

mangchiandjjoe
Copy link
Contributor

@mangchiandjjoe mangchiandjjoe commented May 14, 2018

Description:
Clusters and listeners read secrets from the static resources in the bootstrap configuration.
Reading secrets from the Secret Discovery Service will follow.

Risk Level: Low

Fixes #1194

Signed-off-by: Jae Kim jaebong.kim@gmail.com

@mangchiandjjoe mangchiandjjoe changed the title sds: clusters and listeners read static secrets from Bootstrap.static_resources [WIP] sds: clusters and listeners read static secrets from Bootstrap.static_resources May 14, 2018
@mattklein123
Copy link
Member

Excited to see this being worked on. @lizan @PiotrSikora can you take a first pass?

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick pass. (I already went over once before this PR)

unittests for SecretManagerImpl?

@@ -4,7 +4,7 @@ set -e

# bazel uses jgit internally and the default circle-ci .gitconfig says to
# convert https://github.com to ssh://git@github.com, which jgit does not support.
mv ~/.gitconfig ~/.gitconfig_save
# mv ~/.gitconfig ~/.gitconfig_save
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

virtual const std::string& getPrivateKey() PURE;
};

typedef std::shared_ptr<Secret> SecretPtr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: SecretSharedPtr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced

@@ -1678,4 +1678,19 @@ const std::string Json::Schema::SDS_SCHEMA(R"EOF(
"required" : ["hosts"]
}
)EOF");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to v1 so I don't think you need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

certificate_chain_(readDataSource(config.tls_certificate().certificate_chain(), true)),
private_key_(readDataSource(config.tls_certificate().private_key(), true)) {}

const std::string SecretImpl::readDataSource(const envoy::api::v2::core::DataSource& source,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use Config::DataSource::read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

public:
SecretImpl(const envoy::api::v2::auth::Secret& config);

virtual ~SecretImpl() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

private:
const std::string readDataSource(const envoy::api::v2::core::DataSource& source,
bool allow_empty);
const std::string getDataSourcePath(const envoy::api::v2::core::DataSource& source);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

/**
* @return a name of the SDS secret
*/
virtual const std::string& getName() PURE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make these getters as const method?

Also I would prefer not having get prefix for those properties, so just name, certificateChain...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not const method. (i.e. virtual const std::string& name() const PURE;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

SecretSharedPtr SecretManagerImpl::getStaticSecret(const std::string& name) {
return (static_secrets_.find(name) != static_secrets_.end()) ? static_secrets_[name] : nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're looking up twice, prefer:

auto it = static_secrets_.find(name);
return it != static_secrets_.end() ? it->second : nullptr;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,30 @@
#pragma once

#include <shared_mutex>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. It will be added later for dynamic secret support.


typedef std::shared_ptr<Secret> SecretSharedPtr;

typedef std::unordered_map<std::string, SecretSharedPtr> SecretSharedPtrMap;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map and vector are not used in interfaces, so move them to impl.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved,

@mangchiandjjoe mangchiandjjoe changed the title [WIP] sds: clusters and listeners read static secrets from Bootstrap.static_resources sds: clusters and listeners read static secrets from Bootstrap.static_resources May 15, 2018
@lizan
Copy link
Member

lizan commented May 17, 2018

@mangchiandjjoe Can you try merge master?

@lizan
Copy link
Member

lizan commented May 22, 2018

FIrst pass done, @mattklein123 can you take a look?

@mattklein123
Copy link
Member

@mangchiandjjoe since we are going to have to fix DCO eventually, can you potentially just do it now before we start more reviews? Feel free to squash/rebase/force push.

Signed-off-by: jae Kim <jaebong.kim@gmail.com>
@mattklein123
Copy link
Member

Presumably #3465 replaces this so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants