-
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
PRISM-646 - Deploy new manager #9
Changes from all commits
5969ae3
da88fe1
f45fd26
199f831
68ee19e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ MANAGER_ATTESTATION_POLICY_BINARY=../../build | |
MANAGER_GRPC_CLIENT_CERT= | ||
MANAGER_GRPC_CLIENT_KEY= | ||
MANAGER_GRPC_SERVER_CA_CERTS= | ||
MANAGER_GRPC_URL=localhost:7001 | ||
MANAGER_GRPC_PORT=6101 | ||
MANAGER_GRPC_HOST=0.0.0.0 | ||
MANAGER_GRPC_TIMEOUT=60s | ||
MANAGER_EOS_VERSION="" | ||
|
||
|
@@ -21,22 +22,22 @@ MANAGER_QEMU_MAX_MEMORY=30G | |
MANAGER_QEMU_OVMF_CODE_IF=pflash | ||
MANAGER_QEMU_OVMF_CODE_FORMAT=raw | ||
MANAGER_QEMU_OVMF_CODE_UNIT=0 | ||
MANAGER_QEMU_OVMF_CODE_FILE=/usr/share/OVMF/x64/OVMF_CODE.fd | ||
MANAGER_QEMU_OVMF_CODE_FILE=/usr/share/edk2/x64/OVMF_CODE.fd | ||
MANAGER_QEMU_OVMF_VERSION=edk2-stable202408 | ||
MANAGER_QEMU_OVMF_CODE_READONLY=on | ||
MANAGER_QEMU_OVMF_VARS_IF=pflash | ||
MANAGER_QEMU_OVMF_VARS_FORMAT=raw | ||
MANAGER_QEMU_OVMF_VARS_UNIT=1 | ||
MANAGER_QEMU_OVMF_VARS_FILE=/usr/share/OVMF/x64/OVMF_VARS.fd | ||
MANAGER_QEMU_OVMF_VARS_FILE=/usr/share/edk2/x64/OVMF_VARS.fd | ||
MANAGER_QEMU_NETDEV_ID=vmnic | ||
MANAGER_QEMU_HOST_FWD_AGENT=7020 | ||
MANAGER_QEMU_GUEST_FWD_AGENT=7002 | ||
MANAGER_QEMU_VIRTIO_NET_PCI_DISABLE_LEGACY=on | ||
MANAGER_QEMU_VIRTIO_NET_PCI_IOMMU_PLATFORM=true | ||
MANAGER_QEMU_VIRTIO_NET_PCI_ADDR=0x2 | ||
MANAGER_QEMU_VIRTIO_NET_PCI_ROMFILE= | ||
MANAGER_QEMU_DISK_IMG_KERNEL_FILE=/home/sammyk/Documents/cocos-ai/cmd/manager/img/bzImage | ||
MANAGER_QEMU_DISK_IMG_ROOTFS_FILE=/home/sammyk/Documents/cocos-ai/cmd/manager/img/rootfs.cpio.gz | ||
MANAGER_QEMU_DISK_IMG_KERNEL_FILE=/etc/cocos/bzImage | ||
MANAGER_QEMU_DISK_IMG_ROOTFS_FILE=/etc/cocos/rootfs.cpio.gz | ||
Comment on lines
+39
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Action Required: Create and Set Permissions for /etc/cocos The verification revealed that the
🔗 Analysis chainEnsure /etc/cocos directory setup and permissions. The disk image paths have been moved to Run this script to verify directory setup: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check directory setup and permissions for /etc/cocos
# Check if directory exists and its permissions
ls -ld /etc/cocos 2>/dev/null || echo "Directory not found"
# Check if files exist and their permissions
ls -l /etc/cocos/bzImage /etc/cocos/rootfs.cpio.gz 2>/dev/null || echo "Files not found"
# Check if MANAGER_QEMU_USE_SUDO is properly configured for file access
rg "MANAGER_QEMU_USE_SUDO.*true" && echo "Sudo access configured"
Length of output: 344 |
||
MANAGER_QEMU_SEV_ID=sev0 | ||
MANAGER_QEMU_SEV_CBITPOS=51 | ||
MANAGER_QEMU_SEV_REDUCED_PHYS_BITS=1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#### memory config | ||
MEMORY_SIZE=2048M | ||
MEMORY_SLOTS=5 | ||
MAX_MEMORY=30G | ||
|
||
|
||
#### ovmf code config | ||
OVMF_CODE_IF=pflash | ||
OVMF_CODE_FORMAT=raw | ||
OVMF_CODE_UNIT=0 | ||
OVMF_CODE_FILE=/usr/share/OVMF/OVMF_CODE.fd | ||
OVMF_CODE_READONLY=on | ||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Standardize OVMF paths across configuration files. The OVMF paths are inconsistent between this file and cocos-manager.env:
Please standardize these paths across all configuration files. Also applies to: 77-78 |
||
OVMF_VERSION= | ||
|
||
#### ovmf vars config | ||
OVMF_VARS_IF=pflash | ||
OVMF_VARS_FORMAT=raw | ||
OVMF_VARS_UNIT=1 | ||
OVMF_VARS_FILE=/usr/share/OVMF/OVMF_VARS.fd | ||
|
||
#### net dev config | ||
NET_DEV_ID=vmnic | ||
NET_DEV_HOST_FWD_AGENT=7020 | ||
NET_DEV_GUEST_FWD_AGENT=7002 | ||
|
||
#### Virtio Net Pci Config | ||
VIRTIO_NET_PCI_DISABLE_LEGACY=on | ||
VIRTIO_NET_PCI_IOMMU_PLATFORM=true | ||
VIRTIO_NET_PCI_ADDR=0x2 | ||
VIRTIO_NET_PCI_ROMFILE= | ||
|
||
#### Disk image config | ||
DISK_IMG_KERNEL_FILE= | ||
DISK_IMG_ROOTFS_FILE= | ||
|
||
KERNEL_COMMAND_LINE="quiet console=null" | ||
|
||
#### Sev Config | ||
SEV_ID=sev0 | ||
SEV_CBIT_POS=51 | ||
SEV_REDUCED_PHYS_BITS=1 | ||
SEV_HOST_DATA= | ||
|
||
#### VSock Config | ||
VSOCK_ID=vhost-vsock-pci0 | ||
VSOCK_GUEST_CID=3 | ||
|
||
BIN_PATH=qemu-system-x86_64 | ||
USE_SUDO=false | ||
ENABLE_SEV=false | ||
ENABLE_SEV_SNP=false | ||
|
||
ENABLE_KVM=true | ||
|
||
MACHINE=q35 | ||
CPU=EPYC | ||
SMP_COUNT=8 | ||
SMP_MAXCPUS=64 | ||
MEM_ID=ram1 | ||
|
||
KERNEL_HASH=false | ||
|
||
NO_GRAPHIC=true | ||
MONITOR=pty | ||
HOST_FWD_RANGE=6100-6200 | ||
CERTS_MOUNT=/etc/cocos/certs | ||
ENV_MOUNT=/etc/cocos/environment | ||
|
||
COCOS_AGENT_VERSION=v0.3.1 | ||
|
||
#### Base image URL and names | ||
BASE_IMAGE_URL=https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img | ||
BASE_IMAGE=ubuntu-base.qcow2 | ||
CUSTOM_IMAGE=ubuntu-custom.qcow2 | ||
|
||
#### Paths for OVMF firmware | ||
OVMF_CODE=/usr/share/ovmf/x64/OVMF_CODE.4m.fd | ||
OVMF_VARS=/usr/share/ovmf/x64/OVMF_VARS.4m.fd | ||
|
||
#### VM parameters | ||
VM_NAME=cocos-vm | ||
RAM=16G | ||
DISK_SIZE=10G # Size for root filesystem | ||
QEMU_BINARY=qemu-system-x86_64 | ||
|
||
AGENT_GRPC_SERVER_CERT=/etc/cocos/certs/server.pem | ||
AGENT_GRPC_SERVER_KEY=/etc/cocos/certs/key.pem | ||
AGENT_GRPC_SERVER_CA_CERTS=/etc/cocos/ca.pem | ||
AGENT_GRPC_CLIENT_CA_CERTS=/etc/cocos/ca.pem |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Agent Cloud Init Setup | ||
|
||
## Overview | ||
|
||
The `hal/cloud` directory contains essential files required for setting up a virtual machine (VM) with cloud-init. This setup ensures the automated installation of dependencies, configuration of the environment, and deployment of the Cocos agent as a systemd service. | ||
|
||
### Directory Contents | ||
|
||
- **`config.yaml`**: This YAML file provides configuration instructions for the cloud image. | ||
- **`meta-data`**: Contains VM metadata, such as instance-specific details and identifiers. | ||
- **`qemu.sh`**: A Bash script for downloading and configuring a cloud image, running QEMU to simulate a VM with the cloud-init configuration. | ||
- **`.env`**: Contains environment variables for starting the VM in different modes, configuring disk space, memory allocation, and other parameters. | ||
|
||
## Configuration | ||
|
||
### Preparing the Cloud-Config File | ||
|
||
The `config.yaml` file defines system configurations, including user creation, package installations, file management, and command execution. | ||
Ensure that the cloud-config file is set up with the following configurations: | ||
|
||
- **User Credentials**: Specify the default username and password. | ||
- **Certificates and Keys**: Certificate files for agent for secure communication. | ||
- **Environment Variables**: Configuration parameters required by the system. | ||
|
||
The `config.yaml` file is divided into multiple sections, each addressing a specific aspect of the setup process. | ||
|
||
### 1. User Configuration | ||
|
||
This section creates a default user with specific permissions and configurations: | ||
|
||
- Creates a user named **`cocos_user`**. | ||
- Adds `cocos_user` to the `sudo` and `docker` groups. | ||
- Sets a default password (should be changed for production use). | ||
- Configures the user’s shell as `/bin/bash`. | ||
|
||
### 2. Package Installation | ||
|
||
Installs essential system packages required for various operations: | ||
|
||
- **`curl`**: For downloading files from the web. | ||
- **`make`**: A utility for building software. | ||
- **`git`**: Version control system for managing code repositories. | ||
- **`python3` and `python3-dev`**: Required for running Python-based tools. | ||
- **`net-tools`**: Provides networking utilities such as `ifconfig` and `route`. | ||
|
||
### 3. File Management (write_files) | ||
|
||
Creates and configures critical files required for the setup: | ||
|
||
- **Certificates**: Cert files (`cert.pem`, `ca.pem`, `key.pem`) located at `/etc/cocos/certs/`. | ||
- **Environment Variables**: An env file stored at `/etc/cocos/environment`. | ||
- **Systemd Service File**: Cocos agent service configuration file at `/etc/systemd/system/cocos-agent.service` for managing the Cocos agent. | ||
- **Agent Scripts**: | ||
- `agent_setup.sh`: Configures network interfaces and resizes the root filesystem. | ||
- `agent_start_script.sh`: Sets up Docker and starts the Cocos agent. | ||
|
||
### 4. Execution of Commands (runcmd) | ||
|
||
A sequence of commands is executed to finalize the setup: | ||
|
||
- Creates necessary directories: `/cocos`, `/cocos_init`, `/var/log/cocos`, `/etc/cocos`. | ||
- Downloads and installs the Cocos agent binary. | ||
- Installs **Wasmtime** and configures its environment variables. | ||
- Installs **Docker** and adds `cocos_user` to the Docker group. | ||
- Reloads systemd and enables the Cocos agent service. | ||
|
||
## Running the Agent | ||
|
||
To test the cloud-init configuration, execute the `qemu.sh` script to bring up a VM using QEMU: | ||
|
||
```bash | ||
sudo ./qemu.sh | ||
``` | ||
|
||
**Important:** The script must be executed as root. | ||
|
||
Once the QEMU boots the VM, the Cocos agent will run as a systemd service. The service is configured to start automatically on boot and restart in case of failure. | ||
|
||
## Debugging and Monitoring | ||
|
||
For troubleshooting and monitoring the Cocos agent service, use the following commands within the VM: | ||
|
||
### Manually Start the Service | ||
|
||
To manually start the agent service, execute: | ||
|
||
```bash | ||
sudo systemctl start cocos-agent.service | ||
``` | ||
|
||
### Verify Service Status | ||
|
||
To check if the service is running properly, use: | ||
|
||
```bash | ||
sudo systemctl status cocos-agent.service | ||
``` | ||
|
||
### View Service Logs | ||
|
||
To inspect logs generated by the agent service, execute: | ||
|
||
```bash | ||
journalctl -u cocos-agent.service | ||
``` | ||
|
||
### Check Standard Output and Error Logs | ||
|
||
To check logs stored in the system, use: | ||
|
||
```bash | ||
cat /var/log/cocos/agent.stdout.log | ||
cat /var/log/cocos/agent.stderr.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.
💡 Codebase verification
OVMF Path Verification Issue
/usr/share/edk2/x64/OVMF_CODE.fd
(and similarly/usr/share/edk2/x64/OVMF_VARS.fd
).🔗 Analysis chain
Verify OVMF paths for Dell machines.
The OVMF paths have been updated to use the edk2 package. Since this PR aims to enable deployment on Dell machines, please verify these paths:
/usr/share/edk2/x64/OVMF_CODE.fd
/usr/share/edk2/x64/OVMF_VARS.fd
Run this script to check path compatibility:
Also applies to: 31-31
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 156