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

Pmm-init doesn't skip task with waiting for a local postgres even when an external postgres is used #3666

Open
1 task done
ddkozyreva opened this issue Feb 19, 2025 · 3 comments
Assignees
Labels
bug Bug report

Comments

@ddkozyreva
Copy link

ddkozyreva commented Feb 19, 2025

Description

Hi!

We use an external postgres and define it with the PMM_POSTGRES_ADDR and PMM_DISABLE_BUILTIN_POSTGRES envs.

However the pmm-init process cannot work correctly due to the ansible task in the initialization role:

  - name: Wait for PostgreSQL to become responsive
    wait_for:
      host: 127.0.0.1
      port: 5432
      timeout: 150

And the pmm-init cannot be completed correctly due to the failed task.

It would be great if you added a condition to the problem task like when: lookup('env','PMM_POSTGRES_ADDR') == '127.0.0.1:5432' and lookup('env','PMM_DISABLE_BUILTIN_POSTGRES') != '1'.

Expected Results

We use an external postgres and expect the pmm-init process will work correctly.

Actual Results

The pmm-init runs the task for the local postgres and waits for task to be completed.

We don't have local postgres just because it runs on a separate host.

So the task fails and the playbook fails too.

Version

3.0.0

Steps to reproduce

No response

Relevant logs

Code of Conduct

  • I agree to follow Percona Community Code of Conduct
@ademidoff
Copy link
Member

ademidoff commented Feb 19, 2025

@ddkozyreva I believe this happens because you don't use the other set of variables that are necessary for Grafana to work correctly with an external database. As you can see, this part would not be executed if those GF_ environment variables are non-empty.

If that is the case, I recommend you check out the relevant section in our docs.

@ddkozyreva
Copy link
Author

ddkozyreva commented Feb 19, 2025

Are you talking about this condition when: lookup('env','GF_DATABASE_URL') == '' and lookup('env','GF_DATABASE_HOST') == '' and need_initialization at the end of the part:

  - name: Wait for PostgreSQL to become responsive
    wait_for:
      host: 127.0.0.1
      port: 5432
      timeout: 150

  - name: Create Grafana DB
    block:
      - name: Create grafana database in postgres
        postgresql_db:
          name: grafana
          login_user: postgres
          state: present

      - name: Create grafana user in postgres
        postgresql_user:
          db: grafana
          name: grafana
          password: grafana
          priv: 'ALL'
          expires: infinity
          login_user: postgres
          state: present
        when: not ansible_check_mode
    when: lookup('env','GF_DATABASE_URL') == '' and lookup('env','GF_DATABASE_HOST') == '' and need_initialization

?

This condition is for the block Create Grafana DB. The task with waiting for postgres goes before the block with condition and it is outside the block.

Postgres task has only one condition later - when: need_initialization or need_upgrade.

So if I need to upgrade pmm version and have an external postgres then I will face this postgres task and can't complete initialization process :(

P.S. I have GF_DATABASE_URL env, so these tasks with grafana are skipped when i add the condition into the postgres task

@ddkozyreva ddkozyreva changed the title Pmm-init doesn't skip task with waiting for local postgres even when we use external pmm Pmm-init doesn't skip task with waiting for a local postgres even when an external pmm is used Feb 19, 2025
@ddkozyreva ddkozyreva changed the title Pmm-init doesn't skip task with waiting for a local postgres even when an external pmm is used Pmm-init doesn't skip task with waiting for a local postgres even when an external postgres is used Feb 19, 2025
@ddkozyreva
Copy link
Author

Pull Request for the problem #3667

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

No branches or pull requests

3 participants