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

Fix: github workflow upload logs dir error #917

Merged
Merged
10 changes: 5 additions & 5 deletions .github/workflows/integrate-cluster-cmd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ jobs:

- name: Collect component log
working-directory: ${{ env.working-directory }}
# if: steps.test.outputs.exit_code != 0
if: always()
if: steps.test.outputs.exit_code != 0
# if: always()
run: |
docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-cluster/script/pull_log.sh /tiup-cluster/logs
ls ${{ env.working-directory }}
tar czvf ${{ env.working-directory }}/logs.tar.gz ${{ env.working-directory }}/logs/

- name: Upload component log
# if: steps.test.outputs.exit_code != 0
if: always()
if: steps.test.outputs.exit_code != 0
# if: always()
uses: actions/upload-artifact@v1
with:
name: component_logs
Expand All @@ -87,7 +87,7 @@ jobs:
docker ps
df -h
free -h
"cat ./tests/*.log" || true
cat /tiup-cluster/logs/*.log || true

- name: Upload coverage to Codecov
working-directory: ${{ env.working-directory }}
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/integrate-cluster-scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,31 @@ jobs:

- name: Collect component log
working-directory: ${{ env.working-directory }}
# if: steps.test.outputs.exit_code != 0
if: always()
if: steps.test.outputs.exit_code != 0
# if: always()
run: |
docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-cluster/script/pull_log.sh /tiup-cluster/logs
ls ${{ env.working-directory }}
tar czvf ${{ env.working-directory }}/logs.tar.gz ${{ env.working-directory }}/logs/

- name: Upload component log
# if: steps.test.outputs.exit_code != 0
if: always()
if: steps.test.outputs.exit_code != 0
# if: always()
uses: actions/upload-artifact@v1
with:
name: component_logs
name: cluster_logs
path: ${{ env.working-directory }}/logs.tar.gz

- name: Output cluster debug log
working-directory: ${{ env.working-directory }}
if: always()
if: steps.test.outputs.exit_code != 0
# if: always()
run: |
pwd
docker ps
df -h
free -h
"cat ./tests/*.log" || true
cat /tiup-cluster/logs/*.log || true

- name: Upload coverage to Codecov
working-directory: ${{ env.working-directory }}
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/integrate-dm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,34 @@ jobs:
# ref: https://stackoverflow.com/questions/43099116/error-the-input-device-is-not-a-tty
docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-dm/run.sh ${{matrix.cases}}

- name: Collect component log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why upload log? I think just replacing cat ./tests/*.log with a correct log path will be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As cluster

docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-cluster/script/pull_log.sh /tiup-cluster/logs
uploads it, so I think dm should upload it too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, How about add cat /path/to/*.log too? By this way we can check what happened without downloading the logs when some error occurs in test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea, as the debug file may be very large and may not be human-readable on the terminal, BTW, I'll give it a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to adjust my strategy to look like this:if the test passed, no log were uploaded and print out; else upload and print it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's cool

working-directory: ${{ env.working-directory }}
# if: steps.test.outputs.exit_code != 0
if: always()
run: |
docker exec tiup-cluster-control bash -c 'mkdir -p /tiup-cluster/logs; [[ -d ~/.tiup/logs ]] && find ~/.tiup/logs -type f -name "*.log" -exec cp {} /tiup-cluster/logs \; || true'
ls ${{ env.working-directory }}
tar czvf ${{ env.working-directory }}/dm.logs.tar.gz ${{ env.working-directory }}/logs/

- name: Upload component log
if: steps.test.outputs.exit_code != 0
# if: always()
uses: actions/upload-artifact@v1
with:
name: dm_logs
path: ${{ env.working-directory }}/dm.logs.tar.gz

- name: Output cluster debug log
working-directory: ${{ env.working-directory }}
if: steps.test.outputs.exit_code != 0
# if: always()
run: |
pwd
docker ps
df -h
free -h
cat /tiup-cluster/logs/*.log || true

- name: Upload coverage to Codecov
working-directory: ${{ env.working-directory }}
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integrate-playground.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ jobs:

- name: Collect component log
working-directory: ${{ env.working-directory }}
# if: steps.test.outputs.exit_code != 0
if: always()
if: steps.test.outputs.exit_code != 0
# if: always()
run: |
find ${{ env.working-directory }}/tests/tiup-playground/_tmp/home/data -type f | grep -E '*/ti.*/ti.*.log$' | xargs tar czvf ${{ env.working-directory }}/playground.logs.tar.gz

- name: Upload component log
# if: steps.test.outputs.exit_code != 0
if: always()
if: steps.test.outputs.exit_code != 0
# if: always()
uses: actions/upload-artifact@v1
with:
name: playground_logs
Expand Down
16 changes: 6 additions & 10 deletions tests/tiup-cluster/script/pull_log.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash


out_dir=$1

ipprefix=${TIUP_TEST_IP_PREFIX:-"172.19.0"}

mkdir -p $out_dir
Expand All @@ -13,15 +11,13 @@ do
echo $h
mkdir -p $out_dir/$h

if [ "$h" == "${ipprefix}.100" ]
then
logs=$(ssh -o "StrictHostKeyChecking no" root@$h "find /tiup-cluster/logs | grep '.*log/.*\.log'")
if [ "$i" == "100" ]; then
find ~/.tiup/logs -type f -name "*.log" -exec cp "{}" $out_dir/$h \;
else
logs=$(ssh -o "StrictHostKeyChecking no" root@$h "find /home/tidb | grep '.*log/.*\.log'")
for log in $logs
do
scp -o "StrictHostKeyChecking no" -r root@$h:$log "$out_dir/$h/"
done
fi

for log in $logs
do
scp -o "StrictHostKeyChecking no" -r root@$h:$log "$out_dir/$h/"
done
done