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

postgresql_access resource in a custom resource always returns it is up to date, does not notify other resources #648

Closed
gregkare opened this issue May 7, 2020 · 4 comments
Labels
Bug Something isn't working hacktoberfest An issue highlighted for the digital ocean Hacktoberfest Event

Comments

@gregkare
Copy link
Contributor

gregkare commented May 7, 2020

Brief Description

postgresql_access resource when used in a custom resource always returns it is up to date, does not notify other resources

Cookbook version

7.1.8

Chef-Infra Version

15.3.14

Platform details

Ubuntu 18.04

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install postgresql using the postgresql_server_install resource
  2. In a custom resource, use postgresql_access resource to set up some access rights. For example:
postgresql_access "replication" do
  access_type "host"
  access_db "replication"
  access_user "replication"
  access_addr "192.168.42.25/32"
  access_method "md5"
  notifies :reload, "service[postgresql@12-main]", :immediately
end

It doesn't matter if the hba.conf file needs to be changed, the postgresql_access resource always thinks it was up to date. From a Chef run:

postgresql_access[replication] action grant (up to date)

This means that the notification isn't sent and the service is not reloaded. However on the first run the hba.conf file is updated

Expected behavior

I expect the postgresql_access resource to know when the hba.conf needs to be changed, and properly use the notifies property, allowing the PostgreSQL service to be reloaded for example.

The notification works when the postgresql_access resource is used in a recipe. This only occurs in a custom resource, like in sous-chefs/firewall#134

Do you know about a workaround? I tried editing the hba.conf template with edit_resource and find_resource to add the notifies property to it but got stuck since it expects a lot of variables.

Let me know if you need more information or if you have any question

@jimdaga
Copy link
Contributor

jimdaga commented May 7, 2020

Just a quick guess; but do you happen to have multiple postgresql_access resources with the name replication?

@damacus
Copy link
Member

damacus commented May 8, 2020

I wonder if unified mode will fix this.. if you can drop us a full replication case here, I think I can work out a fix.

Thanks!

@gregkare
Copy link
Contributor Author

I only have one postgresql_access resource with the name replication, however I created a simplified test recipe and I can't reproduce the issue.

Now I'm thinking the bug is related to using a postgresql_access resource inside of a custom resource, similar to sous-chefs/firewall#134. I'm working on a replication case

@gregkare
Copy link
Contributor Author

gregkare commented May 11, 2020

@damacus I have created a repo that reproduces this in Vagrant. The issue does not happen when the postgresql_access resource is used directly in a recipe, I'm updating the issue

Here is the repo: https://github.com/gregkare/pg_test

Edit: I can reproduce the issue using the latest version of Chef too, 16.0.287

@gregkare gregkare changed the title postgresql_access resource always returns it is up to date, does not notify other resources postgresql_access resource in a custom resource always returns it is up to date, does not notify other resources May 11, 2020
@ramereth ramereth added Bug Something isn't working hacktoberfest An issue highlighted for the digital ocean Hacktoberfest Event labels Oct 3, 2020
@bmhughes bmhughes mentioned this issue Dec 8, 2022
3 tasks
@bmhughes bmhughes closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working hacktoberfest An issue highlighted for the digital ocean Hacktoberfest Event
Projects
None yet
Development

No branches or pull requests

5 participants