Skip to content

Commit 247249d

Browse files
authored
Merge pull request #105 from tsurai/main
Fix controller regression errors
2 parents 5b7977b + d2adf07 commit 247249d

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

controller/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ The container engine must have an enabled user socket for the executing user to
1010
* Podman: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/building_running_and_managing_containers/assembly_using-the-container-tools-api_using-the-container-tools-cli#proc_enabling-the-podman-api-using-systemd-in-rootless-mode_assembly_using-the-container-tools-api
1111

1212
### Networking
13-
The controller uses a shared service network namespace to communicate with the node. For docker either the flag `--network=service:node-service-name` or the docker-compose setting `network_mode: "service:node-service-name"` has to be set for the controller container. For Podman running both the controller and node together in one pod is sufficient.
13+
By default the node will try to connect to the controller via the 127.0.0.1 loopback address. A different IP can be configured in `indy_config.py` using the setting `controlServiceHost=x.x.x.x`.
14+
Alternatively both docker and podman allow container to share the same network via either the docker flag `--network=service:node-service-name` or the docker-compose setting `network_mode: "service:node-service-name"`. For Podman runniggng both the controller and node together in one pod is sufficient.
1415

1516
### Environment variables
16-
* CONTAINER: name of the indy node container to be controlled
17+
* NODE_CONTAINER: name of the indy node container to be controlled
18+
* CONTROLLER_CONTAINER: name of the indy node controller itself
1719
* ENGINE: container engine to be used. Defaults to docker
1820

1921
### Mountpoints

controller/upgrade_indy.sh

+16-15
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,23 @@ if [[ "$ENGINE" != "podman" && "$ENGINE" != "docker" ]]; then
2424
fi
2525

2626
for container in $NODE_CONTAINER $CONTROLLER_CONTAINER; do
27-
inspect="$ENGINE container inspect $container --format "
27+
inspect_container="$ENGINE container inspect $container --format "
2828

29-
if [[ "$($inspect '{{.State.Status}}')" != "running" ]]; then
29+
if [[ "$($inspect_container '{{.State.Status}}')" != "running" ]]; then
3030
echo "Skipping upgrade because the container '$container' is not running"
3131
continue
3232
fi
3333

3434
# get name of the image used by the container
35-
image_name="$($inspect '{{.Config.Image}}')"
35+
image_name="$($inspect_container '{{.Config.Image}}')"
3636
if [[ -z "$image_name" ]]; then
3737
print_error "Container $container does not exist"
3838
exit 22
3939
fi
40+
inspect_image="$ENGINE image inspect $image_name --format "
4041

41-
# save the creation date of the image
42-
image_date="$($ENGINE image inspect "$image_name" --format '{{.Created}}')"
42+
# save the current image hash
43+
image_hash="$($inspect_container '{{.Image}}')"
4344

4445
# try to pull a new image
4546
output="$($ENGINE image pull "$image_name")"
@@ -49,19 +50,19 @@ for container in $NODE_CONTAINER $CONTROLLER_CONTAINER; do
4950
exit 1
5051
fi
5152

52-
# compare the old and new creation date to verify that a newer image has been pulled
53-
if [[ "$($ENGINE image inspect $image_name --format '{{.Created}}')" != "$image_date" && "$container" == "$NODE_CONTAINER" ]]; then
53+
# compare the old and new image hash to verify that a newer image has been pulled
54+
if [[ "$($inspect_image '{{.Id}}')" != "$image_hash" && "$container" == "$NODE_CONTAINER" ]]; then
5455
# parse and save various container parameter to supply to the new one
55-
binds="-v $($inspect '{{join .HostConfig.Binds " -v "}}')"
56-
ports="$($inspect '{{range $k, $v := .NetworkSettings.Ports}}{{range $v}}{{print "-p " .HostIp ":" .HostPort ":" $k " "}}{{end}}{{end}}' | sed 's/:::/[::]:/g')"
57-
network="$($inspect '{{range $k, $v := .NetworkSettings.Networks}}{{$id := slice "'$($inspect {{.Id}})'" 0 12}}{{$aliases := join $v.Aliases " --network-alias "}}{{println "--network" $k "--ip" $v.IPAddress "--network-alias" $aliases "--network-alias" $id}}{{end}}' | head -n1)"
58-
restart="--restart $($inspect '{{.HostConfig.RestartPolicy.Name}}')"
59-
init="$($inspect '{{.HostConfig.Init}}' | sed 's/true/--init/g; /--init/!s/.*//')"
60-
$inspect '{{join .Config.Env "\n"}}' > /tmp/envs
56+
binds="-v $($inspect_container '{{join .HostConfig.Binds " -v "}}')"
57+
ports="$($inspect_container '{{range $k, $v := .NetworkSettings.Ports}}{{range $v}}{{print "-p " .HostIp ":" .HostPort ":" $k " "}}{{end}}{{end}}' | sed 's/:::/[::]:/g')"
58+
network="$($inspect_container '{{range $k, $v := .NetworkSettings.Networks}}{{$id := slice "'$($inspect_container {{.Id}})'" 0 12}}{{$aliases := join $v.Aliases " --network-alias "}}{{println "--network" $k "--ip" $v.IPAddress "--network-alias" $aliases "--network-alias" $id}}{{end}}' | head -n1)"
59+
restart="--restart $($inspect_container '{{.HostConfig.RestartPolicy.Name}}')"
60+
init="$($inspect_container '{{.HostConfig.Init}}' | sed 's/true/--init/g; /--init/!s/.*//')"
61+
$inspect_container '{{join .Config.Env "\n"}}' > /tmp/envs
6162
envs="$(if [ -s /tmp/envs ]; then echo "--env-file /tmp/envs"; else echo ""; fi)"
62-
$inspect '{{range $k,$v := .Config.Labels}}{{printf "%s=%s\n" $k $v}}{{end}}' | grep -v "^org.opencontainers.image" > /tmp/labels
63+
$inspect_container '{{range $k,$v := .Config.Labels}}{{printf "%s=%s\n" $k $v}}{{end}}' | grep -v "^org.opencontainers.image" > /tmp/labels
6364
# patch image hash in the docker-compose labels
64-
sed -i "s/sha256.*/$($ENGINE image inspect docker --format '{{.Id}}')/g" /tmp/labels
65+
sed -i "s/sha256.*/$($inspect_image '{{.Id}}')/g" /tmp/labels
6566
labels="$(if [ -s /tmp/labels ]; then echo "--label-file /tmp/labels"; else echo ""; fi)"
6667

6768
output=$($ENGINE container create --name ${container}_new $binds $ports $network $init $restart $envs $labels $image_name) 1> /dev/null

0 commit comments

Comments
 (0)