Skip to content

Commit

Permalink
Rename the VM and services
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed Nov 7, 2024
1 parent 9d4cf52 commit 4c05b25
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 94 deletions.
2 changes: 1 addition & 1 deletion data/AgentVM.ovf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</NetworkSection>
<VirtualSystem ovf:id="AgentVM">
<Info>A Virtual system</Info>
<Name>AgentVM</Name>
<Name>MigrationAssessmentVM</Name>
<OperatingSystemSection ovf:id="80" ovf:version="8" vmw:osType="rhel9_64Guest">
<Info>The operating system installed</Info>
<Description>Other Linux (64-bit)</Description>
Expand Down
28 changes: 14 additions & 14 deletions data/ignition.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ storage:
name: core
group:
name: core
- path: /home/core/.migration-planner
- path: /home/core/.migration-assessment
overwrite: true
user:
name: core
group:
name: core
- path: /home/core/.migration-planner/config
- path: /home/core/.migration-assessment/config
overwrite: true
user:
name: core
group:
name: core
- path: /home/core/.migration-planner/data
- path: /home/core/.migration-assessment/data
overwrite: true
user:
name: core
Expand All @@ -55,11 +55,11 @@ storage:
contents:
inline: |
PasswordAuthentication yes
- path: /home/core/.migration-planner/config/config.yaml
- path: /home/core/.migration-assessment/config/config.yaml
contents:
inline: |
config-dir: /agent/config
data-dir: /agent/data
config-dir: /migration-assessment/config
data-dir: /migration-assessment/data
www-dir: /app/www
log-level: debug
source-id: {{.SourceId}}
Expand All @@ -72,34 +72,34 @@ storage:
name: core
group:
name: core
- path: /home/core/.config/containers/systemd/planner-agent.container
- path: /home/core/.config/containers/systemd/migration-assessment.container
mode: 0644
contents:
inline: |
[Unit]
Description=Planner agent quadlet
Wants=planner-agent-opa.service
Description=Migration assessment quadlet
Wants=migration-assessment-opa.service

[Container]
Image={{.MigrationPlannerAgentImage}}
ContainerName=planner-agent
ContainerName=migration-assessment
AutoUpdate=registry
Exec= -config /agent/config/config.yaml
Exec= -config /migration-assessment/config/config.yaml
PublishPort=3333:3333
Volume=/home/core/.migration-planner:/agent:Z
Volume=/home/core/.migration-assessment:/migration-assessment:Z
Environment=OPA_SERVER=127.0.0.1:8181
Network=host
UserNS=keep-id:uid=1001

[Install]
WantedBy=multi-user.target default.target
- path: /home/core/.config/containers/systemd/planner-agent-opa.container
- path: /home/core/.config/containers/systemd/migration-assessment-opa.container
mode: 0644
contents:
inline: |
[Unit]
Description=OPA quadlet
Before=planner-agent.service
Before=migration-assessment.service

[Container]
ContainerName=opa
Expand Down
11 changes: 0 additions & 11 deletions doc/agentservice.md

This file was deleted.

63 changes: 0 additions & 63 deletions doc/agentvm.md

This file was deleted.

15 changes: 15 additions & 0 deletions doc/assistedmigration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Assited Migration service
The Assited Migration service is responsible for receiving and serving the collected vCenter data to the user. Once the user creates a source for their vCenter environment, the Assited Migration service will provide a streaming service to download an OVA image. The OVA image can be booted on the vCenter enviroment to perform the collection of the vCenter data.

## Assited migration API
There are two APIs related to the assisted migration.

### Internal API
The internal API can be found [here](../api/v1alpha1/agent/openapi.yaml).

The API contains operations to create a source, download the OVA image, etc. By default it runs on tcp port 3443. The API is not exposed externally to users, as it is only used internally by the UI.

### External API
The external API can be found [here](../api/v1alpha1/openapi.yaml).

The API is exposed to communicate with the migration assessment VM. Its only operation is to update the status of the source. By default it runs on tcp port 7443. This API must be externally exposed so that the migration assessment VM can initiate communication.
63 changes: 63 additions & 0 deletions doc/migrationassessmentvm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Migration Assessment virtual machine
The migration assessment virtual machine(VM), based on Red Hat CoreOS (RHCOS), communicates with the Assisted Migration service and reports its status.
The VM is initialized using ignition, which configures multiple containers that run as systemd services. Each of these services is dedicated to a specific function.

