Skip to content

Commit

Permalink
Merge pull request #6 from harness/disneydebugging
Browse files Browse the repository at this point in the history
Bug fixes.
  • Loading branch information
Xun He authored Dec 9, 2022
2 parents 6632c50 + 907a216 commit 9818c13
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
32 changes: 28 additions & 4 deletions handler/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ import (
"github.com/harness/harness-docker-runner/engine/docker"
"github.com/harness/harness-docker-runner/engine/spec"
"github.com/harness/harness-docker-runner/executor"
"github.com/harness/harness-docker-runner/livelog"
"github.com/harness/harness-docker-runner/logger"
"github.com/harness/harness-docker-runner/pipeline"
prruntime "github.com/harness/harness-docker-runner/pipeline/runtime"

"github.com/sirupsen/logrus"
)

// random generator function
Expand Down Expand Up @@ -56,6 +59,28 @@ func HandleSetup() http.HandlerFunc {
// s.LogConfig.URL = "http://localhost:8079"
state.Set(s.Volumes, s.Secrets, s.LogConfig, s.TIConfig, s.SetupRequestConfig.Network.ID)

log := logrus.New()
var logr *logrus.Entry
if s.LogConfig.URL == "" {
log.Out = os.Stdout
} else {
client := state.GetLogStreamClient()
wc := livelog.New(client, s.LogKey, id, nil)
defer func() {
if err := wc.Close(); err != nil {
logrus.WithError(err).Debugln("failed to close log stream")
}
}()

log.Out = wc
log.SetLevel(logrus.TraceLevel)
}
logr = log.WithField("id", s.ID).
WithField("correlation_id", s.CorrelationID)

logr.Traceln("starting setup execution")
logger.FromRequest(r).Traceln("starting the setup process")

if s.MountDockerSocket == nil || *s.MountDockerSocket { // required to support m1 where docker isn't installed.
s.Volumes = append(s.Volumes, getDockerSockVolume())
}
Expand Down Expand Up @@ -89,8 +114,6 @@ func HandleSetup() http.HandlerFunc {
return
}

logger.FromRequest(r).Traceln("starting the setup process")

if err := engine.Setup(r.Context(), cfg); err != nil {
logger.FromRequest(r).WithError(err).
WithField("latency", time.Since(st)).
Expand All @@ -101,13 +124,14 @@ func HandleSetup() http.HandlerFunc {
return
}

logger.FromRequest(r).Traceln("completed the setup process")

WriteJSON(w, api.SetupResponse{IPAddress: "127.0.0.1"}, http.StatusOK)
logger.FromRequest(r).
WithField("latency", time.Since(st)).
WithField("time", time.Now().Format(time.RFC3339)).
Infoln("api: successfully completed the stage setup")

logger.FromRequest(r).Traceln("completed the setup process")
logr.Traceln("completed the setup process")
}
}

Expand Down
3 changes: 2 additions & 1 deletion handler/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func HandleStartStep() http.HandlerFunc {

pollResp, err := stageData.StepExecutor.PollStep(ctx, &api.PollStepRequest{ID: s.ID})
logger.FromRequest(r).WithField("stage_id", s.StageRuntimeID).
WithField("step_id", s.ID).Traceln("received polling response")
WithField("step_id", s.ID).WithField("poll_response", pollResp).
Traceln("received polling response")
if err != nil {
WriteJSON(w, convert(err), http.StatusOK)
return
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (s *Server) Start(ctx context.Context) error {
logrus.Infof("Runner version: %s", version.Version)

var tlsConfig *tls.Config
logrus.Infof("Runner version: %s", version.Version)
if s.Insecure {
tlsConfig = nil
logrus.Warnln("RUNNING IN INSECURE MODE")
Expand Down

0 comments on commit 9818c13

Please sign in to comment.