From 8125a44b098e850df7868daeb76655fe9dee363a Mon Sep 17 00:00:00 2001 From: samrabelachew Date: Mon, 16 Oct 2023 10:44:34 -0700 Subject: [PATCH] logging test (#720) --- server/neptune/temporalworker/server.go | 1 + server/neptune/workflows/internal/notifier/github.go | 8 ++++++++ .../neptune/workflows/internal/pr/revision/processor.go | 2 ++ server/neptune/workflows/internal/pr/revision/state.go | 1 + 4 files changed, 12 insertions(+) diff --git a/server/neptune/temporalworker/server.go b/server/neptune/temporalworker/server.go index a35c283e4..484435e49 100644 --- a/server/neptune/temporalworker/server.go +++ b/server/neptune/temporalworker/server.go @@ -276,6 +276,7 @@ func (s Server) Start() error { Interceptors: []interceptor.WorkerInterceptor{ temporal.NewWorkerInterceptor(), }, + EnableLoggingInReplay: true, }) prWorker.RegisterActivity(s.GithubActivities) prWorker.RegisterActivity(s.TerraformActivities) diff --git a/server/neptune/workflows/internal/notifier/github.go b/server/neptune/workflows/internal/notifier/github.go index 45a7cd081..1c851e025 100644 --- a/server/neptune/workflows/internal/notifier/github.go +++ b/server/neptune/workflows/internal/notifier/github.go @@ -57,6 +57,7 @@ func (c *GithubCheckRunCache) CreateOrUpdate(ctx workflow.Context, deploymentID // if we haven't created one, let's do so now if !ok { + workflow.GetLogger(ctx).Info(fmt.Sprintf("cache before create: %v", c.deploymentCheckRunCache)) resp, err := c.load(ctx, deploymentID, request) if err != nil { return 0, err @@ -66,17 +67,20 @@ func (c *GithubCheckRunCache) CreateOrUpdate(ctx workflow.Context, deploymentID if resp.ID != 0 { c.deploymentCheckRunCache[key] = resp.ID c.deleteIfCompleted(resp.Status, key) + workflow.GetLogger(ctx).Info(fmt.Sprintf("cache after create: %v", c.deploymentCheckRunCache)) } return resp.ID, nil } // update existing checks + workflow.GetLogger(ctx).Info(fmt.Sprintf("cache before update: %v", c.deploymentCheckRunCache)) resp, err := c.update(ctx, deploymentID, request, checkRunID) if err != nil { return 0, err } c.deleteIfCompleted(resp.Status, key) + workflow.GetLogger(ctx).Info(fmt.Sprintf("cache after create: %v", c.deploymentCheckRunCache)) return checkRunID, nil } @@ -102,7 +106,9 @@ func (c *GithubCheckRunCache) update(ctx workflow.Context, externalID string, re } var resp activities.UpdateCheckRunResponse + workflow.GetLogger(ctx).Info(fmt.Sprintf("executing update check run activity: %s %s", request.Title, request.Sha)) err := workflow.ExecuteActivity(ctx, c.activities.GithubUpdateCheckRun, updateCheckRunRequest).Get(ctx, &resp) + workflow.GetLogger(ctx).Info(fmt.Sprintf("update check run activity complete: %s %s", request.Title, request.Sha)) if err != nil { return resp, errors.Wrapf(err, "updating check run with id: %d", checkRunID) } @@ -122,7 +128,9 @@ func (c *GithubCheckRunCache) load(ctx workflow.Context, externalID string, requ } var resp activities.CreateCheckRunResponse + workflow.GetLogger(ctx).Info(fmt.Sprintf("executing create check run activity: %s %s", request.Title, request.Sha)) err := workflow.ExecuteActivity(ctx, c.activities.GithubCreateCheckRun, createCheckRunRequest).Get(ctx, &resp) + workflow.GetLogger(ctx).Info(fmt.Sprintf("create check run activity complete: %s %s", request.Title, request.Sha)) if err != nil { return resp, errors.Wrap(err, "creating check run") } diff --git a/server/neptune/workflows/internal/pr/revision/processor.go b/server/neptune/workflows/internal/pr/revision/processor.go index d4b4f9e62..28529cb7b 100644 --- a/server/neptune/workflows/internal/pr/revision/processor.go +++ b/server/neptune/workflows/internal/pr/revision/processor.go @@ -1,6 +1,7 @@ package revision import ( + "fmt" "github.com/google/uuid" metricNames "github.com/runatlantis/atlantis/server/metrics" internalContext "github.com/runatlantis/atlantis/server/neptune/context" @@ -147,6 +148,7 @@ func (p *Processor) awaitChildTerraformWorkflows(ctx workflow.Context, futures [ workflow.GetLogger(workflow.WithValue(ctx, internalContext.ErrKey, err)).Error("executing terraform workflow") return } + workflow.GetLogger(ctx).Info(fmt.Sprintf("child tf workflow ready: %s", resp.WorkflowState.ID)) results = append(results, resp) }) } diff --git a/server/neptune/workflows/internal/pr/revision/state.go b/server/neptune/workflows/internal/pr/revision/state.go index 633d7f15a..844bbbc43 100644 --- a/server/neptune/workflows/internal/pr/revision/state.go +++ b/server/neptune/workflows/internal/pr/revision/state.go @@ -46,6 +46,7 @@ func (s *StateReceiver) Notify(ctx workflow.Context, workflowState *state.Workfl workflow.GetLogger(ctx).Warn(fmt.Sprintf("skipping notifying root %s", workflowState.ID)) return } + workflow.GetLogger(ctx).Info(fmt.Sprintf("receiving state change signal: %s", rootInfo.Root.Name)) for _, notifier := range s.InternalNotifiers { if err := notifier.Notify(ctx, rootInfo.ToInternalInfo(), workflowState); err != nil {