8000 Getting an auto migrate error · Issue #16 · wenerme/coredns-pdsql · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Getting an auto migrate error #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related ema 8000 ils.

Already on GitHub? Sign in to your account

Open
BrandesEric opened this issue May 19, 2025 · 3 comments
Open

Getting an auto migrate error #16

BrandesEric opened this issue May 19, 2025 · 3 comments

Comments

@BrandesEric
Copy link

This appears related to the change made three weeks ago?

Image

This is an entirely empty DB. Should i pre-create the schema?

@BrandesEric
Copy link
Author

FYI changing to this Go Sqlite client fixed my issue: pdsql_sqlite:github.com/glebarez/sqlite

I gotta say, the docs for this plugin are woefully out of date. The model contains columns I don't see referenced in examples anywhere either - are they even used? How usable is this plugin for production workflows?

@bodo-hugo-barwich
Copy link
Contributor

Thank you for your interest in the project and for bringing this issue to attention.

As far as I understood was the initial objective of this development is to make CoreDNS a drop-in replacement for PowerDNS backends.

But I think your request is valid that it should not be required to have a PowerDNS installed and set up in order to use this.
In this sense the plugin has to be compatible with PowerDNS and also create a database that is compatible with it.

I tested it with the a PostgreSQL database as described at:
PowerDNS PostgreSQL backend structure
To be fully compatible the GORM model certainly needs some extensions although they are not used for name resolution but the pdnsutil tool requires them.

I checked the zones with pdnsutil version 4.9.2:

/ # pdnsutil --version
pdnsutil 4.9.2
/ # pdnsutil check-all-zones
Checked 8 records of 'sub.coredns-pdsql.local', 0 errors, 0 warnings.
Checked 6 records of 'coredns-devel.local', 0 errors, 0 warnings.
[Warning] 'coredns-pdsql.local|MX has a target (mail.coredns-pdsql.local) that is a CNAME.
Checked 12 records of 'coredns-pdsql.local', 0 errors, 1 warnings.
Checked 3 zones, 0 had errors.
/ # pdnsutil list-zone coredns-pdsql.local
$ORIGIN .
coredns-pdsql.local	3600	IN	A	172.53.0.7
coredns-pdsql.local	3600	IN	MX	10 mail.coredns-pdsql.local.
coredns-pdsql.local	3600	IN	NS	ns.coredns-pdsql.local.
coredns-pdsql.local	84600	IN	SOA	ns.coredns-pdsql.local. admin.coredns-pdsql.local. 2025022201 3600 1800 84600 3600
mail.coredns-pdsql.local	3600	IN	CNAME	postfix.coredns-pdsql.local.
ns.coredns-pdsql.local	3600	IN	A	172.53.0.2
postfix.coredns-pdsql.local	3600	IN	A	172.53.0.6
sub.coredns-pdsql.local	84600	IN	NS	ns.coredns-pdsql.local.
web.coredns-pdsql.local	3600	IN	A	172.53.0.7
www.coredns-pdsql.local	3600	IN	CNAME	www1.coredns-pdsql.local.
www1.coredns-pdsql.local	3600	IN	CNAME	web.coredns-pdsql.local.
/ # pdnsutil list-zone sub.coredns-pdsql.local
$ORIGIN .
postfix.sub.coredns-pdsql.local	3600	IN	A	172.53.1.6
sub.coredns-pdsql.local	3600	IN	A	172.53.1.7
sub.coredns-pdsql.local	3600	IN	MX	10 mail.coredns-pdsql.local.
sub.coredns-pdsql.local	3600	IN	NS	ns.coredns-pdsql.local.
sub.coredns-pdsql.local	84600	IN	SOA	ns.coredns-pdsql.local. admin.coredns-pdsql.local. 2025022201 3600 1800 84600 3600
web.sub.coredns-pdsql.local	3600	IN	A	172.53.1.7
www.sub.coredns-pdsql.local	3600	IN	CNAME	www1.sub.coredns-pdsql.local.
www1.sub.coredns-pdsql.local	3600	IN	CNAME	web.sub.coredns-pdsql.local.

So, the zones used with PowerDNS will also work with CoreDNS using this plugin.

Still the capability for creating compatible databases with CoreDNS needs to be improved and tested.

@wenerme

@bodo-hugo-barwich
Copy link
Contributor
bodo-hugo-barwich commented May 23, 2025

I tested the initial database setup with a Corefile like:

coredns-sqlite.local {
	pdsql sqlite3 /var/lib/coredns/data/coredns-sqlite.db {
		debug db
        	auto-migrate
	}

	whoami
	log
	errors
}

coredns-postgres.local {
	pdsql postgres "host=db_postgres dbname=coredns user=coredns password=coredns.secret sslmode=disable" {
		debug db
        	auto-migrate
	}

	whoami
	log
	errors
}

coredns-mysql.local {
	pdsql mysql "coredns:coredns.secret@tcp(db_mysql:3306)/coredns?charset=utf8mb4&parseTime=True&loc=Local" {
		debug db
        	auto-migrate
	}

	whoami
	log
	errors
}

which then should create 3 new zones with the SQLite and MariaDB databases created but empty:

  • coredns-sqlite.local
  • coredns-postgres.local
  • coredns-mysql.local

Unfortunately I could not reproduce the error.

The initial database creation runs smooth without errors creating a new database with just the bare minimum on data which CoreDNS needs to work.

coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104
coredns_dns  | [1.244ms] [rows:-] SELECT DATABASE()
coredns_dns  | 
coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104
coredns_dns  | [31.972ms] [rows:1] SELECT SCHEMA_NAME from Information_schema.SCHEMATA where SCHEMA_NAME LIKE 'coredns%' ORDER BY SCHEMA_NAME='coredns' DESC,SCHEMA_NAME limit 1
coredns_dns  | 
coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104
coredns_dns  | [1.142ms] [rows:-] SELECT count(*) FROM information_schema.tables WHERE table_schema = 'coredns' AND table_name = 'domains' AND table_type = 'BASE TABLE'
coredns_dns  | 
coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104 SLOW SQL >= 200ms
coredns_dns  | [294.477ms] [rows:0] CREATE TABLE `domains` (`id` bigint unsigned AUTO_INCREMENT,`name` varchar(255) NOT NULL,`master` varchar(128),`last_check` bigint,`type` varchar(6) NOT NULL,`notified_serial` bigint,`account` varchar(40),PRIMARY KEY (`id`))
coredns_dns  | 
coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104
coredns_dns  | [0.357ms] [rows:-] SELECT DATABASE()
coredns_dns  | 
coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104
coredns_dns  | [1.446ms] [rows:1] SELECT SCHEMA_NAME from Information_schema.SCHEMATA where SCHEMA_NAME LIKE 'coredns%' ORDER BY SCHEMA_NAME='coredns' DESC,SCHEMA_NAME limit 1
coredns_dns  | 
coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104
coredns_dns  | [1.139ms] [rows:-] SELECT count(*) FROM information_schema.tables WHERE table_schema = 'coredns' AND table_name = 'records' AND table_type = 'BASE TABLE'
coredns_dns  | 
coredns_dns  | 2025/05/23 12:05:47 /usr/local/go/src/pdsql/setup.go:104 SLOW SQL >= 200ms
coredns_dns  | [297.784ms] [rows:0] CREATE TABLE `records` (`id` bigint unsigned AUTO_INCREMENT,`domain_id` bigint unsigned,`name` varchar(255) NOT NULL,`type` varchar(10),`content` text,`ttl` int unsigned,`prio` bigint,`change_date` bigint,`disabled` boolean,PRIMARY KEY (`id`))
coredns_dns  | .:53
coredns_dns  | coredns-mysql.local.:53
coredns_dns  | coredns-postgres.local.:53
coredns_dns  | coredns-sqlite.local.:53
coredns_dns  | CoreDNS-1.12.0
coredns_dns  | linux/amd64, go1.23.6, 
MariaDB [coredns]> show tables;
+-------------------+
| Tables_in_coredns |
+-------------------+
| domains           |
| records           |
+-------------------+
2 rows in set (0.001 sec)

MariaDB [coredns]> show create table domains\G
*************************** 1. row ***************************
       Table: domains
Create Table: CREATE TABLE `domains` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `master` varchar(128) DEFAULT NULL,
  `last_check` bigint(20) DEFAULT NULL,
  `type` varchar(6) NOT NULL,
  `notified_serial` bigint(20) DEFAULT NULL,
  `account` varchar(40) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
1 row in set (0.000 sec)

MariaDB [coredns]> show create table records\G
*************************** 1. row ***************************
       Table: records
Create Table: CREATE TABLE `records` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `domain_id` bigint(20) unsigned DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `type` varchar(10) DEFAULT NULL,
  `content` text DEFAULT NULL,
  `ttl` int(10) unsigned DEFAULT NULL,
  `prio` bigint(20) DEFAULT NULL,
  `change_date` bigint(20) DEFAULT NULL,
  `disabled` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
1 row in set (0.000 sec)
$ sqlite3 dns/data/coredns-sqlite.db
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.
sqlite> SELECT name FROM sqlite_master WHERE type='table';
domains
sqlite_sequence
records
sqlite> .tables
domains  records
sqlite> .schema domains
CREATE TABLE `domains` (`id` integer PRIMARY KEY AUTOINCREMENT,`name` varchar(255) NOT NULL,`master` varchar(128),`last_check` integer,`type` varchar(6) NOT NULL,`notified_serial` integer,`account` varchar(40));
sqlite> .schema records
CREATE TABLE `records` (`id` integer PRIMARY KEY AUTOINCREMENT,`domain_id` integer,`name` varchar(255) NOT NULL,`type` varchar(10),`content` text,`ttl` integer,`prio` integer,`change_date` integer,`disabled` numeric);
sqlite> PRAGMA table_info(domains);
0|id|integer|0||1
1|name|varchar(255)|1||0
2|master|varchar(128)|0||0
3|last_check|integer|0||0
4|type|varchar(6)|1||0
5|notified_serial|integer|0||0
6|account|varchar(40)|0||0
sqlite> PRAGMA table_info(records);
0|id|integer|0||1
1|domain_id|integer|0||0
2|name|varchar(255)|1||0
3|type|varchar(10)|0||0
4|content|text|0||0
5|ttl|integer|0||0
6|prio|integer|0||0
7|change_date|integer|0||0
8|disabled|numeric|0||0

Those tables are enough to host zones with CoreDNS but they do not fulfill the requirements for the pdnsutil tool since PowerDNS still requires other tables for administrative purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0