diff --git a/.github/workflows/review-requested.yml b/.github/workflows/review-requested.yml index 5b7359f..b36b180 100644 --- a/.github/workflows/review-requested.yml +++ b/.github/workflows/review-requested.yml @@ -5,6 +5,7 @@ on: jobs: vale: + if: github.event.requested_reviewer.login == 'tech-comm-team-couchbase' uses: couchbaselabs/docs-runner/.github/workflows/vale-review.yml@main with: path: . diff --git a/modules/ROOT/pages/tutorial-sync-gateway-manage.adoc b/modules/ROOT/pages/tutorial-sync-gateway-manage.adoc index 1f82c60..e54c46e 100644 --- a/modules/ROOT/pages/tutorial-sync-gateway-manage.adoc +++ b/modules/ROOT/pages/tutorial-sync-gateway-manage.adoc @@ -74,9 +74,10 @@ Instead, Enterprise customers can use this endpoint to automatically upload it t [source,console] ---- $ curl -X POST \ - http://localhost:4985/_sgcollect_info \ + https://localhost:4985/_sgcollect_info \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ + -H 'Authorization: Basic c3luY19nYXRld2F5OnBhc3N3b3Jk' \ -d '{ "output_dir": "/home/sync_gateway/logs", "upload": false @@ -84,7 +85,6 @@ $ curl -X POST \ ---- - ==== Monitor the status of the log collection Use the xref:sync-gateway::admin-rest-api.adoc[`GET _sgcollect_info`] REST endpoint to monitor the status of the log collection. This is an example of the command. @@ -93,9 +93,10 @@ Wait until the status reported back is not `running` [source,console] ---- $ curl -X GET \ - http://localhost:4985/_sgcollect_info \ + https://localhost:4985/_sgcollect_info \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' + -H 'Authorization: Basic c3luY19nYXRld2F5OnBhc3N3b3Jk' \ ---- ==== Copy Log Files @@ -121,7 +122,7 @@ To collect logs on a specific pod, run `sgcollect_info` using the `kubectl` http The following command runs `sgcollect_info` on the specified pod and outputs the results to an *out.zip* file. [source,console] ---- -$ kubectl exec -- /opt/couchbase-sync-gateway/tools/sgcollect_info /tmp/out.zip +$ kubectl exec "$pod" -- curl -X POST https://localhost:4985/_sgcollect_info -H 'Accept: application/json' -H 'Authorization: Basic c3luY19nYXRld2F5OnBhc3N3b3Jk' -d `{"output_dir": "/home/sync_gateway/logs"}` ---- ==== Coping log output from pod @@ -140,15 +141,29 @@ The following script runs `sgcollect_info` on all the pods and to copy the zippe //This script is available as `collect_logs_sgw_pods.sh ` [source,sh] ---- -#! /bin/sh -OUTFOLDER=${1:-/tmp} -for pod in `kubectl get pods -o=name | grep sync-gateway | sed "s/^.\{4\}//"` -do - LOGFILE=$OUTFOLDER/$pod'_sgcollect_info_out.zip' - echo "Running sgcollect_info to generate $LOGFILE" - kubectl exec $pod -- /opt/couchbase-sync-gateway/tools/sgcollect_info $LOGFILE - echo "copying $pod:$LOGFILE to current folder" - kubectl cp $pod:$LOGFILE . +#!/bin/bash + +for pod in $(kubectl get pods -o=name | grep sync-gateway | sed "s/^.\{4\}//"); do + echo "Running /_sgcollect_info on $pod" + REMOTE_OUTFOLDER="/home/sync_gateway/logs/sgcollects_$pod" + kubectl exec "$pod" -- mkdir -p "$REMOTE_OUTFOLDER" + kubectl exec "$pod" -- curl -X POST https://localhost:4985/_sgcollect_info -H 'Accept: application/json' -H 'Authorization: Basic c3luY19nYXRld2F5OnBhc3N3b3Jk' -d "{\"output_dir\": \"$REMOTE_OUTFOLDER\"}" + echo "Waiting for /_sgcollect_info to finish on $pod" + # wait for 60 minutes of output + for attempt in {1..120}; do + RESPONSE=$(kubectl exec "$pod" -- curl -X GET https://localhost:4985/_sgcollect_info -H 'Content-Type: application/json' -H 'Authorization: Basic c3luY19nYXRld2F5OnBhc3N3b3Jk') + STATUS=$(echo "$RESPONSE" | jq -r '.status') + echo "Current status is $STATUS" + if [[ "$STATUS" != "running" ]]; then + break + else + echo "Attempt $attempt: status is '$STATUS' — waiting..." + INTERVAL=30 + sleep "$INTERVAL" + fi + done + echo "copying $pod:$REMOTE_OUTFOLDER to current folder" + kubectl cp "$pod":"$REMOTE_OUTFOLDER" . done ----