Skip to content

Commit

Permalink
action: add watch on console log file for sshd status
Browse files Browse the repository at this point in the history
This commit updates the GHA action to watch for sshd status within the
VM's console log file. Success and failure messages for sshd are
continually searched for in the console log file over the course of 30s.
If a failure is observed, then the step fails. If success is observed,
then the step moves on to attempting to ssh into the VM. Continuing to
check if ssh access is available is important, because at the end of the
day, this is the functionality that is needed to continue. Parsing
through the console log file is an added step to help gain insight into
what is going on in the VM.

Regex match-alls is used for white-space in-between keywords when
searching, as console color characters may be printed between.
Additionally, '\.service' is not appended to the end of 'ssh' in these
search strings, as sometimes this part of the string gets truncated in
the log file.

Ref: cilium/cilium#26012

Signed-off-by: Ryan Drew <ryan.drew@isovalent.com>
  • Loading branch information
learnitall authored and brb committed Jul 17, 2023
1 parent 7c15781 commit 714e1e9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,29 @@ runs:
if [ "${{ inputs.verbose }}" == "true" ]; then
extraArgs+=("--verbose")
fi
touch /tmp/console.log
sudo /bin/lvh run --host-mount=${{ inputs.host-mount }} --image /_images/${{ inputs.test-name }}.qcow2 \
--daemonize -p ${{ inputs.ssh-port }}:22 --serial-port ${{ inputs.serial-port }} \
--cpu=${{ inputs.cpu }} --mem=${{ inputs.mem }} --cpu-kind ${{ inputs.cpu-kind }} \
--console-log-file /tmp/console.log \
${extraArgs[@]}
- name: Wait for VM's SSH Server
shell: bash
run: |
n=0
until [ "$n" -ge 30 ]; do
started=1
if grep -E ".*OK.*Started.*ssh.*" /tmp/console.log; then
break || started=0
elif grep -E ".*FAILED.*Failed.*to.*start.*ssh*" /tmp/console.log; then
cat /tmp/console.log && exit 40
fi
n=$((n+1))
sleep 1
done
[ $started -eq 1 ] || (cat /tmp/console.log && exit 41)
n=0
until [ "$n" -ge 5 ]; do
success=1
Expand All @@ -180,7 +195,7 @@ runs:
n=$((n+1))
sleep 1
done
[ $success -eq 1 ] || exit 42
[ $success -eq 1 ] || (cat /tmp/console.log && exit 42)
- name: Set DNS resolver
if: ${{ inputs.provision == 'true' && inputs.dns-resolver != '' }}
Expand Down

0 comments on commit 714e1e9

Please sign in to comment.