Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Rework usage of Krustlet config to allow passing parameters on the command line #36

Merged
merged 8 commits into from
Jan 22, 2021

Conversation

soenkeliebau
Copy link
Member

Fixes #34

Pulled out documentation strings into separate files, which allows editing them as proper adoc files with preview, instead of string literals in Rust code. This makes writing documentation _a lot_ easier.
@soenkeliebau soenkeliebau marked this pull request as draft January 19, 2021 13:07
@soenkeliebau
Copy link
Member Author

Please feel free to take a look, I expect that I'll find some minor things to fix in this still, but the overall structure and code should be done.

@soenkeliebau soenkeliebau marked this pull request as ready for review January 20, 2021 13:45
Added parsing of bootstrapfile from command line.
Copy link
Member

@lfrancke lfrancke left a comment

Choose a reason for hiding this comment

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

I'm not super crazy about the adoc files in the source tree but I don't have a better idea and it kinda makes sense.

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/agentconfig.rs Outdated Show resolved Hide resolved
default: Some("/etc/stackable/agent/plugins"),
required: false,
takes_argument: true,
help: "The directory to observe for new sockets to appear which can be used to communicate with CSI plugins.",
Copy link
Member

Choose a reason for hiding this comment

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

Uhm? Do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

We are not using this, no. It was more a matter of making it configurable "just in case" - I am happy to just default this to something relative to the data dir so that if for some reason it gets created it is out of the way.

Copy link
Member

Choose a reason for hiding this comment

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

Just in case.... CSI plugins? I believe it confuses more than it helps to be honest.

src/agentconfig.rs Show resolved Hide resolved
src/agentconfig.rs Outdated Show resolved Hide resolved
@@ -228,6 +289,51 @@ impl Configurable for AgentConfig {
};
info!("Selected {} as local address to listen on.", final_ip);

// Parse data directory from values
let final_data_dir = if let Ok(data_dir) =
Copy link
Member

Choose a reason for hiding this comment

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

If we add one more it makes sense to move it into a function. This is a 1:1 copy of the stuff below

Copy link
Member Author

Choose a reason for hiding this comment

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

I considered it, but opted for "doesn't have to look nice at this stage" - which incidentally you keep telling me ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

I pulled the code into a fn and refactored it a bit.

})
} else {
// Should not happen due to default value being assigned to the parameter
PathBuf::from("")
Copy link
Member

Choose a reason for hiding this comment

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

If this should not happen wouldn't it make more sense to cause a panic if it does? Especially as this is on startup it'd catch programming errors.

So basically change the if let to something like ...unwrap()
I haven't fully thought it through but should work, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've extracted this code into a function and refactored it a bit.

u16::from_str(&server_port)
.unwrap_or_else(|_| panic!("Error parsing webserver port from [{}], aborting."))
} else {
// This should not be necessary, as the default should be provided by clap,
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. If it shouldn't happen let's panic?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've refactored the code and moved this bit out into a fn.

@lfrancke
Copy link
Member

This should also update the readme once #35 is merged

@lfrancke
Copy link
Member

And there are a few clippy warnings. I haven't mentioned them separately.

@soenkeliebau
Copy link
Member Author

I'm not super crazy about the adoc files in the source tree but I don't have a better idea and it kinda makes sense.

Me neither, I'm open to suggestions, but this was the best compromise I could come up with.

@soenkeliebau
Copy link
Member Author

And there are a few clippy warnings. I haven't mentioned them separately.

I've fixed the ones that are not about naming - those have been around for a while, I'll fix those in a separate PR.

Copy link
Member

@lfrancke lfrancke left a comment

Choose a reason for hiding this comment

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

Only minor stuff left

src/main.rs Outdated
addr: agent_config.server_ip_address.clone(),
port: agent_config.server_port,
cert_file: agent_config.server_cert_file.unwrap_or(Default::default()),
private_key_file: agent_config.server_key_file.unwrap_or(Default::default()),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private_key_file: agent_config.server_key_file.unwrap_or(Default::default()),
private_key_file: agent_config.server_key_file.unwrap_or_default(),

src/main.rs Outdated
let server_config = ServerConfig {
addr: agent_config.server_ip_address.clone(),
port: agent_config.server_port,
cert_file: agent_config.server_cert_file.unwrap_or(Default::default()),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cert_file: agent_config.server_cert_file.unwrap_or(Default::default()),
cert_file: agent_config.server_cert_file.unwrap_or_default(),

@soenkeliebau soenkeliebau merged commit b2394a7 into stackabletech:main Jan 22, 2021
@soenkeliebau soenkeliebau deleted the config_rework branch January 22, 2021 13:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor usage of Krustlet config to allow using command line parameters to configure agent
2 participants