-
Notifications
You must be signed in to change notification settings - Fork 0
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
BYOH agent systemd service #5
base: main
Are you sure you want to change the base?
Conversation
Code Review Agent Run #dbd031Actionable Suggestions - 10
Additional Suggestions - 5
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
@@ -36,6 +37,28 @@ BYOH_TEMPLATES := $(REPO_ROOT)/test/e2e/data/infrastructure-provider-byoh | |||
LDFLAGS := -w -s $(shell hack/version.sh) | |||
STATIC=-extldflags '-static' | |||
|
|||
check-env: | |||
$(shell ./check_env.sh) |
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.
Consider capturing and checking the return value of check_env.sh
script execution. Currently, the shell command output is captured but not evaluated, which could mask potential environment setup issues.
Code suggestion
Check the AI-generated fix before applying
@@ -40,2 +40,2 @@ STATIC=-extldflags '-static'
check-env:
./check_env.sh || (echo "Environment check failed"; exit 1)
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
rpmbuild -bb \ | ||
--define "_topdir $(RPMBUILD_DIR)" \ | ||
--define "_src_dir $(RPM_SRC_ROOT)" \ | ||
--define "_githash $(AGENT_SRC_DIR)/scripts/pf9-byohost.spec " |
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.
The _githash
definition in the rpmbuild
command appears to be pointing to a spec file path instead of an actual git hash value. Consider updating to use the actual git hash value for proper versioning.
Code suggestion
Check the AI-generated fix before applying
--define "_githash $(AGENT_SRC_DIR)/scripts/pf9-byohost.spec " | |
--define "_githash $(shell git rev-parse HEAD)" \ |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
mkdir -p /var/log/pf9/byoh | ||
mkdir -p $HOME/.byoh/ | ||
touch /var/log/pf9/byoh/byoh-agent.log | ||
chmod +x /binary/pf9-byoh-hostagent-linux-amd64 |
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.
Consider checking if the binary file /binary/pf9-byoh-hostagent-linux-amd64
exists before attempting to change its permissions. This could prevent errors if the file is missing.
Code suggestion
Check the AI-generated fix before applying
chmod +x /binary/pf9-byoh-hostagent-linux-amd64 | |
if [ -f /binary/pf9-byoh-hostagent-linux-amd64 ]; then | |
chmod +x /binary/pf9-byoh-hostagent-linux-amd64 | |
else | |
echo "Error: Binary file not found at /binary/pf9-byoh-hostagent-linux-amd64" | |
exit 1 | |
fi |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
mkdir -p $HOME/.byoh/ | ||
touch /var/log/pf9/byoh/byoh-agent.log | ||
chmod +x /binary/pf9-byoh-hostagent-linux-amd64 | ||
cp /lib/systemd/system/pf9-byohost-agent.service /etc/systemd/system/pf9-byohost-agent.service |
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.
Consider adding error handling when copying the service file. The script should verify if the source file exists and handle potential copy failures.
Code suggestion
Check the AI-generated fix before applying
cp /lib/systemd/system/pf9-byohost-agent.service /etc/systemd/system/pf9-byohost-agent.service | |
if [ -f /lib/systemd/system/pf9-byohost-agent.service ]; then | |
if ! cp /lib/systemd/system/pf9-byohost-agent.service /etc/systemd/system/pf9-byohost-agent.service; then | |
echo "Error: Failed to copy service file" | |
exit 1 | |
fi | |
else | |
echo "Error: Service file not found at /lib/systemd/system/pf9-byohost-agent.service" | |
exit 1 | |
fi |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
expect "$(dirname $0)/rpmsign.expect" "$@" | ||
fi |
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.
Consider adding error handling for the expect
command execution. If the expect
script fails, the error should be caught and handled appropriately. Could add a check for the return value.
Code suggestion
Check the AI-generated fix before applying
expect "$(dirname $0)/rpmsign.expect" "$@" | |
fi | |
if ! expect "$(dirname $0)/rpmsign.expect" "$@"; then | |
echo "Error: Package signing failed" | |
exit 1 | |
fi | |
fi |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
echo "Log files already removed or not found" | tee -a "$LOG_FILE" | ||
fi | ||
|
||
if [-f /etc/pf9-byohost* ]; then |
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.
There appears to be a syntax error in the if
condition. The test command requires a space after [
. Consider changing [-f /etc/pf9-byohost*]
to [ -f /etc/pf9-byohost* ]
.
Code suggestion
Check the AI-generated fix before applying
if [-f /etc/pf9-byohost* ]; then | |
if [ -f /etc/pf9-byohost* ]; then |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
|
||
if [-f /etc/pf9-byohost* ]; then | ||
echo "Removing Pf9 conf files" | tee -a "$LOG_FILE" | ||
rm -f /etc/pf9* |
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.
The wildcard pattern pf9*
in rm -f /etc/pf9*
seems too broad and may unintentionally remove unrelated files. Consider using a more specific pattern like pf9-byohost*
to match only relevant files.
Code suggestion
Check the AI-generated fix before applying
rm -f /etc/pf9* | |
rm -f /etc/pf9-byohost* |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
spec: | ||
containers: | ||
- name: kube-rbac-proxy | ||
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0 |
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.
Consider updating the kube-rbac-proxy
image version from v0.8.0
to a newer version as v0.8.0
may have known security vulnerabilities. It would be worth checking if a newer version is available.
Code suggestion
Check the AI-generated fix before applying
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0 | |
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0 |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@@ -31,7 +31,7 @@ spec: | |||
args: | |||
- --enable-leader-election | |||
- "--metrics-bind-addr=127.0.0.1:8080" | |||
image: gcr.io/k8s-staging-cluster-api/cluster-api-byoh-controller:latest | |||
image: docker.io/psarwate/pf9-cluster-api-byoh-controller:dev |
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.
Consider using a specific version tag instead of dev
for the container image docker.io/psarwate/pf9-cluster-api-byoh-controller:dev
. Using floating tags like dev
can lead to inconsistent deployments and make it difficult to track which version is actually running.
Code suggestion
Check the AI-generated fix before applying
image: docker.io/psarwate/pf9-cluster-api-byoh-controller:dev | |
image: docker.io/psarwate/pf9-cluster-api-byoh-controller:v1.0.0 |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
rm -fr $RPM_BUILD_ROOT | ||
mkdir -p $RPM_BUILD_ROOT | ||
cp -r $SRC_DIR/* $RPM_BUILD_ROOT | ||
mkdir -p $RPM_BUILD_ROOT/var/log/pf9/byoh/byoh-agent.log |
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.
The mkdir
command is creating a path to what appears to be a log file rather than a directory. Consider removing /byoh-agent.log
from the path.
Code suggestion
Check the AI-generated fix before applying
mkdir -p $RPM_BUILD_ROOT/var/log/pf9/byoh/byoh-agent.log | |
mkdir -p $RPM_BUILD_ROOT/var/log/pf9/byoh |
Code Review Run #dbd031
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Code Review Agent Run #8b88d4Actionable Suggestions - 6
Review Details
|
byoh-chart/templates/workload.yaml
Outdated
description: BundleLookupBaseRegistry is the base Registry URL that is used for pulling byoh bundle images, if not set, the default will be set to https://projects.registry.vmware.com/cluster_api_provider_bringyourownhost | ||
type: string |
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.
Consider making the default registry URL configurable through a variable or environment setting rather than hardcoding it in the description. The current hardcoded URL https://projects.registry.vmware.com/cluster_api_provider_bringyourownhost
may need to change in the future.
Code suggestion
Check the AI-generated fix before applying
description: BundleLookupBaseRegistry is the base Registry URL that is used for pulling byoh bundle images, if not set, the default will be set to https://projects.registry.vmware.com/cluster_api_provider_bringyourownhost | |
type: string | |
description: BundleLookupBaseRegistry is the base Registry URL that is used for pulling byoh bundle images. If not set, the default will be set to the value of BYOH_DEFAULT_REGISTRY environment variable | |
type: string |
Code Review Run #8b88d4
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
byoh-chart/templates/workload.yaml
Outdated
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- create | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
- secrets | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- get | ||
- list | ||
- watch |
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.
Consider consolidating duplicate RBAC rules for events
and secrets
resources in the ""
API group to avoid redundancy. The permissions can be combined into a single rule with merged verbs.
Code suggestion
Check the AI-generated fix before applying
- apiGroups:
- ""
resources:
- - events
- verbs:
- - create
- - get
- - list
- - patch
- - update
- - watch
- - apiGroups:
- - ""
- resources:
- events
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- - apiGroups:
- - ""
- resources:
- - secrets
- verbs:
- - get
- - list
- - watch
Code Review Run #8b88d4
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
byoh-chart/templates/workload.yaml
Outdated
- apiGroups: | ||
- infrastructure.cluster.x-k8s.io | ||
resources: | ||
- byomachines/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- infrastructure.cluster.x-k8s.io | ||
resources: | ||
- byomachinetemplates | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- infrastructure.cluster.x-k8s.io | ||
resources: | ||
- byomachinetemplates/finalizers | ||
verbs: | ||
- update | ||
- apiGroups: | ||
- infrastructure.cluster.x-k8s.io | ||
resources: | ||
- byomachinetemplates/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- infrastructure.cluster.x-k8s.io | ||
resources: | ||
- k8sinstallerconfigs | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- infrastructure.cluster.x-k8s.io | ||
resources: | ||
- k8sinstallerconfigs/finalizers | ||
verbs: | ||
- update | ||
- apiGroups: | ||
- infrastructure.cluster.x-k8s.io | ||
resources: | ||
- k8sinstallerconfigs/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.10.0 | ||
labels: | ||
cluster.x-k8s.io/provider: infrastructure-byoh | ||
cluster.x-k8s.io/v1beta1: v1beta1 | ||
name: k8sinstallerconfigtemplates.infrastructure.cluster.x-k8s.io | ||
spec: | ||
group: infrastructure.cluster.x-k8s.io | ||
names: | ||
kind: K8sInstallerConfigTemplate | ||
listKind: K8sInstallerConfigTemplateList | ||
plural: k8sinstallerconfigtemplates | ||
singular: k8sinstallerconfigtemplate | ||
scope: Namespaced | ||
versions: | ||
- name: v1beta1 | ||
schema: | ||
openAPIV3Schema: | ||
description: K8sInstallerConfigTemplate is the Schema for the k8sinstallerconfigtemplates API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: K8sInstallerConfigTemplateSpec defines the desired state of K8sInstallerConfigTemplate | ||
properties: | ||
template: | ||
properties: | ||
spec: | ||
description: Spec is the specification of the desired behavior of the installer config. | ||
properties: |
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.
Consider consolidating similar RBAC rules for resources under the same API group infrastructure.cluster.x-k8s.io
. The current structure has repetitive declarations that could be simplified by grouping common verbs and resources together.
Code suggestion
Check the AI-generated fix before applying
- - apiGroups:
- - infrastructure.cluster.x-k8s.io
- resources:
- - byoclusters
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
- - apiGroups:
- - infrastructure.cluster.x-k8s.io
- resources:
- - byohosts
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
+ - apiGroups:
+ - infrastructure.cluster.x-k8s.io
+ resources:
+ - byoclusters
+ - byohosts
+ - byomachines
+ - byomachinetemplates
+ - k8sinstallerconfigs
+ verbs:
+ - create
+ - delete
+ - get
+ - list
+ - patch
+ - update
+ - watch
Code Review Run #8b88d4
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
scripts/Dockerfile
Outdated
conntrack \ | ||
systemctl | ||
|
||
CMD dpkg -i /pf9-byohost-agent.deb |
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.
Using CMD
with dpkg -i
may not handle package installation errors gracefully. Consider using an entrypoint script that can perform proper error handling and initialization.
Code suggestion
Check the AI-generated fix before applying
CMD dpkg -i /pf9-byohost-agent.deb | |
COPY entrypoint.sh / | |
RUN chmod +x /entrypoint.sh | |
ENTRYPOINT ["/entrypoint.sh"] | |
# Example entrypoint.sh content: | |
# #!/bin/bash | |
# dpkg -i /pf9-byohost-agent.deb || exit 1 | |
# exec "$@" |
Code Review Run #a3b31d
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Code Review Agent Run #e6df91Actionable Suggestions - 6
Review Details
|
cp $(AGENT_SRC_DIR)/scripts/install.sh $(DEB_DEP_SRC_ROOT)/install.sh | ||
echo "Successfully copied install.sh" |
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.
Consider consolidating the copy operation and its echo statement into a single command using &&
operator to ensure the echo only prints on successful copy. This would make the build process more reliable by failing fast if the copy fails.
Code suggestion
Check the AI-generated fix before applying
cp $(AGENT_SRC_DIR)/scripts/install.sh $(DEB_DEP_SRC_ROOT)/install.sh | |
echo "Successfully copied install.sh" | |
cp $(AGENT_SRC_DIR)/scripts/install.sh $(DEB_DEP_SRC_ROOT)/install.sh && echo "Successfully copied install.sh" |
Code Review Run #e6df91
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
scripts/install.sh
Outdated
sudo systemctl enable systemd-resolved --now | ||
dpkg -i pf9-byohost-agent.deb | ||
systemctl enable pf9-byohost-agent | ||
systemctl start pf9-byohost-agent |
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.
Consider adding error handling for the systemctl enable
command. The script might fail silently if the command fails. Could add a check for the command's exit status.
Code suggestion
Check the AI-generated fix before applying
sudo systemctl enable systemd-resolved --now | |
dpkg -i pf9-byohost-agent.deb | |
systemctl enable pf9-byohost-agent | |
systemctl start pf9-byohost-agent | |
if ! sudo systemctl enable systemd-resolved --now; then | |
echo "Failed to enable systemd-resolved service" | |
exit 1 | |
fi | |
if ! dpkg -i pf9-byohost-agent.deb; then | |
echo "Failed to install pf9-byohost-agent" | |
exit 1 | |
fi | |
if ! systemctl enable pf9-byohost-agent; then | |
echo "Failed to enable pf9-byohost-agent service" | |
exit 1 | |
fi | |
if ! systemctl start pf9-byohost-agent; then | |
echo "Failed to start pf9-byohost-agent service" | |
exit 1 | |
fi |
Code Review Run #e6df91
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
|
||
echo " Starting pf9-byohost-agent" | ||
sudo systemctl enable systemd-resolved --now | ||
dpkg -i pf9-byohost-agent.deb |
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.
The dpkg -i
command should be run with sudo
and include error handling. Package installation could fail silently.
Code suggestion
Check the AI-generated fix before applying
dpkg -i pf9-byohost-agent.deb | |
if ! sudo dpkg -i pf9-byohost-agent.deb; then | |
echo "Failed to install pf9-byohost-agent package" | |
exit 1 | |
fi |
Code Review Run #e6df91
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* |
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.
Consider adding apt-get autoremove -y
before cleanup commands to remove automatically installed dependencies that are no longer needed. This helps reduce the image size further.
Code suggestion
Check the AI-generated fix before applying
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
&& apt-get autoremove -y \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* |
Code Review Run #e6df91
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
@@ -66,7 +66,7 @@ func (r *ByoAdmissionReconciler) Reconcile(ctx context.Context, req ctrl.Request | |||
|
|||
// Approve the CSR | |||
logger.Info("Approving CSR", "object", req.NamespacedName) | |||
_, err = r.ClientSet.CertificatesV1().CertificateSigningRequests().UpdateApproval(ctx, csr.Name, csr, metav1.UpdateOptions{}) | |||
_, err = r.ClientSet.CertificatesV1().CertificateSigningRequests().UpdateStatus(ctx, csr, metav1.UpdateOptions{}) |
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.
Consider using UpdateApproval
instead of UpdateStatus
for CSR approval. The UpdateStatus
method may not properly handle the approval workflow for certificate signing requests.
Code suggestion
Check the AI-generated fix before applying
_, err = r.ClientSet.CertificatesV1().CertificateSigningRequests().UpdateStatus(ctx, csr, metav1.UpdateOptions{}) | |
_, err = r.ClientSet.CertificatesV1().CertificateSigningRequests().UpdateApproval(ctx, csr.Name, csr, metav1.UpdateOptions{}) |
Code Review Run #e6df91
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
…p-kubeconfig.yaml and added build dir which contains byoh-agent image creation files
Code Review Agent Run #7b5bb4Actionable Suggestions - 4
Review Details
|
ebtables \ | ||
ethtool \ | ||
conntrack \ | ||
systemctl \ |
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.
Consider using systemd
instead of systemctl
package in the Dockerfile. While systemctl
is the command-line tool, systemd
is the actual init system package that provides the complete functionality. Installing just systemctl
might lead to missing dependencies.
Code suggestion
Check the AI-generated fix before applying
systemctl \ | |
systemd \ |
Code Review Run #7b5bb4
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
|
||
echo " Starting pf9-byohost-agent" | ||
sudo systemctl enable systemd-resolved --now | ||
dpkg -i pf9-byohost-agent.deb |
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.
Consider adding error handling for the dpkg -i
command. If package installation fails, the script continues executing which could lead to service startup failures.
Code suggestion
Check the AI-generated fix before applying
dpkg -i pf9-byohost-agent.deb | |
if ! dpkg -i pf9-byohost-agent.deb; then | |
echo "Failed to install pf9-byohost-agent package" | |
exit 1 | |
fi |
Code Review Run #7b5bb4
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
test/e2e/docker_helper.go
Outdated
@@ -221,7 +221,7 @@ func (r *ByoHostRunner) copyKubeconfig(config cpConfig, listopt types.ContainerL | |||
|
|||
config.sourcePath = TempKubeconfigPath | |||
// SplitAfterN used to remove the unwanted special characters in the homeDir | |||
config.destPath = strings.SplitAfterN(strings.TrimSpace(homeDir)+"/.byoh/config", "/", 2)[1] //nolint: gomnd | |||
config.destPath = strings.SplitAfterN(strings.TrimSpace(homeDir)+"/.byoh/conf/bootstrap-kubeconfig.yaml", "/", 2)[1] //nolint: gomnd |
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.
Consider extracting the kubeconfig path .byoh/conf/bootstrap-kubeconfig.yaml
into a constant since it appears in multiple places. This would make future path changes easier to maintain and reduce the risk of inconsistencies.
Code suggestion
Check the AI-generated fix before applying
@@ -28,6 +28,7 @@
const (
kindImage = "byoh/node:e2e"
TempKubeconfigPath = "/tmp/mgmt.conf"
bootstrapKubeconfig = "/tmp/boostrap-kubeconfig"
+ ByohKubeconfigPath = ".byoh/conf/bootstrap-kubeconfig.yaml"
)
Code Review Run #7b5bb4
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
export NAMESPACE=$(grep "namespace" /root/.byoh/conf/bootstrap-kubeconfig.yaml | awk '{print $2}') | ||
echo "NAMESPACE=$NAMESPACE" > /etc/pf9-byohost-agent.service.d/pf9-byohost-agent.conf |
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.
Consider adding error handling when reading the namespace from bootstrap-kubeconfig.yaml
. If the file doesn't exist or the namespace field is missing, the script might fail silently. Maybe add a check and set a default namespace value if the grep fails.
Code suggestion
Check the AI-generated fix before applying
export NAMESPACE=$(grep "namespace" /root/.byoh/conf/bootstrap-kubeconfig.yaml | awk '{print $2}') | |
echo "NAMESPACE=$NAMESPACE" > /etc/pf9-byohost-agent.service.d/pf9-byohost-agent.conf | |
NAMESPACE=$(grep "namespace" /root/.byoh/conf/bootstrap-kubeconfig.yaml | awk '{print $2}' || echo "") | |
if [ -z "$NAMESPACE" ]; then | |
echo "Warning: Could not read namespace from config, using default" | |
NAMESPACE="default" | |
fi | |
echo "NAMESPACE=$NAMESPACE" > /etc/pf9-byohost-agent.service.d/pf9-byohost-agent.conf |
Code Review Run #7b5bb4
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Code Review Agent Run #7d319eActionable Suggestions - 1
Review Details
|
# systemctl enable pf9-byohost-agent.service | ||
# systemctl start pf9-byohost-agent.service |
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.
Consider adding error handling for the systemctl
commands to ensure the service is properly enabled and started. Could check the return status and log any failures.
Code suggestion
Check the AI-generated fix before applying
# systemctl enable pf9-byohost-agent.service | |
# systemctl start pf9-byohost-agent.service | |
if ! systemctl enable pf9-byohost-agent.service; then | |
echo "Failed to enable pf9-byohost-agent service" | |
exit 1 | |
fi | |
if ! systemctl start pf9-byohost-agent.service; then | |
echo "Failed to start pf9-byohost-agent service" | |
exit 1 | |
fi |
Code Review Run #7d319e
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Code Review Agent Run #816e29Actionable Suggestions - 0Review Details
|
Code Review Agent Run #3e8bedActionable Suggestions - 2
Review Details
|
echo "NAMESPACE=$NAMESPACE" > /etc/pf9-byohost-agent.service.d/pf9-byohost-agent.conf | ||
echo "BOOTSTRAP_KUBECONFIG=/etc/pf9-byohost-agent.service.d/bootstrap-kubeconfig.yaml" >> /etc/pf9-byohost-agent.service.d/pf9-byohost-agent.conf | ||
|
||
# systemctl daemon-reload |
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.
Consider removing the comment and enabling the systemctl daemon-reload
command since it appears to be required for the service to work properly. The subsequent commands on lines 21-22 depend on this reload.
Code suggestion
Check the AI-generated fix before applying
# systemctl daemon-reload | |
systemctl daemon-reload |
Code Review Run #3e8bed
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
@@ -0,0 +1,75 @@ | |||
# Adds namespace to all resources. | |||
namespace: '{{ .Release.Namespace }}' |
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.
Consider adding validation for {{ .Release.Namespace }}
to ensure it's not empty or invalid. The namespace value is critical for resource placement.
Code suggestion
Check the AI-generated fix before applying
namespace: '{{ .Release.Namespace }}' | |
namespace: '{{ required "Release.Namespace is required" .Release.Namespace }}' |
Code Review Run #3e8bed
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Changed Makefile to create deb and rpm package :
-> Added pf9-byohostagent.service
-> added pf9-byoh-agent-after-install.sh
-> added pf9-byoh-agent-before-remove.sh
-> added pf9-byoh-agent-after-remove.sh
-> added pf9-byohost.spec for rpm package (in progress)
Summary by Bito
This PR implements major BYOH infrastructure changes, transitioning from Docker-based installation to native packaging (DEB/RPM) with systemd integration. The implementation includes moving from ~/.byoh/conf/bootstrap-kubeconfig.yaml to ~/.byoh/config and implementing dynamic namespace-based configuration. Key improvements include certificate handling, dependency management, and systemd integration with restart policies and logging. The changes involve RBAC policy updates, streamlined Dockerfile dependencies, and removal of unnecessary systemd-resolved service enablement.Unit tests added: False
Estimated effort to review (1-5, lower is better): 5