Skip to content

Conversation

@garry-t
Copy link

@garry-t garry-t commented Jun 20, 2025

For #1799

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @garry-t, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the flexibility of the infrastructure setup by allowing the Longhorn volume mount path to be dynamically configured rather than being a fixed value. This change makes the deployment more adaptable to different environment requirements.

Highlights

  • Longhorn Mount Path Parameterization: The hardcoded /var/longhorn mount path for Longhorn volumes has been replaced with a configurable variable, var.longhorn_mount_path, in the remote execution commands for agent configuration.
  • New Configuration Variable: A new optional string variable, longhorn_mount_path, has been introduced to the agent_nodepools definition in variables.tf, providing a default value of /var/longhorn for backward compatibility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to parameterize the mount path for Longhorn volumes, which is a valuable enhancement for flexibility. The changes in variables.tf correctly introduce the new longhorn_mount_path parameter as an optional attribute on agent nodepools, ensuring backward compatibility.

My review focuses on the agents.tf file, where I've identified a critical issue with how the new variable is referenced, which would cause the Terraform execution to fail. I've also provided suggestions to make the shell commands more robust and idempotent. Please note that for this feature to work as intended, you'll also need to update locals.tf to propagate the new variable, a change which is currently missing from this PR.

Overall, this is a good change that will be ready to merge after addressing the feedback.

@garry-t
Copy link
Author

garry-t commented Jun 20, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request parameterizes the Longhorn volume mount path. A syntax issue was found in locals.tf that needs to be fixed. Additionally, suggestions were provided for agents.tf to improve the idempotency of the shell commands.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a feature to parameterize the Longhorn volume mount path. The changes involve modifications to agents.tf, locals.tf, and variables.tf to allow users to specify a custom mount path for Longhorn volumes. It's recommended to address the quoting of variables in shell commands to prevent potential command injection vulnerabilities.

@garry-t
Copy link
Author

garry-t commented Jun 20, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the longhorn_mount_path variable, allowing parameterization of the Longhorn volume mount path. There's a critical issue in the validation logic and a high-severity issue in the script updating /etc/fstab. Suggestions have been provided to address these.

@garry-t
Copy link
Author

garry-t commented Jun 21, 2025

I found simpler option

@garry-t garry-t closed this Jun 21, 2025
@garry-t garry-t reopened this Jul 27, 2025
@garry-t
Copy link
Author

garry-t commented Jul 31, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces parameterization of the Longhorn volume mount path. The implementation propagates the new longhorn_mount_path variable through the module's inputs, locals, and resources. I've provided feedback on the validation logic for the mount path and the idempotency of the command that updates /etc/fstab.

@mysticaltech
Copy link
Collaborator

@garry-t why is this important to you? MicroOS is quite specific in the way that its file system works, allowing any other directory out of var would not work and would delete the data on reboot. This is the only valid location.

