Skip to content

Commit

Permalink
remove debug logs (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
samrabelachew authored Apr 27, 2022
1 parent c799e08 commit a8f4853
Show file tree
Hide file tree
Showing 29 changed files with 13 additions and 121 deletions.
15 changes: 0 additions & 15 deletions server/controllers/events/events_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ func (e *VCSEventsController) Post(w http.ResponseWriter, r *http.Request) {
e.respond(w, logging.Debug, http.StatusBadRequest, "Ignoring request since not configured to support GitLab")
return
}
e.Logger.Debugf("handling GitLab post")
e.handleGitlabPost(w, r)
return
} else if r.Header.Get(bitbucketEventTypeHeader) != "" {
Expand All @@ -313,15 +312,13 @@ func (e *VCSEventsController) Post(w http.ResponseWriter, r *http.Request) {
e.respond(w, logging.Debug, http.StatusBadRequest, "Ignoring request since not configured to support Bitbucket Cloud")
return
}
e.Logger.Debugf("handling Bitbucket Cloud post")
e.handleBitbucketCloudPost(w, r)
return
} else if r.Header.Get(bitbucketServerRequestIDHeader) != "" {
if !e.supportsHost(models.BitbucketServer) {
e.respond(w, logging.Debug, http.StatusBadRequest, "Ignoring request since not configured to support Bitbucket Server")
return
}
e.Logger.Debugf("handling Bitbucket Server post")
e.handleBitbucketServerPost(w, r)
return
}
Expand All @@ -330,7 +327,6 @@ func (e *VCSEventsController) Post(w http.ResponseWriter, r *http.Request) {
e.respond(w, logging.Debug, http.StatusBadRequest, "Ignoring request since not configured to support AzureDevops")
return
}
e.Logger.Debugf("handling AzureDevops post")
e.handleAzureDevopsPost(w, r)
return
}
Expand All @@ -348,11 +344,9 @@ func (e *VCSEventsController) handleBitbucketCloudPost(w http.ResponseWriter, r
}
switch eventType {
case bitbucketcloud.PullCreatedHeader, bitbucketcloud.PullUpdatedHeader, bitbucketcloud.PullFulfilledHeader, bitbucketcloud.PullRejectedHeader:
e.Logger.Debugf("handling as pull request state changed event")
e.handleBitbucketCloudPullRequestEvent(w, eventType, body, reqID, r)
return
case bitbucketcloud.PullCommentCreatedHeader:
e.Logger.Debugf("handling as comment created event")
e.HandleBitbucketCloudCommentEvent(w, body, reqID, r)
return
default:
Expand Down Expand Up @@ -384,11 +378,9 @@ func (e *VCSEventsController) handleBitbucketServerPost(w http.ResponseWriter, r
}
switch eventType {
case bitbucketserver.PullCreatedHeader, bitbucketserver.PullMergedHeader, bitbucketserver.PullDeclinedHeader, bitbucketserver.PullDeletedHeader:
e.Logger.Debugf("handling as pull request state changed event")
e.handleBitbucketServerPullRequestEvent(w, eventType, body, reqID, r)
return
case bitbucketserver.PullCommentCreatedHeader:
e.Logger.Debugf("handling as comment created event")
e.HandleBitbucketServerCommentEvent(w, body, reqID, r)
return
default:
Expand All @@ -403,7 +395,6 @@ func (e *VCSEventsController) handleAzureDevopsPost(w http.ResponseWriter, r *ht
e.respond(w, logging.Warn, http.StatusUnauthorized, err.Error())
return
}
e.Logger.Debugf("request valid")

azuredevopsReqID := "Request-Id=" + r.Header.Get("Request-Id")
event, err := azuredevops.ParseWebHook(payload)
Expand All @@ -413,10 +404,8 @@ func (e *VCSEventsController) handleAzureDevopsPost(w http.ResponseWriter, r *ht
}
switch event.PayloadType {
case azuredevops.PullRequestCommentedEvent:
e.Logger.Debugf("handling as pull request commented event")
e.HandleAzureDevopsPullRequestCommentedEvent(w, event, azuredevopsReqID, r)
case azuredevops.PullRequestEvent:
e.Logger.Debugf("handling as pull request event")
e.HandleAzureDevopsPullRequestEvent(w, event, azuredevopsReqID, r)
default:
e.respond(w, logging.Debug, http.StatusOK, "Ignoring unsupported event: %v %s", event.PayloadType, azuredevopsReqID)
Expand Down Expand Up @@ -556,17 +545,13 @@ func (e *VCSEventsController) handleGitlabPost(w http.ResponseWriter, r *http.Re
e.respond(w, logging.Warn, http.StatusBadRequest, err.Error())
return
}
e.Logger.Debugf("request valid")

switch event := event.(type) {
case gitlab.MergeCommentEvent:
e.Logger.Debugf("handling as comment event")
e.HandleGitlabCommentEvent(w, event, r)
case gitlab.MergeEvent:
e.Logger.Debugf("handling as pull request event")
e.HandleGitlabMergeRequestEvent(w, event, r)
case gitlab.CommitCommentEvent:
e.Logger.Debugf("comments on commits are not supported, only comments on merge requests")
e.respond(w, logging.Debug, http.StatusOK, "Ignoring comment on commit event")
default:
e.respond(w, logging.Debug, http.StatusOK, "Ignoring unsupported event")
Expand Down
3 changes: 0 additions & 3 deletions server/controllers/github_app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (g *GithubAppController) ExchangeCode(w http.ResponseWriter, r *http.Reques
g.respond(w, logging.Debug, http.StatusOK, "Ignoring callback, missing code query parameter")
}

g.Logger.Debugf("Exchanging GitHub app code for app credentials")
creds := &vcs.GithubAnonymousCredentials{}

// TODO: unify this in a single inject.go file
Expand All @@ -72,8 +71,6 @@ func (g *GithubAppController) ExchangeCode(w http.ResponseWriter, r *http.Reques
return
}

g.Logger.Debugf("Found credentials for GitHub app %q with id %d", app.Name, app.ID)

err = templates.GithubAppSetupTemplate.Execute(w, templates.GithubSetupData{
Target: "",
Manifest: "",
Expand Down
2 changes: 0 additions & 2 deletions server/controllers/locks_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ func (l *LocksController) DeleteLock(w http.ResponseWriter, r *http.Request) {
if err = l.VCSClient.CreateComment(lock.Pull.BaseRepo, lock.Pull.Num, comment, ""); err != nil {
l.Logger.Warnf("failed commenting on pull request: %s", err)
}
} else {
l.Logger.Debugf("skipping commenting on pull request and deleting workspace because BaseRepo field is empty")
}
l.respond(w, logging.Info, http.StatusOK, "Deleted lock id %q", id)
}
Expand Down
22 changes: 1 addition & 21 deletions server/core/config/valid/global_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package valid

import (
"fmt"
"regexp"
"strings"

"github.com/graymeta/stow"
"github.com/graymeta/stow/s3"
version "github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/logging"
"regexp"
)

const MergeableApplyReq = "mergeable"
Expand Down Expand Up @@ -236,7 +234,6 @@ func (g GlobalCfg) PlatformModeEnabled() bool {
// MergeProjectCfg merges proj and rCfg with the global config to return a
// final config. It assumes that all configs have been validated.
func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, proj Project, rCfg RepoCfg) MergedProjectCfg {
log.Debugf("MergeProjectCfg started")
var applyReqs []string
var workflow Workflow
var pullRequestWorkflow Workflow
Expand All @@ -261,7 +258,6 @@ func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, pro
switch key {
case ApplyRequirementsKey:
if proj.ApplyRequirements != nil {
log.Debugf("overriding server-defined %s with repo settings: [%s]", ApplyRequirementsKey, strings.Join(proj.ApplyRequirements, ","))
applyReqs = proj.ApplyRequirements
}
case WorkflowKey:
Expand All @@ -279,7 +275,6 @@ func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, pro
if w, ok := rCfg.Workflows[name]; allowCustomWorkflows && ok {
workflow = w
}
log.Debugf("overriding server-defined %s with repo-specified workflow: %q", WorkflowKey, workflow.Name)
}
case PullRequestWorkflowKey:
if proj.PullRequestWorkflowName != nil {
Expand All @@ -288,28 +283,14 @@ func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, pro
pullRequestWorkflow = w
}
}

log.Debugf("overriding server-defined %s with repo-specified pull_request_workflow: %q", PullRequestWorkflowKey, workflow.Name)
case DeploymentWorkflowKey:
if proj.DeploymentWorkflowName != nil {
name := *proj.DeploymentWorkflowName
if w, ok := g.DeploymentWorkflows[name]; ok {
deploymentWorkflow = w
}
}

log.Debugf("overriding server-defined %s with repo-specified deployment_workflow: %q", DeploymentWorkflowKey, workflow.Name)
}
log.Debugf("MergeProjectCfg completed")
}

if g.PlatformModeEnabled() {
log.Debugf("final settings: %s: %s, %s: %s, %s: %s",
WorkflowKey, workflow.Name, DeploymentWorkflowKey, deploymentWorkflow.Name, PullRequestWorkflowKey, pullRequestWorkflow.Name)

} else {
log.Debugf("final settings: %s: [%s], %s: %s",
ApplyRequirementsKey, strings.Join(applyReqs, ","), WorkflowKey, workflow.Name)
}

return MergedProjectCfg{
Expand All @@ -331,7 +312,6 @@ func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, pro
// DefaultProjCfg returns the default project config for all projects under the
// repo with id repoID. It is used when there is no repo config.
func (g GlobalCfg) DefaultProjCfg(log logging.SimpleLogging, repoID string, repoRelDir string, workspace string) MergedProjectCfg {
log.Debugf("building config based on server-side config")
repo := g.foldMatchingRepos(repoID)

mrgPrj := MergedProjectCfg{
Expand Down
6 changes: 0 additions & 6 deletions server/core/runtime/apply_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func (a *ApplyStepRunner) runRemoteApply(
}

// Start the async command execution.
prjCtx.Log.Debugf("starting async tf remote operation")
inCh := make(chan string)
defer close(inCh)
outCh := a.AsyncTFExec.RunCommandAsyncWithInput(ctx, prjCtx, filepath.Clean(path), applyArgs, envs, tfVersion, prjCtx.Workspace, inCh)
Expand All @@ -156,16 +155,13 @@ func (a *ApplyStepRunner) runRemoteApply(
nextLineIsRunURL = true
} else if nextLineIsRunURL {
runURL = strings.TrimSpace(line.Line)
prjCtx.Log.Debugf("remote run url found, updating commit status")
updateStatusF(models.PendingCommitStatus, runURL)
nextLineIsRunURL = false
}

// If the plan is complete and it's waiting for us to verify the apply,
// check if the plan is the same and if so, input "yes".
if a.atConfirmApplyPrompt(lines) {
prjCtx.Log.Debugf("remote apply is waiting for confirmation")

// Check if the plan is as expected.
planChangedErr = a.remotePlanChanged(string(planfileBytes), strings.Join(lines, "\n"), tfVersion)
if planChangedErr != nil {
Expand All @@ -177,12 +173,10 @@ func (a *ApplyStepRunner) runRemoteApply(
continue
}

prjCtx.Log.Debugf("plan generated during apply matches expected plan, continuing")
inCh <- "yes\n"
}
}

prjCtx.Log.Debugf("async tf remote operation complete")
output := strings.Join(lines, "\n")
if planChangedErr != nil {
updateStatusF(models.FailedCommitStatus, runURL)
Expand Down
1 change: 0 additions & 1 deletion server/core/runtime/init_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func (i *InitStepRunner) Run(ctx context.Context, prjCtx command.ProjectContext,
// delete it as it probably has been created by a previous run of
// terraform init
if common.FileExists(terraformLockfilePath) && !terraformLockFileTracked {
prjCtx.Log.Debugf("Deleting `%s` that was generated by previous terraform init", terraformLockfilePath)
delErr := os.Remove(terraformLockfilePath)
if delErr != nil {
prjCtx.Log.Infof("Error Deleting `%s`", lockFileName)
Expand Down
4 changes: 0 additions & 4 deletions server/core/runtime/plan_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func (p *PlanStepRunner) Run(ctx context.Context, prjCtx command.ProjectContext,
planCmd := p.buildPlanCmd(prjCtx, extraArgs, path, tfVersion, planFile)
output, err := p.TerraformExecutor.RunCommandWithVersion(ctx, prjCtx, filepath.Clean(path), planCmd, envs, tfVersion, prjCtx.Workspace)
if p.isRemoteOpsErrorf(output, err) {
prjCtx.Log.Debugf("detected that this project is using TFE remote ops")
return p.remotePlan(ctx, prjCtx, extraArgs, path, tfVersion, planFile, envs)
}
if err != nil {
Expand Down Expand Up @@ -255,7 +254,6 @@ func (p *PlanStepRunner) runRemotePlan(
}

// Start the async command execution.
prjCtx.Log.Debugf("starting async tf remote operation")
outCh := p.AsyncTFExec.RunCommandAsync(ctx, prjCtx, filepath.Clean(path), cmdArgs, envs, tfVersion, prjCtx.Workspace)
var lines []string
nextLineIsRunURL := false
Expand All @@ -275,13 +273,11 @@ func (p *PlanStepRunner) runRemotePlan(
nextLineIsRunURL = true
} else if nextLineIsRunURL {
runURL = strings.TrimSpace(line.Line)
prjCtx.Log.Debugf("remote run url found, updating commit status")
updateStatusF(models.PendingCommitStatus, runURL)
nextLineIsRunURL = false
}
}

prjCtx.Log.Debugf("async tf remote operation complete")
output := strings.Join(lines, "\n")
if err != nil {
updateStatusF(models.FailedCommitStatus, runURL)
Expand Down
4 changes: 0 additions & 4 deletions server/core/runtime/plan_type_step_runner_delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ import (
type NullRunner struct{}

func (p NullRunner) Run(ctx context.Context, prjCtx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
prjCtx.Log.Debugf("runner not configured for plan type")

return "", nil
}

// RemoteBackendUnsupportedRunner is a runner that is responsible for outputting that the remote backend is unsupported
type RemoteBackendUnsupportedRunner struct{}

func (p RemoteBackendUnsupportedRunner) Run(ctx context.Context, cmdCtx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
cmdCtx.Log.Debugf("runner not configured for remote backend")

return "Remote backend is unsupported for this step.", nil
}

Expand Down
1 change: 0 additions & 1 deletion server/core/runtime/policy/conftest_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func NewConfTestExecutorWorkflow(log logging.SimpleLogging, versionRootDir strin
func (c *ConfTestExecutorWorkflow) Run(ctx context.Context, prjCtx command.ProjectContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) (string, error) {
policyArgs := []Arg{}
policySetNames := []string{}
prjCtx.Log.Debugf("policy sets, %s ", prjCtx.PolicySets)
for _, policySet := range prjCtx.PolicySets.PolicySets {
path, err := c.SourceResolver.Resolve(policySet)

Expand Down
4 changes: 2 additions & 2 deletions server/core/runtime/run_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (r *RunStepRunner) Run(ctx context.Context, prjCtx command.ProjectContext,
err := r.TerraformExecutor.EnsureVersion(prjCtx.Log, tfVersion)
if err != nil {
err = fmt.Errorf("%s: Downloading terraform Version %s", err, tfVersion.String())
prjCtx.Log.Debugf("error: %s", err)
prjCtx.Log.Errorf("error: %s", err)
return "", err
}

Expand Down Expand Up @@ -71,7 +71,7 @@ func (r *RunStepRunner) Run(ctx context.Context, prjCtx command.ProjectContext,

if err != nil {
err = fmt.Errorf("%s: running %q in %q: \n%s", err, command, path, out)
prjCtx.Log.Debugf("error: %s", err)
prjCtx.Log.Errorf("error: %s", err)
return "", err
}
prjCtx.Log.Infof("successfully ran %q in %q", command, path)
Expand Down
2 changes: 0 additions & 2 deletions server/core/terraform/async_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func (c *AsyncClient) RunCommandAsyncWithInput(ctx context.Context, prjCtx comma
}
cmd.Env = envVars

prjCtx.Log.Debugf("starting %q in %q", cmd.String(), path)
err = cmd.Start()
if err != nil {
err = errors.Wrapf(err, "running %q in %q", cmd.String(), path)
Expand All @@ -83,7 +82,6 @@ func (c *AsyncClient) RunCommandAsyncWithInput(ctx context.Context, prjCtx comma
// This function will exit when inCh is closed which we do in our defer.
go func() {
for line := range input {
prjCtx.Log.Debugf("writing %q to remote command's stdin", line)
_, err := io.WriteString(stdin, line)
if err != nil {
prjCtx.Log.Errorf(errors.Wrapf(err, "writing %q to process", line).Error())
Expand Down
1 change: 0 additions & 1 deletion server/events/approve_policies_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (a *ApprovePoliciesCommandRunner) Run(ctx *command.Context, cmd *command.Co
// If there were no projects modified, we set successful commit statuses
// with 0/0 projects approve_policies successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debugf("setting VCS status to success with no projects found")
if err := a.commitStatusUpdater.UpdateCombinedCount(context.TODO(), ctx.Pull.BaseRepo, ctx.Pull, models.SuccessCommitStatus, command.PolicyCheck, 0, 0); err != nil {
ctx.Log.Warnf("unable to update commit status: %s", err)
}
Expand Down
2 changes: 0 additions & 2 deletions server/events/db_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ func (c *DBUpdater) updateDB(ctx *command.Context, pull models.PullRequest, resu
var filtered []command.ProjectResult
for _, r := range results {
if _, ok := r.Error.(DirNotExistErr); ok {
ctx.Log.Debugf("ignoring error result from project at dir %q workspace %q because it is dir not exist error", r.RepoRelDir, r.Workspace)
continue
}
filtered = append(filtered, r)
}
ctx.Log.Debugf("updating DB with pull results")
return c.DB.UpdatePullWithResults(pull, filtered)
}
2 changes: 0 additions & 2 deletions server/events/delete_lock_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (l *DefaultDeleteLockCommand) DeleteLocksByPull(repoFullName string, pullNu
return numLocks, err
}
if numLocks == 0 {
l.Logger.Debugf("No locks found for pull")
return numLocks, nil
}

Expand All @@ -63,7 +62,6 @@ func (l *DefaultDeleteLockCommand) deleteWorkingDir(lock models.ProjectLock) {
// installations of Atlantis will have locks in their DB that do not have
// this field on PullRequest. We skip deleting the working dir in this case.
if lock.Pull.BaseRepo == (models.Repo{}) {
l.Logger.Debugf("Not deleting the working dir.")
return
}
unlock, err := l.WorkingDirLocker.TryLock(lock.Pull.BaseRepo.FullName, lock.Pull.Num, lock.Workspace)
Expand Down
1 change: 0 additions & 1 deletion server/events/git_cred_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func WriteGitCreds(gitUser string, gitToken string, gitHostname string, home str
return err
}
if hasLine {
logger.Debugf("git credentials file has expected contents, not modifying")
return nil
}

Expand Down
1 change: 0 additions & 1 deletion server/events/plan_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func (p *PlanCommandRunner) runAutoplan(ctx *command.Context) {
// If there were no projects modified, we set successful commit statuses
// with 0/0 projects planned/policy_checked/applied successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debugf("setting VCS status to success with no projects found")
if err := p.commitStatusUpdater.UpdateCombinedCount(context.TODO(), baseRepo, pull, models.SuccessCommitStatus, command.Plan, 0, 0); err != nil {
ctx.Log.Warnf("unable to update commit status: %s", err)
}
Expand Down
1 change: 0 additions & 1 deletion server/events/policy_check_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func (p *PolicyCheckCommandRunner) Run(ctx *command.Context, cmds []command.Proj
// If there were no projects modified, we set successful commit statuses
// with 0/0 projects policy_checked successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debugf("setting VCS status to success with no projects found")
if err := p.commitStatusUpdater.UpdateCombinedCount(context.TODO(), ctx.Pull.BaseRepo, ctx.Pull, models.SuccessCommitStatus, command.PolicyCheck, 0, 0); err != nil {
ctx.Log.Warnf("unable to update commit status: %s", err)
}
Expand Down
Loading

0 comments on commit a8f4853

Please sign in to comment.