Repository navigation
Conversation
4f90186 to
5d39ac5
Compare
smortex
left a comment
There was a problem hiding this comment.
Some unit test that ensure this feature does not break in the future would be cool. Other that that, that feels good to me.
| case $ensure { | ||
| 'present': { | ||
| $command = "CREATE EXTENSION \"${extension}\"" | ||
| $command = "CREATE EXTENSION \"${extension}\"${if $version and $version != 'latest' { " VERSION \"${version}\"" } else { '' }}" |
There was a problem hiding this comment.
Looks like the code in the ${} confuse the linter. While this is syntactically correct, that is quite uncommon and I would rather avoid this.
Switching to inline epp would be a valid alternative, something like (untested):
| $command = "CREATE EXTENSION \"${extension}\"${if $version and $version != 'latest' { " VERSION \"${version}\"" } else { '' }}" | |
| $command = inline_epp('CREATE EXTENSION "<%= $extension %>"<% if $version and $version != 'latest' { %> VERSION "<%= $version %>"<% } %>', { extension => $extension, version => $version }) |
There was a problem hiding this comment.
It works as expected, I just had to replace the quotation marks for 'latest' , but it works.
$command = inline_epp('CREATE EXTENSION "<%= $extension %>"<% if $version and $version != "latest" { %> VERSION "<%= $version %>"<% } %>', { extension => $extension, version => $version })
My output:
...
Notice: /Stage[main]/Profile::Postgresql/Postgresql::Server::Grant[monitoring_execute_pg_ls_waldir]/Postgresql_psql[grant:monitoring_execute_pg_ls_waldir]/command: command changed 'notrun' to 'GRANT EXECUTE ON FUNCTION pg_ls_waldir() TO "monitoring"'
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Role[zabbix]/Postgresql_psql[CREATE ROLE zabbix ENCRYPTED PASSWORD ****]/command: changed [redacted] to [redacted]
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[CREATE DATABASE "zabbix"]/command: command changed 'notrun' to 'CREATE DATABASE "zabbix" WITH TEMPLATE = "template0" ENCODING = \'UTF-8\' LC_COLLATE = \'en_US.UTF-8\' LC_CTYPE = \'en_US.UTF-8\' '
Info: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[CREATE DATABASE "zabbix"]: Scheduling refresh of Postgresql_psql[REVOKE CONNECT ON DATABASE "zabbix" FROM public]
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[REVOKE CONNECT ON DATABASE "zabbix" FROM public]: Triggered 'refresh' from 1 event
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[ALTER DATABASE "zabbix" OWNER TO "zabbix"]/command: command changed 'notrun' to 'ALTER DATABASE "zabbix" OWNER TO "zabbix"'
Notice: /Stage[main]/Profile::Postgresql/Postgresql::Server::Extension[timescaledb]/Postgresql_psql[zabbix: CREATE EXTENSION "timescaledb" VERSION "2.23.1"]/command: command changed 'notrun' to 'CREATE EXTENSION "timescaledb" VERSION "2.23.1"'
Notice: /Stage[main]/Profile::Postgresql/Postgresql::Server::Extension[pg_repack]/Postgresql_psql[zabbix: CREATE EXTENSION "pg_repack" VERSION "1.5.3"]/command: command changed 'notrun' to 'CREATE EXTENSION "pg_repack" VERSION "1.5.3"'
...
|
/ping |
|
I tried my best to implement |
|
@aba-malu : Thanks for the updates! I've approved the tests to run so that you can see the CI feedback. It looks like there are some RuboCop failures to address. |
|
@jst-cyr : Thanks, when I run |
|
I approved the CI to run and we have new results: https://github.com/puppetlabs/puppetlabs-postgresql/actions/runs/36817873546?pr=1654 The good news is that the Rubocop issues appear to be resolved! The bad news is that we appear to have metadata that is not allowing for the latest releases of dependencies to be pulled down (stdlib, concat, systemd). I don't see these errors in main, so I think your branch needs a rebase to pick up the fixes from the main branch. |
f93ca35 to
fe1cde6
Compare
|
Oh, yeah my PR was with v10.6.0. Now I have rebased my branch. |
|
Thank you @aba-malu ! The spec tests look good. I'll kick off some acceptance testing so that we can get that initial feedback done. |
|
Running CI tests for this PR here: #1711 |
|
Good morning @jst-cyr, could it be, that I should split the apply_manifest(pp, catch_failures: true)
expect(psql("-tA --command=\"SELECT extversion FROM pg_extension WHERE extname = '#{ext}'\" ext_vtest", 'postgres').stdout)
.to include(ver)
apply_manifest(pp, catch_changes: true)
end
end |
|
Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-postgresql/actions/runs/37061237668?pr=1711 Full red across the board. Some are expected (Debian 11 and Red Hat 7) but other failures appear to be caused by the changes in this PR. Initial inspection sees two errors, at least:
@aba-malu : To your question, I think you should still use one apply_manifest, you just can't pass two params in. Using |
|
Now I need help from an AI :( If I understand the reports right, I choose a contrib extension (with i now have in |
|
Changed to extensions from docs https://www.postgresql.org/docs/current/contrib.html. |
|
Thank you @aba-malu ! CI is looking good, I'll kick off acceptance tests next. |
|
Running CI for this PR here: #1712 |
|
Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-postgresql/actions/runs/37334103392?pr=1712 Full red across the board, regression from prevous tests. Spot-checking across a few platforms seems to show a similar error popping up:
|
|
I try to split the output extension name and default_version with I hope the part with |
|
Thanks @aba-malu ! I'll kick off some more acceptance tests and let's see if this approach yields better results cross-platform. |
|
Running CI tests for this PR here: #1713 |
|
Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-postgresql/actions/runs/37665536933?pr=1713 Full failure across all platforms. Red Hat 9 seemed to have an infra issue, but on the spot checks I made there is a consistent theme:
|
Ref 1654#issuecomment-6060338754
|
New day, new try. |
|
@aba-malu : No need to apologize! Thank you so much for trying to make the module better. We'll get there eventually! |
|
Running CI tests for this PR here: #1714 |
|
Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-postgresql/actions/runs/37832984393?pr=1714 Full green! No errors, this is good to go forward for engineering review. |
Summary
This pull request adds support for specifying an explicit extension version when using CREATE EXTENSION. Allowing users to control which extension version is installed instead of relying on the default.
Additional Context
I recently encountered this issue with TimescaleDB 2.23.1 and PostgreSQL 18 on Debian 12 using the official TimescaleDB APT repository. The package timescaledb-2-loader-postgresql-18 (dependency of timescaledb-2-2.23.1-postgresql-18) sets the default to 2.24.0 in
/usr/share/postgresql/18/extension/timescaledb.control. When creating a new database, Puppet wants to create the extension withCREATE EXTENSION "timescaledb" ;. In the next stepALTER EXTENSION "timescaledb" UPDATE TO "2.23.1" ;is executed and fails with following error:If no version is specified, the default from the file
/usr/share/postgresql/18/extension/timescaledb.controlis used. Since the “version” is already implemented, I would like to use it in CREATE as well.Related Issues (if any)
Mention any related issues or pull requests.
Checklist
puppet apply)