If you want to use volumes (shouldn't matter which kind, nvme, ...etc), you already can. Hence I'm closing this PR for now, please shout back at me if you really need it and explain why in details.

@garry-t
Copy link
Author

garry-t commented Aug 4, 2025

@mysticaltech Never used MicroOS, but problem when we have quite big machine as storage, usually it comes with 100GB+ nvme disk which we can reuse as well in Longhorn. (Current implementation we can't , because stick to one path)
I want to have ability use longhorn on native disk and on attached ssd, for this I create second storage class. And now we don't waste disk space and can schedule data on nvme or ssd. I set path /var/lib/longhorn this path within /var folder.
Another use case Bare metal with can have two type of disk additionally configured during server order, nvme and ssd. I want to have flexibility and for specific workloads choose right one.
Don't know thought it quite useful PR, since it also save mone in some cases.

@mysticaltech mysticaltech reopened this Aug 4, 2025
@mysticaltech
Copy link
Collaborator

mysticaltech commented Aug 4, 2025

@garry-t Ok, thanks for the detailed explanation. Then let's just add proper explanations in kube.tf.example along with the variable to let people know that they should stick to the /var directory. I've now reopened the PR, please feel free complete it whenever you can and I will merge if the review passes without issues. Thanks again for this!

@garry-t
Copy link
Author

garry-t commented Aug 4, 2025

@mysticaltech understood will add instructions soon.
10x

@garry-t
Copy link
Author

garry-t commented Aug 7, 2025

@mysticaltech tell me if this doc format is ok. 10x

@mysticaltech
Copy link
Collaborator

@garry-t It's good, but please rebase with the current master and make sure the / gemini review passes please.

added new variable
mount path now parameterised
added new variable
updated with suggested changes
fix syntax
commit suggestions
added variable validation
removed / from provisioner
fixed validation rule
updated validation rule for longhorn
@garry-t
Copy link
Author

garry-t commented Oct 27, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature by allowing the Longhorn volume mount path to be parameterized. The changes are well-structured, including updates to Terraform logic, variables, example files, and new documentation.

My review has identified a critical issue in agents.tf where the idempotency check for /etc/fstab is broken, which would cause duplicate entries on every apply. I've also suggested a minor improvement to error visibility in the same file. Additionally, I've proposed a clarification in the new documentation to help users make more informed decisions about replica counts for their storage classes.

Overall, this is a great addition. Once the critical issue is addressed, this PR will be in excellent shape.

@garry-t
Copy link
Author

garry-t commented Oct 28, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature by allowing the Longhorn volume mount path to be parameterized via the longhorn_mount_path variable. The changes are well-implemented across the Terraform configuration, including updates to variables, local values, and the agent provisioning logic. The addition of input validation and documentation is also a great touch. My review focuses on improving the robustness of the shell command used for idempotency when updating /etc/fstab to prevent potential issues with special characters in file paths.

@garry-t
Copy link
Author

garry-t commented Oct 28, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature to parameterize the Longhorn volume mount path. The implementation is robust, including idempotent shell commands in the remote-exec provisioner and comprehensive validation for the new path variable. The addition of documentation is also a great touch, making the feature easy to adopt. Overall, this is a high-quality contribution. I have one suggestion to improve the documentation example.

just to make gemini calm

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@garry-t
Copy link
Author

garry-t commented Oct 28, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature by allowing the Longhorn volume mount path to be parameterized. The changes to the provisioning scripts in agents.tf make them more robust and idempotent, which is a great improvement. The new documentation file is also very clear and helpful for users who want to leverage this new functionality.

However, I've identified a critical security vulnerability in the validation logic for the new longhorn_mount_path variable, which could allow for path traversal. I've also suggested an improvement to the example code in the new documentation to follow a more declarative Terraform pattern. Please see the detailed comments for specifics.

@garry-t
Copy link
Author

garry-t commented Oct 28, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature by allowing the Longhorn volume mount path to be parameterized. The implementation is robust, with good use of idempotent shell commands in the remote-exec provisioner and strong validation for the new path variable. The addition of documentation is also a great step. My main feedback is on the new documentation file, where an example could be clarified to avoid misleading users about the complexity of automating Longhorn node patching. Overall, this is a well-executed enhancement.

@garry-t
Copy link
Author

garry-t commented Oct 28, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature by allowing the Longhorn volume mount path to be parameterized. The implementation is robust, with solid improvements to the remote-exec scripts in agents.tf for idempotency and error handling, and a thorough validation rule for the new longhorn_mount_path variable. The addition of documentation is also a great touch.

I have one suggestion to improve the example in the new documentation to prevent potential user errors when dealing with more complex configurations. Overall, this is a well-executed change.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@garry-t
Copy link
Author

garry-t commented Oct 28, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature by allowing the Longhorn volume mount path to be parameterized. The changes are well-implemented across the Terraform configuration, including updates to variables, local values, and the agent provisioning script. The remote-exec script in agents.tf has been significantly improved for better idempotency and robustness by using mkdir -p, mountpoint, and an awk check for /etc/fstab entries. The addition of a new documentation file and validation for the mount path is also a great enhancement.

I have a couple of suggestions to further improve the code: one to make the new documentation example less error-prone for users, and another to refine the validation logic in variables.tf for better clarity and correctness.

@garry-t
Copy link
Author

garry-t commented Oct 28, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to parameterize the mount path for Longhorn volumes, which is a great enhancement for flexibility. The implementation is solid, with robust shell commands for idempotency and new validation for the mount path. I've added a couple of suggestions: one to improve the new documentation by using a local variable in the example to prevent user error, and another to tighten the validation regex to prevent potentially dangerous configurations like mounting over the /var directory.

@garry-t
Copy link
Author

garry-t commented Oct 29, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to parameterize the Longhorn volume mount path, a valuable feature for custom storage configurations. The implementation is excellent, not only adding the new parameter but also significantly improving the robustness and idempotency of the volume configuration script in agents.tf. The addition of strong input validation in variables.tf is a great measure to prevent configuration errors. Furthermore, the new documentation in docs/customize-mount-path-longhorn.md is clear, comprehensive, and will be very helpful for users. The changes are well-thought-out and of high quality. I have no specific issues to raise.

@garry-t
Copy link
Author

garry-t commented Oct 29, 2025

@mysticaltech gemini satisfied :)

@mysticaltech
Copy link
Collaborator

Thanks @garry-t ! I need to test it, will do ASAP

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.

2 participants