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

BUG: userlist is not populating users slice causing "no configured users" error #359

Open
jaitaiwan opened this issue Jan 26, 2025 · 3 comments

Comments

@jaitaiwan
Copy link

Hey folks,

When running curl -X GET --user admin:admin http://localhost:55555/v3/info against the dataplane api setup to point to an haproxy config that has a user setup to be admin using the standard userlist setup as per the documentation the following is returned:

{"code":401,"message":"no configured users"}

Looking at the code there are two places that this happens both in users.go here and here

This appears to indicate that there are no users in the users slice but if that were the case then I believe this check here would fail.

Consequently, I think there's some mishap where the users list that is grabbed by the endpoint isn't the same initialized one as in the file above?

@mjuraga
Copy link
Collaborator

mjuraga commented Feb 3, 2025

Hi, thank you for reporting this issue, we'll take a look and get back to you.

@mjuraga
Copy link
Collaborator

mjuraga commented Feb 6, 2025

Can you share how you run your dataplaneapi (command line options) and .yaml configuration field. And also can you share your haproxy config used (you can remove sensitive data)?

@jaitaiwan
Copy link
Author

jaitaiwan commented Feb 7, 2025

Dataplane Command

dataplaneapi --host 0.0.0.0 \
    --port 5555 \
    --haproxy-bin /usr/local/sbin/haproxy \
    --config-file /usr/local/etc/haproxy/haproxy.cfg \
    --reload-cmd "kill -SIGUSR2 \$(cat /run/haproxy.pid)" \
    --restart-cmd "kill -SIGUSR2 \$(cat /run/haproxy.pid)" \
    --reload-delay 5 \
    --userlist "default-haproxy-dataplane" \
    --log-to stdout \
    --log-level trace

Dataplane YAML

dataplaneapi:
  advertised:
    api_address: "0.0.0.0"
    api_port: 5555
haproxy:
  reload:
    reload_strategy: custom

Note: It looks like it doesn't matter if you are specifying cmdline variables, if you don't have a yaml file in /etc/haproxy/dataplaneapi.yaml dataplaneapi will error despite creating it's own (at least as far as the dockerfile is concerned)

Haproxy Config

Config location: /usr/local/etc/haproxy/haproxy.cfg
Contents:

userlist default-haproxy-dataplane
    user admin insecure-password mypassword


defaults
    # Setup arbitrary default timeouts, changable in interface
    timeout connect 5s
    timeout client 5s
    timeout server 5s

    # Setup default logging
    log global

global
    # Enable runtime api for dataplaneapi
    stats socket /run/haproxy.sock mode 666 level admin

    # Use master-worker mode
    #master-worker #no-exit-on-failure

    # enable a pidfile for dataplane's abilty to restart
    pidfile /run/haproxy.pid

    # setup default logging
    log stdout format timed local0

frontend default
    bind :80
    mode http
    default_backend default_response

backend default_response
    mode http
    http-request return content-type "text/plain" string "Hello World!"

I see no differences in the response whether it's in master-worker mode or not.

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