-
Notifications
You must be signed in to change notification settings - Fork 15
bug: cloud-init disable fix #273
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Purpose: Fix bug where cloud-init networking disable file creation fails if the target directory is absent by adding a directory existence check and adjusting path handling.
- Add explicit CLOUD_INIT_CONFIG_DIR constant and split full path into dir + filename.
- Check for existence of the config directory before attempting to write, and build the file path with Path::join.
- Update logging around skip and disable actions.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| fn disable_cloud_init_networking() -> Result<(), TridentError> { | ||
| fs::write(CLOUD_INIT_DISABLE_FILE, CLOUD_INIT_DISABLE_CONTENT) | ||
| let cloud_init_disable_path = Path::new(CLOUD_INIT_CONFIG_DIR).join(CLOUD_INIT_DISABLE_FILE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: You could move this further down post the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
| fn disable_cloud_init_networking() -> Result<(), TridentError> { | ||
| fs::write(CLOUD_INIT_DISABLE_FILE, CLOUD_INIT_DISABLE_CONTENT) | ||
| let cloud_init_disable_path = Path::new(CLOUD_INIT_CONFIG_DIR).join(CLOUD_INIT_DISABLE_FILE); | ||
| if !Path::new(CLOUD_INIT_CONFIG_DIR).exists() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is sufficient to address this bug, but should we have a better handling re package presence detection in general? We could use the cosi manifest now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supposedly yes, but i think i want to add some cleaner interfaces for that before we cross that bridge
| } | ||
| } | ||
|
|
||
| fn disable_cloud_init_networking() -> Result<(), TridentError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add a few UTs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if !config_dir.as_ref().exists() { | ||
| debug!( | ||
| "Cloud-init config dir {} does not exist, skipping disabling cloud-init networking", | ||
| config_dir.as_ref().display() | ||
| ); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| debug!("Disabling cloud-init networking"); | ||
| let cloud_init_disable_path = config_dir.as_ref().join(CLOUD_INIT_DISABLE_FILE); |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] config_dir.as_ref() is called multiple times; storing it in a local variable (e.g., let config_dir = config_dir.as_ref();) would improve readability and avoid repetition.
| if !config_dir.as_ref().exists() { | |
| debug!( | |
| "Cloud-init config dir {} does not exist, skipping disabling cloud-init networking", | |
| config_dir.as_ref().display() | |
| ); | |
| return Ok(()); | |
| } | |
| debug!("Disabling cloud-init networking"); | |
| let cloud_init_disable_path = config_dir.as_ref().join(CLOUD_INIT_DISABLE_FILE); | |
| let config_dir = config_dir.as_ref(); | |
| if !config_dir.exists() { | |
| debug!( | |
| "Cloud-init config dir {} does not exist, skipping disabling cloud-init networking", | |
| config_dir.display() | |
| ); | |
| return Ok(()); | |
| } | |
| debug!("Disabling cloud-init networking"); | |
| let cloud_init_disable_path = config_dir.join(CLOUD_INIT_DISABLE_FILE); |
🔍 Description
Fix #272
Check if directory exists before attempting to create file.