cresta / atlantis-drift-detection

Detect terraform drift in atlantis
Apache License 2.0
60 stars 6 forks source link

/0/default: no such file or directory #28

Open jamengual opened 1 year ago

jamengual commented 1 year ago

For some reason when the github action run it tries to find the PR 0 on the workspace directory in the atlantis server, if I create the dir manually it seems to work but I do not know if this is an atlantis issue or the drifter action needs to send more data to the API?

this is the error:

{"level":"debug","ts":"2023-01-06T23:40:19.860-0800","caller":"server/middleware.go:45","msg":"POST /api/plan – from [::1]:59352","json":{}}
{"level":"error","ts":"2023-01-06T23:40:20.317-0800","caller":"events/instrumented_project_command_builder.go:66","msg":"Error building plan commands: checking if workspace exists: stat /Users/pepe.amengual/.atlantis/repos/jamengual/atlantmos/0/default: no such file or directory","json":{},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandBuilder).buildAndEmitStats\n\t/Users/pepe.amengual/github/atlantis/server/events/instrumented_project_command_builder.go:66\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandBuilder).BuildPlanCommands\n\t/Users/pepe.amengual/github/atlantis/server/events/instrumented_project_command_builder.go:35\ngithub.com/runatlantis/atlantis/server/controllers.(*APIRequest).getCommands\n\t/Users/pepe.amengual/github/atlantis/server/controllers/api_controller.go:64\ngithub.com/runatlantis/atlantis/server/controllers.(*APIController).apiPlan\n\t/Users/pepe.amengual/github/atlantis/server/controllers/api_controller.go:145\ngithub.com/runatlantis/atlantis/server/controllers.(*APIController).Plan\n\t/Users/pepe.amengual/github/atlantis/server/controllers/api_controller.go:90\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/Cellar/go/1.19.3/libexec/src/net/http/server.go:2109\ngithub.com/gorilla/mux.(*Router).ServeHTTP\n\t/Users/pepe.amengual/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210\ngithub.com/urfave/negroni/v3.Wrap.func1\n\t/Users/pepe.amengual/go/pkg/mod/github.com/urfave/negroni/v3@v3.0.0/negroni.go:59\ngithub.com/urfave/negroni/v3.HandlerFunc.ServeHTTP\n\t/Users/pepe.amengual/go/pkg/mod/github.com/urfave/negroni/v3@v3.0.0/negroni.go:33\ngithub.com/urfave/negroni/v3.middleware.ServeHTTP\n\t/Users/pepe.amengual/go/pkg/mod/github.com/urfave/negroni/v3@v3.0.0/negroni.go:51\ngithub.com/runatlantis/atlantis/server.(*RequestLogger).ServeHTTP\n\t/Users/pepe.amengual/github/atlantis/server/middleware.go:70\ngithub.com/urfave/negroni/v3.middleware.ServeHTTP\n\t/Users/pepe.amengual/go/pkg/mod/github.com/urfave/negroni/v3@v3.0.0/negroni.go:51\ngithub.com/urfave/negroni/v3.(*Recovery).ServeHTTP\n\t/Users/pepe.amengual/go/pkg/mod/github.com/urfave/negroni/v3@v3.0.0/recovery.go:210\ngithub.com/urfave/negroni/v3.middleware.ServeHTTP\n\t/Users/pepe.amengual/go/pkg/mod/github.com/urfave/negroni/v3@v3.0.0/negroni.go:51\ngithub.com/urfave/negroni/v3.(*Negroni).ServeHTTP\n\t/Users/pepe.amengual/go/pkg/mod/github.com/urfave/negroni/v3@v3.0.0/negroni.go:111\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/Cellar/go/1.19.3/libexec/src/net/http/server.go:2947\nnet/http.(*conn).serve\n\t/usr/local/Cellar/go/1.19.3/libexec/src/net/http/server.go:1991"}
{"level":"debug","ts":"2023-01-06T23:40:20.320-0800","caller":"metrics/debug.go:52","msg":"timer","json":{"name":"atlantis.builder.execution_time","value":0.004596752,"tags":{},"type":"timer"}}
jamengual commented 1 year ago

A Pr must exist in order to plan so maybe my problem is that the name: Force a terraform PR action in the README needs to run first to create a PR what then the drifter uses to run plan against? but if that was the case I do not see a reference of a PR number on the drifter code.

Please help me to understand the sequence of events, or if I need additional configs.

Thanks.

jamengual commented 1 year ago

ok, so I managed to implement this after fixing a few bugs. There is still a bug on the API in Atlantis that needs to be addressed to make this more usable which is related to no such file or directory, how did you workaround it?

for reference: https://github.com/runatlantis/atlantis/issues/2949

zen commented 9 months ago

@jamengual did you manage to actually workaround this? It seems to be serious blocker for this project's functionality

jamengual commented 9 months ago

There is a PR in flight with an attempt to fix this but it might not be the best approach. We are working on a more core solution to locks and workspaces in general.

The workaround for me was to create the dir semi-automatically.

cep21 commented 4 months ago

I'll see if something changed. /0 used to work as an acceptable default. The main problem I was trying to solve was that I wasn't sure what number to use when I make a plan so I used a PR number that I knew was safe.