mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-21 05:49:40 +00:00
Add environment logic in autotest
This commit is contained in:
@@ -134,12 +134,19 @@ actions = strip_curly_braces(actions)
|
||||
|
||||
background = []
|
||||
cwd = os.path.expanduser("~")
|
||||
env = {}
|
||||
for current_action, next_action in zip(actions, actions[1:]+[("bash", "true")]):
|
||||
if current_action[0] == "meta":
|
||||
continue
|
||||
print(ansi(7)(">>> {}".format(current_action[1])))
|
||||
time.sleep(1)
|
||||
proc = subprocess.Popen(current_action[1], shell=True, cwd=cwd, stdin=subprocess.PIPE, preexec_fn=os.setpgrp)
|
||||
popen_options = dict(shell=True, cwd=cwd, stdin=subprocess.PIPE, preexec_fn=os.setpgrp)
|
||||
# The follow hack allows to capture the environment variables set by `docker-machine env`
|
||||
# FIXME: this doesn't handle `unset` for now
|
||||
if "eval $(docker-machine env" in current_action[1]:
|
||||
popen_options["stdout"] = subprocess.PIPE
|
||||
current_action[1] += "\nenv"
|
||||
proc = subprocess.Popen(current_action[1], **popen_options)
|
||||
proc.cmd = current_action[1]
|
||||
if next_action[0] == "meta":
|
||||
print(">>> {}".format(next_action[1]))
|
||||
@@ -159,6 +166,13 @@ for current_action, next_action in zip(actions, actions[1:]+[("bash", "true")]):
|
||||
print(ansi(7)("<<< {}".format(current_action[1])))
|
||||
else:
|
||||
proc.wait()
|
||||
if "stdout" in popen_options:
|
||||
stdout, stderr = proc.communicate()
|
||||
for line in stdout.split('\n'):
|
||||
if line.startswith("DOCKER_"):
|
||||
variable, value = line.split('=', 1)
|
||||
env[variable] = value
|
||||
print("=== {}={}".format(variable, value))
|
||||
print(ansi(7)("<<< {} >>> {}".format(proc.returncode, current_action[1])))
|
||||
if proc.returncode != 0:
|
||||
print("Got non-zero status code; aborting.")
|
||||
|
||||
@@ -265,8 +265,17 @@ for N in $(seq 1 5); do
|
||||
ssh -o StrictHostKeyChecking=no node$N true
|
||||
done
|
||||
for N in $(seq 1 5); do
|
||||
(.
|
||||
docker-machine rm -f node$N
|
||||
ssh node$N "docker ps -aq | xargs -r docker rm -f"
|
||||
ssh node$N sudo rm -f /etc/systemd/system/docker.service
|
||||
ssh node$N sudo systemctl daemon-reload
|
||||
echo Restarting node$N.
|
||||
ssh node$N sudo systemctl restart docker
|
||||
echo Restarted node$N.
|
||||
) &
|
||||
done
|
||||
wait
|
||||
```
|
||||
-->
|
||||
|
||||
@@ -2623,7 +2632,7 @@ of this workshop.
|
||||
## How do we know when to upgrade?
|
||||
|
||||
- Subscribe to CVE notifications
|
||||
|
||||
|
||||
- https://cve.mitre.org/
|
||||
|
||||
- your distros' security announcements
|
||||
@@ -3090,7 +3099,7 @@ in the discovery service hosted by Docker Inc.
|
||||
|
||||
## Swarm manager
|
||||
|
||||
- Accepts Docker API requests
|
||||
- Accepts Docker API requests
|
||||
- Communicates with the cluster nodes
|
||||
- Performs healthchecks, scheduling...
|
||||
|
||||
@@ -3173,6 +3182,14 @@ Let's connect to the manager instead.
|
||||
eval $(docker-machine env node1 --swarm)
|
||||
```
|
||||
|
||||
<!--
|
||||
```bash
|
||||
while ! docker info | grep -q "^Nodes: 1"; do
|
||||
sleep 1
|
||||
done
|
||||
```
|
||||
-->
|
||||
|
||||
- Execute some Docker commands
|
||||
|
||||
```bash
|
||||
@@ -3307,6 +3324,14 @@ Repeat for all 4 nodes. (Pro tip: look for name/address mapping in `/etc/hosts`!
|
||||
done
|
||||
```
|
||||
|
||||
<!--
|
||||
```bash
|
||||
while ! docker info | grep -q "^Nodes: 5"; do
|
||||
sleep 1
|
||||
done
|
||||
```
|
||||
-->
|
||||
|
||||
- Check that all nodes are here:
|
||||
```bash
|
||||
docker info
|
||||
|
||||
Reference in New Issue
Block a user