ory / keto

The most scalable and customizable permission server on the market. Fix your slow or broken permission system with Google's proven "Zanzibar" approach. Supports ACL, RBAC, and more. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=keto
Apache License 2.0
4.84k stars 348 forks source link

0.2.2-sandbox+oryOS.10: Unable to initialize compiler: lstat /go: no such file or directory #73

Closed sevenlure closed 5 years ago

sevenlure commented 5 years ago

Describe the bug Version [0.2.2-sandbox+oryOS.10] keto serve => Unable to initialize compiler: lstat /go: no such file or directory

Version [v0.1.9-sandbox+oryOS.9] keto serve => work well

To Reproduce Steps to reproduce the behavior:

  1. Run keto serve
  2. See error: Unable to initialize compiler: lstat /go: no such file or directory

Version:

bensont1 commented 5 years ago

I have also run into this problem, same issue on 0.2.1-sandbox+oryOS.10.

aeneasr commented 5 years ago

What OS?

bensont1 commented 5 years ago

I’m runnning the Docker image from DockerHub. In my case, it doesn’t even specify which file is is not found.

The process immediately gets shutdown due to this error.

time="2019-01-07T20:28:40Z" level=info msg="Listening on https://:4466"
time="2019-01-07T20:28:40Z" level=fatal msg="Unable to gracefully shutdown HTTP(s) server because open : no such file or directory"
bensont1 commented 5 years ago

I think i found the issue, seems to be in this block on HTTPS server start. The certs are not actually set in the http.Server tls config

https://github.com/ory/keto/blob/ed7af3fa4e5d1d0d03b5366f4cf865a5b82ec293/cmd/server/serve.go#L126-L130

aeneasr commented 5 years ago

Are you running it with TLS configured or without?

bensont1 commented 5 years ago

I am running 0.2.2-sandbox+oryOS.10 with TLS configured using Path to cert and key.

aeneasr commented 5 years ago

Can you make sure that the paths are set correctly? Could you maybe show the env config?

bensont1 commented 5 years ago

They are set correctly, using HTTPS_TLS_CERT_PATH and HTTPS_TLS_KEY_PATH.

The tlsx package for tlsx.HTTPSCertificate() doesn't return tlsx.ErrNoCertificatesConfigured which would allow the above code to hit line 127. Instead nil is returned in err

From tlsx: https://github.com/ory/x/blob/8463556ef7762bd4f6dd94dd30da22cec10ac70a/tlsx/cert.go#L81

aeneasr commented 5 years ago

Right, the logic here seems to be messed up. TLSConfig should be nil in case of tlsx.ErrNoCertificatesConfigured and set if the error is nil.

sum2000 commented 5 years ago

@aeneasr I am facing the same issue on Mac. I am building from source and I pull in the src using go mod vendor. This script pulls in Keto source (.go files) to local vendor folder and I build using 'go build -mod=vendor'. The build is fine but when I run keto serve, I get the same error as OP. It has to do with go mod vendor because it does not pull the .rego files from git as they are non .go files. I manually added the rego folder on my local src copy inside ladon folder and everything was working fine. One solution could be adding a placeholder .go file inside the rego folder. I imagine this will force go mod vendor to download all the necessary code required to run keto serve

aeneasr commented 5 years ago

Ohhh, that's possible. Damn, any ideas how to fix that?

sum2000 commented 5 years ago

One solution could be adding a placeholder .go file inside the rego folder. I imagine this will force go mod vendor to download all the necessary code required to run keto serve. I tried forking latest master and running with proposed solution but I kept getting the resty import issues, I will try again today.

sum2000 commented 5 years ago

@aeneasr PR for the issue

sum2000 commented 5 years ago

Also, the DockerFile needs to be updated. You have to copy the rego folder into your docker release image here. Let me know if it needs further clarification.

aeneasr commented 5 years ago

Whoops, reopening because this is two issues in one

ingenieroariel commented 5 years ago

I got a similar error with yesterday's master:

Unable to initialize compiler: lstat /build: no such file or directory
aeneasr commented 5 years ago

This is probably caused by: https://github.com/ory/keto/pull/79#issuecomment-459759675

ingenieroariel commented 5 years ago

I have a nix derivation that reproduces the problem (while packaging ORY for NixOS).

https://github.com/piensa/nur-packages/blob/master/pkgs/keto/default.nix

aeneasr commented 5 years ago

Ok, it seems like there were several issues:

This has all been fixed now and is being merged with #84

aeneasr commented 5 years ago

0.2.3 is now on it's way where this should be solved