From 85fb9eca26afe4f6b8e72faa7cf4c1b04a8ee5d6 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 20 Nov 2019 10:54:41 -0500 Subject: [PATCH] Improve logging in SSH pipeline --- gitsrht-keys/main.go | 1 + gitsrht-shell/main.go | 4 ++++ gitsrht-update-hook/post-update.go | 2 ++ gitsrht-update-hook/webhooks.go | 3 +++ 4 files changed, 10 insertions(+) diff --git a/gitsrht-keys/main.go b/gitsrht-keys/main.go index 9f4cc6c..7741db1 100644 --- a/gitsrht-keys/main.go +++ b/gitsrht-keys/main.go @@ -209,6 +209,7 @@ func main() { } push := uuid.New() + logger.Printf("Assigned uuid %s to this push", push.String()) shellCommand := fmt.Sprintf("%s '%d' '%s' '%s'", shell, userId, username, b64key) fmt.Printf(`restrict,command="%s",`+ diff --git a/gitsrht-shell/main.go b/gitsrht-shell/main.go index 858a9a9..c8dfcba 100644 --- a/gitsrht-shell/main.go +++ b/gitsrht-shell/main.go @@ -108,6 +108,10 @@ func main() { cmdstr = "" } + if pushUuid, ok := os.LookupEnv("SRHT_PUSH"); ok { + logger.Printf("Running shell for push %s", pushUuid) + } + // Grab the command the user is trying to execute cmd, err = shlex.Split(cmdstr) if err != nil { diff --git a/gitsrht-update-hook/post-update.go b/gitsrht-update-hook/post-update.go index 3bba5ac..34b5978 100644 --- a/gitsrht-update-hook/post-update.go +++ b/gitsrht-update-hook/post-update.go @@ -269,5 +269,7 @@ func postUpdate() { // blocking the pusher's terminal. stage3 := exec.Command(hook, string(deliveriesJson), string(payloadBytes)) stage3.Args[0] = "stage-3" + logger.Printf("Executing stage 3 to record %d sync deliveries and make " + + "%d async deliveries", len(deliveries), len(dbinfo.AsyncWebhooks)) stage3.Start() } diff --git a/gitsrht-update-hook/webhooks.go b/gitsrht-update-hook/webhooks.go index ac68eda..2f5ddec 100644 --- a/gitsrht-update-hook/webhooks.go +++ b/gitsrht-update-hook/webhooks.go @@ -134,6 +134,8 @@ func deliverWebhooks(subs []WebhookSubscription, continue } log.Println(runewidth.Truncate(string(respBody), 1024, "...")) + logger.Printf("Delivered webhook to %s (sub %d), got %d", + sub.Url, sub.Id, resp.StatusCode) var responseHeaders bytes.Buffer for name, values := range resp.Header { @@ -141,6 +143,7 @@ func deliverWebhooks(subs []WebhookSubscription, name, strings.Join(values, ", "))) } + delivery.ResponseStatus = resp.StatusCode delivery.ResponseHeaders = responseHeaders.String() delivery.Response = string(respBody)[:65535] deliveries = append(deliveries, delivery) -- 2.38.4