feat(agentstack-cli): switch to microshift#2098
Conversation
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Summary of ChangesHello @JanPokorny, 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 significantly refactors the local Agent Stack platform management within the CLI. It transitions from a driver-based architecture with separate files to a unified Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the platform management logic, replacing the driver-based architecture with a unified module to introduce MicroShift support, consolidating VM and Kubernetes management. A critical security concern has been identified: several hardcoded secrets and default credentials are present in the platform deployment logic, which must be addressed to improve the security posture of the local development environment. Furthermore, while the new platform.py is generally sound, it is quite large and could benefit from future modularization, and there are areas for improvement related to error handling, resource management, and robustness.
| if total_memory_gib < 8: | ||
| console.warning("Less than 8 GB of RAM detected. Performance may be degraded.") | ||
|
|
||
| with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete_on_close=False) as f: |
There was a problem hiding this comment.
The temporary file created using tempfile.NamedTemporaryFile with delete_on_close=False is never deleted after use. This will lead to an accumulation of temporary YAML files on the user's system. The file should be deleted after it's no longer needed by the limactl start command. Using a try...finally block would be a good way to ensure the file is always cleaned up, even if errors occur.
| await run_in_vm( | ||
| vm_name, | ||
| [ | ||
| "bash", | ||
| "-c", | ||
| f"kubectl --kubeconfig={kubeconfig} get configmap -n openshift-dns dns-default -o yaml | sed '/^ Corefile: |/a\\ host.docker.internal:53 {{\\n hosts {{\\n {host_ip} host.docker.internal\\n fallthrough\\n }}\\n }}' | kubectl --kubeconfig={kubeconfig} apply -f -", | ||
| ], | ||
| "Setting up internal networking", | ||
| ) |
There was a problem hiding this comment.
Using sed to modify the CoreDNS ConfigMap by piping kubectl output is fragile. The command relies on the exact YAML output format of kubectl, which could change in future versions and break this logic. A more robust approach would be to fetch the ConfigMap, parse the YAML in Python, modify the data structure, and then apply the updated ConfigMap object. This would make the code more resilient to formatting changes.
| "encryptionKey": "Ovx8qImylfooq4-HNwOzKKDcXLZCB3c_m0JlB9eJBxc=", | ||
| "trustProxyHeaders": True, | ||
| "keycloak": { | ||
| "uiClientSecret": "agentstack-ui-secret", | ||
| "serverClientSecret": "agentstack-server-secret", | ||
| "service": {"type": "LoadBalancer"}, | ||
| "auth": {"adminPassword": "admin"}, |
There was a problem hiding this comment.
Several hardcoded secrets and credentials are used in the deploy function to configure the Agent Stack platform. These include the encryptionKey, uiClientSecret, serverClientSecret, and the Keycloak adminPassword (set to "admin"). Hardcoding secrets in the source code is a security risk as they are known to anyone with access to the code. If the platform is deployed without overriding these values, it could be vulnerable to unauthorized access.
Severity: Medium
Vulnerability Type: Hardcoded Secrets
| except Exception: | ||
| pass |
There was a problem hiding this comment.
The broad except Exception: pass can hide important errors during VM status detection, such as issues with limactl or wsl.exe commands. This might lead to unexpected behavior, for example, attempting to create a VM that already exists but was not detected due to an error. It would be more robust to log the exception, especially in verbose/debug mode, to aid in debugging potential environment issues.
| if values_file and not pathlib.Path(values_file).is_file(): | ||
| raise FileNotFoundError(f"Values file {values_file} not found.") |
There was a problem hiding this comment.
The values_file parameter is already annotated as pathlib.Path | None. Calling pathlib.Path(values_file) is redundant. You can directly use the is_file() method on values_file.
| if values_file and not pathlib.Path(values_file).is_file(): | |
| raise FileNotFoundError(f"Values file {values_file} not found.") | |
| if values_file and not values_file.is_file(): | |
| raise FileNotFoundError(f"Values file {values_file} not found.") |
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Signed-off-by: Jan Pokorný JenomPokorny@gmail.com
Summary
Linked Issues
Documentation
If this PR adds new feature or changes existing. Make sure documentation is adjusted accordingly. If the docs is not needed, please explain why.