Skip to content
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

CSS-4745 Improve dev environment (debugging + controller setup) #1023

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ tmp_dir = "tmp"
[build]
args_bin = []
bin = "./tmp/jimm"
cmd = "go build -buildvcs=false -tags version -o ./tmp/jimm ./cmd/jimmsrv "
cmd = "go build -gcflags='all=-N -l' -buildvcs=false -o ./tmp/jimm ./cmd/jimmsrv"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_dir = [".vscode", "assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
full_bin = "dlv exec --accept-multiclient --log --headless --continue --listen :2345 --api-version 2 ./tmp/jimm"
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
kill_delay = "0s"
Expand Down
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
},
{
"name": "Attach to container",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "/jimm/",
"substitutePath": [
{
"from": "${workspaceFolder}/",
"to": "/jimm/",
},
],
"port": 2345,
"host": "127.0.0.1",
"showLog": true,
"apiVersion": 2,
"trace": "verbose"
}
]
}
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ services:
hostname: jimm.localhost
working_dir: /jimm
container_name: jimmy
entrypoint:
- bash
- -c
- >-
go install github.com/go-delve/delve/cmd/dlv@latest
&& air
ports:
- 17070:80
- 2345:2345
environment:
JIMM_LOG_LEVEL: "debug"
JIMM_UUID: "3217dbc9-8ea9-4381-9e97-01eab0b3f6bb"
Expand Down
2 changes: 1 addition & 1 deletion local/jimm/add-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo "Switching juju controller to $JIMM_CONTROLLER_NAME"
juju switch "$JIMM_CONTROLLER_NAME"
echo
echo "Retrieving controller info for $CONTROLLER_NAME"
./jimmctl controller-info "$CONTROLLER_NAME" "$CONTROLLER_YAML_PATH"
./jimmctl controller-info --local "$CONTROLLER_NAME" "$CONTROLLER_YAML_PATH"
kian99 marked this conversation as resolved.
Show resolved Hide resolved
if [[ -f "$CONTROLLER_YAML_PATH" ]]; then
echo "Controller info retrieved."
else
Expand Down
22 changes: 15 additions & 7 deletions local/jimm/setup-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@

set -ux

CLOUDINIT_FILE="cloudinit.temp.yaml"
function finish {
rm "$CLOUDINIT_FILE"
}
trap finish EXIT

CONTROLLER_NAME="${CONTROLLER_NAME:-qa-controller}"
CLOUDINIT_TEMPLATE=$'cloudinit-userdata: |
preruncmd:
- echo "%s candid.localhost" >> /etc/hosts
ca-certs:
trusted:
- |\n%s'

printf "$CLOUDINIT_TEMPLATE" "$(lxc network get lxdbr0 ipv4.address | cut -f1 -d/)" "$(cat local/traefik/certs/ca.crt | sed -e 's/^/ /')" > "${CLOUDINIT_FILE}"

echo "Bootstrapping controller"
juju bootstrap localhost "${CONTROLLER_NAME}" --config allow-model-access=true --config identity-url=https://candid.localhost
juju bootstrap localhost "${CONTROLLER_NAME}" --config allow-model-access=true --config "${CLOUDINIT_FILE}" --config identity-url=https://candid.localhost
CONTROLLER_ID=$(juju show-controller --format json | jq --arg name "${CONTROLLER_NAME}" '.[$name]."controller-machines"."0"."instance-id"' | tr -d '"')
echo "Adding proxy to LXC instance ${CONTROLLER_ID}"
lxc config device add "${CONTROLLER_ID}" myproxy proxy listen=tcp:0.0.0.0:443 connect=tcp:127.0.0.1:443 bind=instance
echo "Pushing local CA"
lxc file push local/traefik/certs/ca.crt "${CONTROLLER_ID}"/usr/local/share/ca-certificates/
lxc exec "${CONTROLLER_ID}" -- update-ca-certificates
echo "Restarting controller"
lxc stop "${CONTROLLER_ID}"
lxc start "${CONTROLLER_ID}"