## Systemd services
The following are a list of systemd services that can be found on migration assessment virtual machine. All of the services
are defined as quadlets. Quadlet configuration can be found in the [ignition template file](../data/ignition.template).
The migration assessment containerfile can be found [here](../Containerfile.agent).

### migration-assessment
`migration-assessment` is a service that reports the status to the assisted migration service. The URL of the assisted migration service is configured in the file `$HOME/.migration-assessment/config/config.yaml`, which is injected via ignition.

The migration-assessment contains a web application that is exposed via tcp port 3333. Once the user accesses the web application and enters the credentials of their vCenter, the `credentials.json` file is created on the shared volume and the `collector` goroutine is spawned, which fetches the vCenter data. The data is stored in `$HOME/.migration-assessment/data/inventory.json`. Once `inventory.json` is created, the `migration-assessment` sends the data over to assisted migration service.

### migration-assessment-opa
migration-assessment-opa is a service that re-uses the [forklift validation](https://github.com/kubev2v/forklift/blob/main/validation/README.adoc) container. The forklift validation container is responsible for vCenter data validation. When the `migration-assessment` fetches vCenter data, it's validated against the OPA server and the report is shared back to the assisted migration service.

### podman-auto-update
Podman auto update is responsible for updating the image of the containers in case there is a new image release. The default `podman-auto-update.timer` is used, which executes `podman-auto-update` every 24 hours.

## Troubleshooting Migration Assessment VM services
Useful commands to troubleshoot the Migration Assessment VM. Note that all the containers are running under the `core` user.

### Listing the running podman containers
```
$ podman ps
```

### Checking the status of migration-assessment service
```
$ systemctl --user status migration-assessment
```

### Inspecting the host directory with data
When the virtual machine boots, ignition creates the `.migration-assesment` directory in the `core` user's home directory.
This directory contains two subdirectories: `data` and `config`.
The `data` directory contains a `credentials.json` file, which is created when the user enters their vCenter credentials.
It also contains an `inventory.json` file, which is created by the `migration-assesment` service when vCenter data is fetched.
The `config` directory contains a `config.yaml` file, which is created by ignition and contains configuration for the
`migration-assesment` service.

To explore the data and configuration created and used by `migration-assesment`:
```
$ ls -l /home/core/.migration-assesment/data
$ cat /home/core/.migration-assesment/config/config.yaml
```

### Check logs of the services
```
$ journalctl --user -f -u migration-assesment
```

### Status is `Not connected` after VM is booted.
This usually indicates that the `migration-assesment` service can't communicate with the assisted migration service.
Check the logs of the `migration-assesment` service:
```
journalctl --user -f -u migration-assesment
```
And search for the error in the log:
```
level=error msg="failed connecting to assisted migration: dial tcp: http://non-working-ip:7443
```
Make sure `non-working-ip` has a properly setup assisted migration service and is listening on port `7443`.
2 changes: 1 addition & 1 deletion internal/agent/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (u *InventoryUpdater) initializeCredentialUrl() {
// Connect to service
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%s", parsedURL.Hostname(), port))
if err != nil {
u.log.Errorf("failed connecting to migration planner: %v", err)
u.log.Errorf("failed connecting to assisted migration: %v", err)
u.credUrl = "N/A"
return
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (p *plannerAgentLibvirt) IsServiceRunning(agentIp string, service string) b
}

func (p *plannerAgentLibvirt) DumpLogs(agentIp string) {
stdout, _ := RunCommand(agentIp, "journalctl --no-pager --user -u planner-agent")
stdout, _ := RunCommand(agentIp, "journalctl --no-pager --user -u migration-assessment")
fmt.Fprintf(GinkgoWriter, "Journal: %v\n", stdout)
}

Expand Down
6 changes: 3 additions & 3 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var _ = Describe("e2e", func() {
}, "1m", "3s").ShouldNot(BeEmpty())
Expect(agentIP).ToNot(BeEmpty())
Eventually(func() bool {
return agent.IsServiceRunning(agentIP, "planner-agent")
return agent.IsServiceRunning(agentIP, "migration-assessment")
}, "3m", "2s").Should(BeTrue())

Eventually(func() string {
Expand All @@ -66,8 +66,8 @@ var _ = Describe("e2e", func() {

Context("Flow", func() {
It("Up to date", func() {
// Check that planner-agent service is running
r := agent.IsServiceRunning(agentIP, "planner-agent")
// Check that migration-assesment service is running
r := agent.IsServiceRunning(agentIP, "migration-assessment")
Expect(r).To(BeTrue())

// Put the vCenter credentials and check that source is up to date eventually
Expand Down

0 comments on commit 4c05b25

Please sign in to comment.