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

feat(core): Support external configuration using Spring Cloud Config #1368

Merged

Conversation

scottfrederick
Copy link
Contributor

This PR adds the following features related to external configuration using Spring Cloud Config Server (see the Spinnaker Config Secrets design doc)

  • When the CLI detects that an account configuration file contains the prefix configserver:, it doesn't convert to an absolute local path
  • On validation, if a field that is required for live validation of a connection to an account contains a property placeholder (e.g. ${some.value}) that should be resolved via Config Server at service runtime, then live account validation is bypassed
  • On validation, if a field that is used as an account configuration file contains the prefix configserver:, then the contents of the file is not validated and live account validation is bypassed
  • On deployment, if the default kubernetes account used for deployment is configured with a kubeconfigFile containing the prefix configserver:, then the contents of the file will be retrieved from a config server backend and used for the deployment

This PR contains the following related refactorings:

  • Validator subclasses all use the SecretSessionManager that already existed in the base class instead of defining their own SecretSessionManager
  • All attempts to load account configuration files use ValidatingFileReader (via Validator#validatingFileDecrypt where possible)
  • ValidatingFileReader was moved to eliminate a package cycle

Copy link
Contributor

@ezimanyi ezimanyi left a comment

Choose a reason for hiding this comment

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

This looks good, with a few small comments.

CC @KathrynLewis who may want to take a look to make sure the changes involving SecretSessionManager look good.

@@ -55,7 +54,7 @@ public void validate(ConfigProblemSetBuilder p, AbstractCanaryAccount n) {
if (StringUtils.isNotEmpty(usernamePasswordFile)) {
String usernamePassword = validatingFileDecrypt(p, usernamePasswordFile);

if (Strings.isNullOrEmpty(usernamePassword)) {
if (usernamePassword != null && StringUtils.isEmpty(usernamePassword)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this && be an || to keep the current behavior (or was the change deliberate)?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is hard to guess intent, but here goes...
I'd guess that it should not be && because that leaves the 'else if' condition the chance of throwing an NPE when usernamePassword is null. Making it || is redundant since StringUtils.isEmpty checks for null and "". Given the context, the only thing that makes sense is for it to just be StringUtils.isEmpty(usernamePassword) unless the surrounding code is further modified. I'm going to make that change.

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

@@ -7,15 +7,12 @@
import com.netflix.spinnaker.halyard.config.model.v1.node.Validator;
import com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster;
import com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder;
import com.netflix.spinnaker.halyard.core.secrets.v1.SecretSessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang.StringUtils;
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally use org.apache.commons.lang3 (something must be pulling the lang version onto the classpath though).

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@claymccoy claymccoy left a comment

Choose a reason for hiding this comment

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

fixed a few minor issues based on PR feedback

@claymccoy claymccoy merged commit 7bfa5ce into spinnaker:master Jul 18, 2019
@scottfrederick scottfrederick deleted the external-config-no-validate branch July 30, 2019 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants