Skip to content
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 emails.

Already on GitHub? Sign in to your account

building from external repo doesn't work #253

Open
marten-seemann opened this issue Mar 1, 2022 · 2 comments
Open

building from external repo doesn't work #253

marten-seemann opened this issue Mar 1, 2022 · 2 comments
Labels

Comments

@marten-seemann
Copy link

What happened:

In preparation for adding my own plugin as described in https://coredns.io/2017/07/25/compile-time-enabling-or-disabling-plugins/#build-with-external-golang-source-code I build coredns from an external repo (see code below). There's no Corefile in the directory.

❯ go run main.go
no action found for directive 'log' with server type 'dns' (missing a plugin?)
exit status 1

What you expected to happen:

I expected coredns to start.

How to reproduce it (as minimally and precisely as possible):

package main

import (
	"github.com/coredns/coredns/coremain"
)

func main() {
	coremain.Run()
}

Using coredns v1.9.0.

Anything else we need to know?:

Environment:

  • the version of CoreDNS: v1.9.0
  • Corefile: n/a
  • logs, if applicable: see above
  • OS (e.g: cat /etc/os-release): OSX (m1 mbp)
  • Others:
@marten-seemann
Copy link
Author

Adding the following import fixes the problem:

import _ "github.com/coredns/coredns/core/plugin"

This should probably be added to the manual (https://coredns.io/2017/07/25/compile-time-enabling-or-disabling-plugins/#build-with-external-golang-source-code).

@chrisohaver chrisohaver transferred this issue from coredns/coredns Mar 1, 2022
@chrisohaver
Copy link
Member

Thanks! At face value this seems right, but on further consideration ...

import _ "github.com/coredns/coredns/core/plugin"

This import will compile in all of coredns' default plugins. They won't be usable if not also added to the directives list, but their packages will be built into the resulting binary. To leave unused/unwanted plugins out of the binary (e.g. if the goal is to trim down the size of the binary), only the plugins needed should be included.

❯ go run main.go
no action found for directive 'log' with server type 'dns' (missing a plugin?)
exit status 1

When running coredns without a Corefile, coredns runs with a stub configuration that includes log and whoami. Hence, the error if those plugins are not included and no Corefile exists. Running coredns without a Corefile is not an important function, so compiling without log or whoami is valid.

@zouyee zouyee added question and removed bug labels May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants