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

Halyard separation #789

Merged
merged 10 commits into from
Jan 18, 2018
Merged

Halyard separation #789

merged 10 commits into from
Jan 18, 2018

Conversation

brandonnelson3
Copy link
Contributor

Halyard can now be configured to deploy referenced files by value instead of by filesystem reference.

Copy link
Member

@lwander lwander left a comment

Choose a reason for hiding this comment

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

Nicely done, a few nitpicks and one config wiring change

return FileUtil.readAsString(new File(value));
} catch (IOException e) {
throw new HalException(Problem.Severity.FATAL,
"Config references file that is unreadable: " + value);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should read "config", instead "Was passed parameter " + value + " to unreadable file: " + e.getMessage()

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.

@@ -140,6 +155,8 @@
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
Path stagingPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
Copy link
Member

Choose a reason for hiding this comment

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

Should this be named "configPath"? (Here and in a few other spots).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If by a few, you mean 30. Yes ;)

@Data
public class GlobalApplicationOptions {

private static final String CONFIG_PATH = "/tmp/hal.config";
Copy link
Member

Choose a reason for hiding this comment

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

I think tmp is fair game to be deleted

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to keep this close to other halyard config, so something like /opt/halyard/config or ~/.hal

f.setAccessible(true);
return (String) f.get(n);
} catch (IllegalAccessException e) {
throw new HalException(FATAL, "Failed to clean staging directory: " + e.getMessage(), e);
Copy link
Member

Choose a reason for hiding this comment

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

This feels more like a runtime error than a halexception - by convention the latter is reserved for errors the user can do something about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SGTM.

* Deletes all files in the staging directory that are not referenced in the hal config.
*/
public void cleanLocalFiles(Path stagingDirectoryPath) {
if (GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) {
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be configured another way - those config options are used by the CLI - this should use spring.

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.

Copy link
Member

@ttomsu ttomsu left a comment

Choose a reason for hiding this comment

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

Side observation: It'd be great if we could check in code style formatter config for Intellij that could be shared across all components. That would have reduced some of the formatting changes in this PR.

* Deletes all files in the staging directory that are not referenced in the hal config.
*/
public void cleanLocalFiles(Path stagingDirectoryPath) {
if (globalApplicationOptions.isUseRemoteDaemon()) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggest returning early:

if (!globalApplicationOptions.isRemoteDaemon()) {
  return
}

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.

@@ -169,6 +183,30 @@ public void parentify() {
return res;
}

public void stageLocalFiles(Path outputPath) {
if (GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) {
Copy link
Member

Choose a reason for hiding this comment

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

Return early

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.

@PropertySource("file:" + GlobalApplicationOptions.CONFIG_PATH)
public class GlobalApplicationOptions {

static final String CONFIG_PATH = "/opt/spinnaker/hal.properties";
Copy link
Member

Choose a reason for hiding this comment

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

Is this config shared between the client and the server? Based on the javadoc string, it appears so.

All of the other components follow a convention for server configuration options that hooks into Spring's parsing and options logic (here's a guide on how that works: https://www.travistomsu.com/2016/12/19/configuring-spinnaker/)

If possible, I'd suggest using the yaml format instead of .properties files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason this is done this way is because the CLI doesn't use spring and i'd prefer to share the implementation between the two.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also its still Autowire-ed in the halyard-web backend.

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