mirror of
https://github.com/acme-dns/acme-dns.git
synced 2026-04-27 04:45:48 +03:00
[GH-ISSUE #93] PostgreSQL go driver #38
Labels
No labels
Documentation
Documentation
bug
enhancement
feature request
feature request
help wanted
pull-request
question
security
security
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/acme-dns#38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sh511 on GitHub (Jul 2, 2018).
Original GitHub issue: https://github.com/acme-dns/acme-dns/issues/93
I set up acme-dns as a service with an unprivileged acme-dns user. I edited the config file to use PostgreSQL and downloaded the pq driver for go. However, being new to go, I am at a lost about where to place the pq package. The command "go get githup/com/lib/pq" installs the river in ~/go by default but since acme-dns is shell-less, where does the package should be installed. The recommendation is to set the $GOPATH variable but I believe that this would not work for acme-dns.
The messages log file (on CENTOS) shows:
acme-dns: time="2018-06-27T22:36:18-04:00" level=error msg="Could not open database [sql: unknown driver "" (forgotten import?)]"
For go neophytes, an addition to the documentation would be greatly appreciated.
@joohoi commented on GitHub (Jul 3, 2018):
The PgSQL driver is baked in the acme-dns itself, so there's no need to install your own. Your issue seems to be that the database engine option in the config file seems to be empty (or commented out):
It should be:
@sh511 commented on GitHub (Jul 4, 2018):
Thank you for pointing out that the driver is embedded in the binary. I forgot to check under the vendor folder.
Regarding my config.cfg file I do have engine="postgres" specified. The file is in /etc/acme-dns and owned by acme-dns:acme-dns as per service file.
I get the same error if I run acme-dns directly
INFO[0000] Using config file file=/etc/acme-dns/config.cfg
ERRO[0000] Could not open database [sql: unknown driver "" (forgotten import?)]
Actually it does not matter what string I use in the config file, even
engine = "nonsense"
I get the same error unknown driver "" (i.e. empty string).
Completely confused ...
@joohoi commented on GitHub (Jul 4, 2018):
The error message implies that the
enginevalue within[database]block couldn't be read for some reason. I wonder if you might have commented the[database]block out or something? Anyway acme-dns is unable to read the value ofengineconfiguration variable for reason or another.@sh511 commented on GitHub (Jul 6, 2018):
After learning how to get around in GOLANG, I tracked down the issue. I had left out the quotes around the ip parameters. Since util.go does not check for errors in toml.DecodeFile, because it "Practically never errors" 8-), the error was not caught and no parameters was returned in Config then resulting in the "" driver error. So I would suggest not to assume that users will not make an error while editing the config file.
Also, if the permissions are not set properly on the config file, the os.Stat check in fileExists will not flag a file that exists but cannot be read. Using os.Open and checking for an error is more reliable (then closing the file is there is no error). There might be a more GOLANG way of doing the same.
@joohoi commented on GitHub (Jul 6, 2018):
Ah, most awesome that you got it to work!
Burn! I'm very sorry that the sloppy error handling did bite you :/
This definitely is a bug, and should get fixed. As you dug into the code already, would you like to submit a PR to fix the issue? If not, I'll do it.
@sh511 commented on GitHub (Jul 14, 2018):
Finally got around submitting a PR. Just did a bit more testing not to introduce new features. I think that the documentation should direct the user to always place the configuration file in /etc/acme-dns/ if running as a service and non-privileged user acme-dns. I am not sure what the "current" directory is for a service.
Also regarding the configuration file, I would suggest including the ip:port option and not only the :port option for listen, e.g.
Edit the following line to the ip address that acme-dns is listening to
#listen = "198.51.100.1:53"
If acme-dns is listening to all addresses on the server, use
listen = ":53"
Since I am running acme-dns along the "main" DNS server, I needed to specify separate IP addresses to listen to. Rather obvious in retrospect but a note in the configuration file would be useful.
@LinuxCuba commented on GitHub (Aug 9, 2018):
This is my conf referent to database
[database]
Database engine to use, sqlite3 or postgres
engine = "sqlite3"
Connection string, filename for sqlite3 and postgres://$username:$password@$host/$db_name for postgres
connection = "/var/lib/acme-dns/acme-dns.db"
The problem is persistent
@joohoi commented on GitHub (Aug 12, 2018):
The error messages should be a lot better now when #99 and #101 have landed to reveal the underlying issue.