From 549c1a62fee6c05b6c5ebaad6decfb933b52ffd4 Mon Sep 17 00:00:00 2001 From: Pavel Anpin Date: Mon, 20 Mar 2023 12:09:57 +0400 Subject: [PATCH 1/5] maintainers: add anpin --- maintainers/maintainer-list.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index d15322cf497f..43eedd7585d9 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -1061,6 +1061,16 @@ githubId = 1342360; name = "Andrew Morgan"; }; + anpin = { + email = "pavel@anpin.fyi"; + github = "anpin"; + githubId = 6060545; + matrix = "@anpin:matrix.org"; + name = "Pavel Anpin"; + keys = [{ + fingerprint = "06E8 4FF6 0CCF 7AFD 5101 76C9 0FBC D3EE 6310 7407"; + }]; + }; anpryl = { email = "anpryl@gmail.com"; github = "anpryl"; From 3efea7f0eacb27b940d5d3e930246bd37eb1cca0 Mon Sep 17 00:00:00 2001 From: Pavel Anpin Date: Mon, 20 Mar 2023 12:11:26 +0400 Subject: [PATCH 2/5] postgresqlPackages.promscale_extension: init at 0.8.0 --- .../postgresql/ext/promscale_extension.nix | 60 +++++++++++++++++++ pkgs/servers/sql/postgresql/packages.nix | 2 + 2 files changed, 62 insertions(+) create mode 100644 pkgs/servers/sql/postgresql/ext/promscale_extension.nix diff --git a/pkgs/servers/sql/postgresql/ext/promscale_extension.nix b/pkgs/servers/sql/postgresql/ext/promscale_extension.nix new file mode 100644 index 000000000000..0e574a8ac85d --- /dev/null +++ b/pkgs/servers/sql/postgresql/ext/promscale_extension.nix @@ -0,0 +1,60 @@ +{ lib +, fetchFromGitHub +, fetchpatch +, buildPgxExtension +, postgresql +, stdenv +, nixosTests +}: + +buildPgxExtension rec { + inherit postgresql; + + pname = "promscale_extension"; + version = "0.8.0"; + + src = fetchFromGitHub { + owner = "timescale"; + repo = "promscale_extension"; + rev = version; + sha256 = "sha256-vyEfQMGguHrHYdBEEmbev29L2uCa/4xL9DpGIniUwfI="; + }; + + cargoSha256 = "sha256-vq/R9Kd0a9ckgEYm9Kt2J+RdyiHHYVutNEM4dcRViUo="; + + cargoPatches = [ + # there is a duplicate definition in the lock file which fails to build with buildRustPackage + (fetchpatch { + name = "cargo-vendor.patch"; + url = "https://github.com/timescale/promscale_extension/commit/3cef3f26f72ebf52d8800910ea655cac09312c57.patch"; + hash = "sha256-bXwvOv6T09EsCu+QCOCZny+V/Cy1UvCP6zlE8TdBlEg="; + }) + ]; + + preBuild = '' + patchShebangs create-upgrade-symlinks.sh extract-extension-version.sh + ## Hack to boostrap the build because some pgx commands require this file. It gets re-generated later. + cp templates/promscale.control ./promscale.control + ''; + postInstall = '' + ln -s $out/lib/promscale-${version}.so $out/lib/promscale.so + ''; + passthru.tests = { + promscale = nixosTests.promscale; + }; + + # tests take really long + doCheck = false; + + meta = with lib; { + description = "Promscale is an open source observability backend for metrics and traces powered by SQL"; + homepage = "https://github.com/timescale/promscale_extension"; + maintainers = with maintainers; [ anpin ]; + platforms = postgresql.meta.platforms; + license = licenses.unfree; + + # as it needs to be used with timescaledb, simply use the condition from there + broken = versionOlder postgresql.version "12" + || versionAtLeast postgresql.version "15"; + }; +} diff --git a/pkgs/servers/sql/postgresql/packages.nix b/pkgs/servers/sql/postgresql/packages.nix index 211a54bb5523..c94b91f02e2b 100644 --- a/pkgs/servers/sql/postgresql/packages.nix +++ b/pkgs/servers/sql/postgresql/packages.nix @@ -71,6 +71,8 @@ self: super: { pg_safeupdate = super.callPackage ./ext/pg_safeupdate.nix { }; + promscale_extension = super.callPackage ./ext/promscale_extension.nix { }; + repmgr = super.callPackage ./ext/repmgr.nix { }; rum = super.callPackage ./ext/rum.nix { }; From 4e6ddd0c15d65bcd5bdc36bac7a6e51b64b39061 Mon Sep 17 00:00:00 2001 From: Pavel Anpin Date: Mon, 20 Mar 2023 12:12:37 +0400 Subject: [PATCH 3/5] promscale: 0.10.0 -> 0.17.0 --- .../0001-remove-jaeger-test-dep.patch | 17 ----------------- .../prometheus/promscale/default.nix | 18 +++++++++--------- 2 files changed, 9 insertions(+), 26 deletions(-) delete mode 100644 pkgs/servers/monitoring/prometheus/promscale/0001-remove-jaeger-test-dep.patch diff --git a/pkgs/servers/monitoring/prometheus/promscale/0001-remove-jaeger-test-dep.patch b/pkgs/servers/monitoring/prometheus/promscale/0001-remove-jaeger-test-dep.patch deleted file mode 100644 index 9266a9aca53c..000000000000 --- a/pkgs/servers/monitoring/prometheus/promscale/0001-remove-jaeger-test-dep.patch +++ /dev/null @@ -1,17 +0,0 @@ - -A Promscale test has a dependency on a package which was not intended to be -vendored, so `go mod vendor` breaks. The dependency is not required to build -Promscale, so it can be removed. - -diff --git a/pkg/tests/end_to_end_tests/trace_query_integration_test.go b/pkg/tests/end_to_end_tests/trace_query_integration_test.go -index 84a0d08..efbe5e1 100644 ---- a/pkg/tests/end_to_end_tests/trace_query_integration_test.go -+++ b/pkg/tests/end_to_end_tests/trace_query_integration_test.go -@@ -24,7 +24,6 @@ import ( - ingstr "github.com/timescale/promscale/pkg/pgmodel/ingestor" - "github.com/timescale/promscale/pkg/pgxconn" - -- jaegerQueryApp "github.com/jaegertracing/jaeger/cmd/query/app" - jaegerQueryService "github.com/jaegertracing/jaeger/cmd/query/app/querysvc" - jaegerJSONModel "github.com/jaegertracing/jaeger/model/json" - ) diff --git a/pkgs/servers/monitoring/prometheus/promscale/default.nix b/pkgs/servers/monitoring/prometheus/promscale/default.nix index fbd1661c5f8b..7dcc5f01e47c 100644 --- a/pkgs/servers/monitoring/prometheus/promscale/default.nix +++ b/pkgs/servers/monitoring/prometheus/promscale/default.nix @@ -7,20 +7,16 @@ buildGoModule rec { pname = "promscale"; - version = "0.10.0"; + version = "0.17.0"; src = fetchFromGitHub { owner = "timescale"; repo = pname; rev = version; - sha256 = "sha256-KF+aD9vJYqNJkJftx27ZsxmOIXZ/2ciKwjwcTw0GBvY="; + sha256 = "sha256-JizUI9XRzOEHF1kAblYQRYB11z9KWX7od3lPiRN+JNI="; }; - patches = [ - ./0001-remove-jaeger-test-dep.patch - ]; - - vendorSha256 = "sha256-/cjRM8CrOKnx0BcRu2+MLV28MYLOrG5x1DN24mRUJzQ="; + vendorSha256 = "sha256-lnyKsipr/f9W9LWLb2lizKGLvIbS3XnSlOH1u1B87OY="; ldflags = [ "-s" @@ -28,7 +24,11 @@ buildGoModule rec { "-X github.com/timescale/promscale/pkg/version.Version=${version}" "-X github.com/timescale/promscale/pkg/version.CommitHash=${src.rev}" ]; - + preBuild = '' + # Without this build fails with + # main module (github.com/timescale/promscale) does not contain package github.com/timescale/promscale/migration-tool/cmd/prom-migrator + rm -r migration-tool + ''; checkPhase = '' runHook preCheck @@ -51,6 +51,6 @@ buildGoModule rec { changelog = "https://github.com/timescale/promscale/blob/${version}/CHANGELOG.md"; license = licenses.asl20; platforms = platforms.unix; - maintainers = with maintainers; [ _0x4A6F ]; + maintainers = with maintainers; [ _0x4A6F anpin ]; }; } From 08ddf6f0e3ce657dcd1d579796297af2b32b578d Mon Sep 17 00:00:00 2001 From: Pavel Anpin Date: Mon, 20 Mar 2023 12:13:09 +0400 Subject: [PATCH 4/5] nixosTests.promscale: add tests for promscale_extension --- nixos/tests/all-tests.nix | 1 + nixos/tests/promscale.nix | 60 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 nixos/tests/promscale.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 715fe7e51e0f..4926286a4ece 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -712,6 +712,7 @@ in { tiddlywiki = handleTest ./tiddlywiki.nix {}; tigervnc = handleTest ./tigervnc.nix {}; timescaledb = handleTest ./timescaledb.nix {}; + promscale = handleTest ./promscale.nix {}; timezone = handleTest ./timezone.nix {}; tinc = handleTest ./tinc {}; tinydns = handleTest ./tinydns.nix {}; diff --git a/nixos/tests/promscale.nix b/nixos/tests/promscale.nix new file mode 100644 index 000000000000..d4825b6d7f55 --- /dev/null +++ b/nixos/tests/promscale.nix @@ -0,0 +1,60 @@ +# mostly copied from ./timescaledb.nix which was copied from ./postgresql.nix +# as it seemed unapproriate to test additional extensions for postgresql there. + +{ system ? builtins.currentSystem +, config ? { } +, pkgs ? import ../.. { inherit system config; } +}: + +with import ../lib/testing-python.nix { inherit system pkgs; }; +with pkgs.lib; + +let + postgresql-versions = import ../../pkgs/servers/sql/postgresql pkgs; + test-sql = pkgs.writeText "postgresql-test" '' + CREATE USER promscale SUPERUSER PASSWORD 'promscale'; + CREATE DATABASE promscale OWNER promscale; + ''; + + make-postgresql-test = postgresql-name: postgresql-package: makeTest { + name = postgresql-name; + meta = with pkgs.lib.maintainers; { + maintainers = [ anpin ]; + }; + + nodes.machine = { config, pkgs, ... }: + { + services.postgresql = { + enable = true; + package = postgresql-package; + extraPlugins = with postgresql-package.pkgs; [ + timescaledb + promscale_extension + ]; + settings = { shared_preload_libraries = "timescaledb, promscale"; }; + }; + environment.systemPackages = with pkgs; [ promscale ]; + }; + + testScript = '' + machine.start() + machine.wait_for_unit("postgresql") + with subtest("Postgresql with extensions timescaledb and promscale is available just after unit start"): + print(machine.succeed("sudo -u postgres psql -f ${test-sql}")) + machine.succeed("sudo -u postgres psql promscale -c 'SHOW shared_preload_libraries;' | grep promscale") + machine.succeed( + "promscale --db.name promscale --db.password promscale --db.user promscale --db.ssl-mode allow --startup.install-extensions --startup.only" + ) + machine.succeed("sudo -u postgres psql promscale -c 'SELECT ps_trace.get_trace_retention_period();' | grep '(1 row)'") + machine.shutdown() + ''; + }; + #version 15 is not supported yet + applicablePostgresqlVersions = filterAttrs (_: value: versionAtLeast value.version "12" && !(versionAtLeast value.version "15")) postgresql-versions; +in +mapAttrs' + (name: package: { + inherit name; + value = make-postgresql-test name package; + }) + applicablePostgresqlVersions From 0e191c7ec12e5af4041c2c5cba1a3ab52f3a17ae Mon Sep 17 00:00:00 2001 From: Pavel Anpin Date: Sun, 23 Apr 2023 13:17:14 +0400 Subject: [PATCH 5/5] promscale_extension: fixed cargoPatch somehow the patch made earlier stoped working, so the build was failing due to git dependency in cargo.lock. Fixed that in the upstream PR and repointed fetchpatch to the new commit --- pkgs/servers/sql/postgresql/ext/promscale_extension.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/sql/postgresql/ext/promscale_extension.nix b/pkgs/servers/sql/postgresql/ext/promscale_extension.nix index 0e574a8ac85d..e031bb4c021b 100644 --- a/pkgs/servers/sql/postgresql/ext/promscale_extension.nix +++ b/pkgs/servers/sql/postgresql/ext/promscale_extension.nix @@ -20,14 +20,14 @@ buildPgxExtension rec { sha256 = "sha256-vyEfQMGguHrHYdBEEmbev29L2uCa/4xL9DpGIniUwfI="; }; - cargoSha256 = "sha256-vq/R9Kd0a9ckgEYm9Kt2J+RdyiHHYVutNEM4dcRViUo="; + cargoSha256 = "sha256-VK9DObkg4trcGUXxxISCd0zqU3vc1Qt6NxqpgKIARCQ="; cargoPatches = [ # there is a duplicate definition in the lock file which fails to build with buildRustPackage (fetchpatch { name = "cargo-vendor.patch"; - url = "https://github.com/timescale/promscale_extension/commit/3cef3f26f72ebf52d8800910ea655cac09312c57.patch"; - hash = "sha256-bXwvOv6T09EsCu+QCOCZny+V/Cy1UvCP6zlE8TdBlEg="; + url = "https://github.com/timescale/promscale_extension/commit/3048bd959430e9abc2c1d5c772ab6b4fc1dc6a95.patch"; + hash = "sha256-xTk4Ml8GN06QlJdrvAdVK21r30ZR/S83y5A5jJPdOw4="; }) ];