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

metadata run plugin metadata() order vary #6671

Open
yifan513 opened this issue May 8, 2024 · 0 comments
Open

metadata run plugin metadata() order vary #6671

yifan513 opened this issue May 8, 2024 · 0 comments
Labels

Comments

@yifan513
Copy link

yifan513 commented May 8, 2024

What happened:
metadata run plugin metadata() order vary.
For me I have two plugins have the func
Metadata(ctx context.Context, state request.Request)
it should be calling in
func (m *Metadata) ServeDNS...
in a fixed order.

But when I start server, it may runs inverse order as before.

What you expected to happen:
Run in a fixed order.

How to reproduce it (as minimally and precisely as possible):
If you setup 2 plugin has metadata, you can check

func setup(c *caddy.Controller) error {
	m, err := metadataParse(c)
	if err != nil {
		return err
	}
	dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
		m.Next = next
		return m
	})

	c.OnStartup(func() error {
		plugins := dnsserver.GetConfig(c).Handlers()
		for _, p := range plugins {
			if met, ok := p.(Provider); ok {
				m.Providers = append(m.Providers, met)
			}
		}
		return nil
	})

	return nil
}

If you set a breakpoint to

plugins := dnsserver.GetConfig(c).Handlers()

you should see sometimes plugins items order changes.
This will cause order of items in m.Providers changes.
I added two images run runs without change corefile. You can see the redis and sortByLoc orders changes in the plugins.

Anything else we need to know?:

Environment:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal

  • the version of CoreDNS: 1.9.3

  • Corefile:

  • logs, if applicable:

  • OS (e.g: cat /etc/os-release):
    Screenshot 2024-05-08 at 16 51 19
    Screenshot 2024-05-08 at 16 50 35

  • Others:

@yifan513 yifan513 added the bug label May 8, 2024
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

1 participant