-
Notifications
You must be signed in to change notification settings - Fork 8
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
Remove collector container and merge it with planner #46
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,29 @@ To run the collector localy here are the steps. | |
## Prepare | ||
Prepare the dependencies. | ||
|
||
### Configuration | ||
Create the planner-agent configuration file: | ||
|
||
``` | ||
$ mkdir /tmp/config | ||
$ mkdir /tmp/data | ||
$ cat <<EOF > ~/.planner-agent/config.yaml | ||
config-dir: /tmp/config | ||
data-dir: /tmp/data | ||
log-level: debug | ||
source-id: 9195e61d-e56d-407d-8b29-ff2fb7986928 | ||
update-interval: 5s | ||
planner-service: | ||
service: | ||
server: http://127.0.0.1:7443 | ||
EOF | ||
``` | ||
|
||
### Credentials | ||
Create VMware credentials file. | ||
|
||
``` | ||
cat <<EOF > /tmp/creds.json | ||
cat <<EOF > /tmp/data/creds.json | ||
{ | ||
"username": "[email protected]", | ||
"password": "userpassword", | ||
|
@@ -28,7 +46,7 @@ podman run -p 8181:8181 -d --name opa --entrypoint '/usr/bin/opa' quay.io/kubev2 | |
Build & run the collector code specifying credentials file as first argument and as second path to invetory file, where data should be written. | ||
|
||
``` | ||
go run cmd/collector/main.go /tmp/creds.json /tmp/inventory.json | ||
go run cmd/planner-agent/main.go -config -config ~/.planner-agent/config.yaml | ||
``` | ||
|
||
Explore `/tmp/inventory.json` | ||
Explore `/tmp/data/inventory.json` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,9 @@ func (a *Agent) Run(ctx context.Context) error { | |
} | ||
healthChecker.Start(healthCheckCh) | ||
|
||
collector := NewCollector(a.log, a.config.DataDir) | ||
go collector.collect() | ||
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. the context needs to be passed into the collector to be stopped gracefully. 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. Why do you think? Currently we keep running the agent, which monitor the changes of inventory.json. Maybe we should keep it running just with noop, because noone can update the inventory.json, but if we keep it running podman-auto-update can update image and restart the pod, so we actually do update the invetory.json. 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. I was speaking about stopping the goroutine. If you don't check the context it will leak at the end. Also, we must wait for the collector to close the inventory.json properly before exiting the agent. |
||
|
||
inventoryUpdater := NewInventoryUpdater(a.log, a.config, client) | ||
inventoryUpdater.UpdateServiceWithInventory(ctx) | ||
|
||
|
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.
shouldn't be
.migration-planner/config/config.yaml
?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.
It can, but won't help us actually, as we need to pass the path as parameter anyway, if we don't use default
/etc/planner/config
as config-dir . But will change as it makes more sense.