-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
nixos/postgresql/citus: fix syscall filter and add test #379769
Open
jflanglois
wants to merge
1
commit into
NixOS:staging
Choose a base branch
from
jflanglois:fix-citus
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
pkgs, | ||
makeTest, | ||
genTests, | ||
}: | ||
|
||
let | ||
inherit (pkgs) lib; | ||
|
||
test-sql = pkgs.writeText "postgresql-test" '' | ||
CREATE EXTENSION citus; | ||
|
||
CREATE TABLE examples ( | ||
id bigserial, | ||
shard_key int, | ||
PRIMARY KEY (id, shard_key) | ||
); | ||
|
||
SELECT create_distributed_table('examples', 'shard_key'); | ||
|
||
INSERT INTO examples (shard_key) SELECT shard % 10 FROM generate_series(1,1000) shard; | ||
''; | ||
|
||
makeTestFor = | ||
package: | ||
makeTest { | ||
name = "citus-${package.name}"; | ||
meta = with lib.maintainers; { | ||
maintainers = [ typetetris ]; | ||
}; | ||
|
||
nodes.machine = | ||
{ ... }: | ||
{ | ||
services.postgresql = { | ||
inherit package; | ||
enable = true; | ||
enableJIT = lib.hasInfix "-jit-" package.name; | ||
extensions = | ||
ps: with ps; [ | ||
citus | ||
]; | ||
settings = { | ||
shared_preload_libraries = "citus"; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
def check_count(statement, lines): | ||
return 'test $(sudo -u postgres psql postgres -tAc "{}") -eq {}'.format( | ||
statement, lines | ||
) | ||
|
||
|
||
machine.start() | ||
machine.wait_for_unit("postgresql") | ||
|
||
with subtest("Postgresql with extension citus is available just after unit start"): | ||
machine.succeed( | ||
"sudo -u postgres psql -f ${test-sql}" | ||
) | ||
|
||
machine.succeed(check_count("SELECT count(*) FROM examples;", 1000)) | ||
|
||
machine.shutdown() | ||
''; | ||
}; | ||
in | ||
genTests { | ||
inherit makeTestFor; | ||
filter = _: p: !p.pkgs.citus.meta.broken; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in #355010 we didn't add a whole new test on purpose - because this won't scale for many extensions. We can't add a new VM test for each of them. But I think we also can't test them together, otherwise the granted exceptions here might overlay each other.
At the same time - we should really test this. So we need a VM test.
I don't really have a solution, but I do think that a VM test for
citus
is generally a good idea, especially if we consider that this test could be extended to test multiple machines setting up a citus cluster in the future.TLDR: I'm OK with adding another test here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right I agree with a multi-node test, but would rather do that on top of
master
whenstaging
is mergedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also makes me think: I wonder if the hardening should be made more configurable in the module? It seems like extensions could easily hit a blocked syscall after an update and this was difficult to debug for me because there were no logs—I only looked at hardening options because postgresql started fine when run manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these logged to the kernel log?
I don't recall where exactly, but I'm pretty sure it's written somewhere - for syscalls at least.
See #344925 (comment) for my rationale on why it's implemented the way it currently is.
Agreed. For the time being, my suggestion would be to add VM tests when the need arises (i.e. when we have to adjust the hardening for instance).