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

/pgadmin4/servers.json content does not show up in web interface 8.1 #7074

Closed
khteh opened this issue Dec 20, 2023 · 14 comments
Closed

/pgadmin4/servers.json content does not show up in web interface 8.1 #7074

khteh opened this issue Dec 20, 2023 · 14 comments
Assignees
Labels

Comments

@khteh
Copy link

khteh commented Dec 20, 2023

Please note that security bugs or issues should be reported to security@pgadmin.org.
Why was #6998 closed!?! It is still an issue! I have servers.json mounted in k8s statefulset and pgadmin4 is NOT deployed with the mounted server configuration!

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. See the error

Expected behavior

A clear and concise description of what you expected to happen.

Error message

If possible, include the full, unedited text of any error messages displayed.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows 10, OSX monterey] Ubuntu 23.10
  • Version: [e.g. 6.15] 8.1
  • Mode: [e.g Desktop or Server] Server
  • Browser (if running in server mode): [e.g. chrome, safari] Chrome
  • Package type: [e.g. RPM, DEB, Python, Container, etc.] Container

Additional context

Add any other context about the problem here.

@yogeshmahajan-1903
Copy link
Contributor

@khteh ,
Can you please share the docker-config? As mentioned in #6998 I am not able to reproduce the issue.

@paulmilbank
Copy link
Contributor

paulmilbank commented Jan 21, 2024

@khteh Are you using a custom entrypoint for the docker container? Or possibly loading an old one somehow?

I can see in my logs: No such option: --load-servers on a PGAdmin4 8.2 container using an older entrypoint. Looking at the current master branch, I can see the -- has been removed from the options. I think this is a consequence of switching from argparse to typer.
0d287df

Updating my entrypoint to sync with the current master branch entrypoint at https://github.com/pgadmin-org/pgadmin4/blob/master/pkg/docker/entrypoint.sh has fixed the loading for me.

@adityatoshniwal
Copy link
Contributor

@khteh
Copy link
Author

khteh commented Jan 27, 2024

Not custom entrypoint. There is no load-servers in my k8s manifest!

@khteh khteh removed their assignment Jan 27, 2024
@adityatoshniwal
Copy link
Contributor

@khteh did you follow the simple example here to verify - https://www.pgadmin.org/docs/pgadmin4/8.2/container_deployment.html#examples?

@sanhardik
Copy link

sanhardik commented Feb 23, 2024

Doesnt seem to work for me
This is in my docker compose

db-rl:
    image: dpage/pgadmin4:latest
    entrypoint: >
      /bin/sh -c "
      echo '*:5432:postgres:postgres:pass' >> /var/lib/pgadmin/pgpass;
      chmod 600 /var/lib/pgadmin/pgpass;
      chown pgadmin /var/lib/pgadmin/pgpass;
      /entrypoint.sh
      "
    environment:
      - PGADMIN_DEFAULT_EMAIL=admin@abc.com
      - PGADMIN_DEFAULT_PASSWORD=5W2dO3AKP9hM
    networks:
      rdcnet: {}
    secrets:
      - source: pgadmin_config_20240223_3
        target: /pgadmin4/config_local.py
      - source: pgadmin_servers_20240223_1
        target: /pgadmin4/servers.json
    deploy:
      replicas: 1
      rollback_config:
        parallelism: 1
      update_config:
        parallelism: 1
        order: start-first
        delay: 10s
        failure_action: rollback

My config.py looks like this

AUTHENTICATION_SOURCES = ['oauth2']
OAUTH2_CONFIG = [
    {
        'OAUTH2_NAME': 'Google',
        'OAUTH2_DISPLAY_NAME': 'Google',
        'OAUTH2_CLIENT_ID': 'clientId',
        'OAUTH2_CLIENT_SECRET': 'clientSecret',
        'OAUTH2_TOKEN_URL': 'https://oauth2.googleapis.com/token',
        'OAUTH2_AUTHORIZATION_URL': 'https://accounts.google.com/o/oauth2/v2/auth',
        'OAUTH2_SERVER_METADATA_URL': 'https://accounts.google.com/.well-known/openid-configuration',
        'OAUTH2_API_BASE_URL': 'https://openidconnect.googleapis.com/v1/',
        'OAUTH2_USERINFO_ENDPOINT': 'userinfo',
        'OAUTH2_SCOPE': 'openid email profile',
        'OAUTH2_ICON': 'fa-google',
        'OAUTH2_BUTTON_COLOR': '#3253a8',
    }
]
PGADMIN_CONFIG_CONSOLE_LOG_LEVEL = 10
MASTER_PASSWORD_REQUIRED= False

I can see the servers loading in the logs
| Added 0 Server Group(s) and 3 Server(s).

But I dont see the servers in the UI

@yogeshmahajan-1903
Copy link
Contributor

@sanhardik
With which user have logged in internal(Provided with PGADMIN_DEFAULT_EMAIL) or OAuth2? By default servers are loaded for user specified in the variable PGADMIN_DEFAULT_EMAIL. Hence you will not see server loaded when you are logged in with OAuth2 user.
Also can you please complete logs which starts with 'Loading servers with:'

You can use import/export from tools menu to add servers for OAuth2 user. Else mark servers in servers.json as shared.

@sanhardik
Copy link

sanhardik commented Feb 24, 2024

I have logged in using OAuth2.
I would like all the users logged in through OAuth2 to see all servers.

The "Shared" option worked.
I had to provide the "SharedUsername" option as well.

However now, its asking for password for the user "postgres".
I am passing the "PassFile": "/var/lib/pgadmin/pgpass" in the servers.json.
I have added the pgpass config in the entrypoint script in docker.

I also see this error
connection failed: fe_sendauth: no password supplied

@yogeshmahajan-1903
Copy link
Contributor

While connecting to the server in the server mode, pgpass file is looked up in 'var/lib/storage//', hence you are getting password not supplied error.
If you want to share pgpass file, then you can use shared storage feature. Please refer this link / or this link.

@sanhardik
Copy link

I will try out the shared storage.
I also tried

entrypoint: >
  /bin/sh -c "
  mkdir -p /var/lib/pgadmin/storage/admin_abc.com/;
  echo '*:*:*:postgres:pass' >> /var/lib/pgadmin/storage/admin_abc.com/.pgpass;
  echo '' >> /var/lib/pgadmin/storage/admin_abc.com/.pgpass;
  chown pgadmin:root /var/lib/pgadmin/storage/admin_abc.com/.pgpass;
  chmod 600 /var/lib/pgadmin/storage/admin_abc.com/.pgpass;
  /entrypoint.sh
      "
      ```
But that didnt work. 

For the shared storage, what should be the passfile

```SHARED_STORAGE = [{
    'name': Shared-Storage',
     'path': '/var/pgadmin4/shared',
     'restricted_access': True
}]

@yogeshmahajan-1903
Copy link
Contributor

@sanhardik
entrypoint stuff should work. What is error? Did you check hidden files in storage manager?
You can copy pgpass file in shared directory and then set password_file parameter in server dialogue/(via server.json) to the pgpass file path.

@sanhardik
Copy link

With the entrypoint, I see Error: connection failed: fe_sendauth: no password supplied error

My servers.json file has

      "PassFile": ".pgpass",
      "ConnectionParameters": {
         "passfile": ".pgpass"
      }

@adityatoshniwal
Copy link
Contributor

I'm closing this issue as the original issues seem to be fixed.
@sanhardik You have configuration problems, you can send email to pgadmin-support@postgresql.org

@adityatoshniwal adityatoshniwal closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
@samratdgreat
Copy link

With the entrypoint, I see Error: connection failed: fe_sendauth: no password supplied error

My servers.json file has

      "PassFile": ".pgpass",
      "ConnectionParameters": {
         "passfile": ".pgpass"
      }

Were you able to resolve the issue?

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

7 participants