From 6380f465a23f7f4401f6519438f04bdbad364c06 Mon Sep 17 00:00:00 2001 From: "awsdesktop\\chrisma" Date: Sun, 10 Apr 2022 11:13:52 +0100 Subject: [PATCH 1/5] use pgx --- go.mod | 2 +- go.sum | 89 +++++++++++++++++++ internal/lookout/application.go | 1 - internal/lookout/postgres/postgres.go | 4 +- internal/lookout/repository/job_sets.go | 36 ++++---- .../lookout/repository/schema/migrations.go | 18 ++-- internal/lookout/repository/sql_repository.go | 14 ++- internal/lookout/repository/store.go | 1 - internal/lookout/repository/util.go | 5 +- internal/lookout/testutil/db_testutil.go | 5 +- 10 files changed, 133 insertions(+), 42 deletions(-) diff --git a/go.mod b/go.mod index 4c579c3e83a..62fbc264a18 100644 --- a/go.mod +++ b/go.mod @@ -29,8 +29,8 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/golang-lru v0.5.3 // indirect github.com/instrumenta/kubeval v0.0.0-20190918223246-8d013ec9fc56 + github.com/jackc/pgx/v4 v4.15.0 // indirect github.com/jcmturner/gokrb5/v8 v8.4.2-0.20201112171129-78f56934d598 - github.com/lib/pq v1.10.4 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v1.4.2 github.com/nats-io/jsm.go v0.0.26 diff --git a/go.sum b/go.sum index 84d82095e03..229b8716a31 100644 --- a/go.sum +++ b/go.sum @@ -63,6 +63,7 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY= github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -138,6 +139,7 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.2.1 h1:/EeEo2EtN3umhbbgCveyjifoMYg0pS+nMMEemaYw634= @@ -150,11 +152,13 @@ github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHo github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -354,6 +358,7 @@ github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGt github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -522,6 +527,56 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/instrumenta/kubeval v0.0.0-20190918223246-8d013ec9fc56 h1:kKOrEaxR9KvCDdnQqjiBxbaeJg/goLvJvW0lno6aWm4= github.com/instrumenta/kubeval v0.0.0-20190918223246-8d013ec9fc56/go.mod h1:bpiMYvNpVxWjdJsS0hDRu9TrobT5GfWCZwJseGUstxE= +github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= +github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ= +github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= +github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= +github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38= +github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o= +github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w= +github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo= @@ -571,10 +626,14 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.1/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= @@ -594,11 +653,14 @@ github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsI github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= @@ -758,12 +820,18 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -858,6 +926,7 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 h1:1b6PAtenNyhsmo/NKXVe34h7JEZKva1YB/ne7K7mqKM= github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= @@ -892,17 +961,26 @@ go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -918,6 +996,7 @@ golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -980,6 +1059,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1068,6 +1148,7 @@ golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1165,6 +1246,7 @@ golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -1175,9 +1257,12 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1186,6 +1271,7 @@ golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1217,6 +1303,8 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1364,6 +1452,7 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8X gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/internal/lookout/application.go b/internal/lookout/application.go index 7c8b623672e..34ac55f6089 100644 --- a/internal/lookout/application.go +++ b/internal/lookout/application.go @@ -5,7 +5,6 @@ import ( "github.com/doug-martin/goqu/v9" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - _ "github.com/lib/pq" "github.com/nats-io/jsm.go" "github.com/nats-io/stan.go" log "github.com/sirupsen/logrus" diff --git a/internal/lookout/postgres/postgres.go b/internal/lookout/postgres/postgres.go index 01f171a51a0..55a3c5718d2 100644 --- a/internal/lookout/postgres/postgres.go +++ b/internal/lookout/postgres/postgres.go @@ -4,13 +4,13 @@ import ( "database/sql" "strings" - _ "github.com/lib/pq" + _ "github.com/jackc/pgx/v4/stdlib" "github.com/G-Research/armada/internal/lookout/configuration" ) func Open(config configuration.PostgresConfig) (*sql.DB, error) { - db, err := sql.Open("postgres", createConnectionString(config.Connection)) + db, err := sql.Open("pgx", createConnectionString(config.Connection)) if err != nil { return nil, err } diff --git a/internal/lookout/repository/job_sets.go b/internal/lookout/repository/job_sets.go index 0809f29bde7..cfaba647df3 100644 --- a/internal/lookout/repository/job_sets.go +++ b/internal/lookout/repository/job_sets.go @@ -5,12 +5,10 @@ import ( "database/sql" "time" + "github.com/G-Research/armada/pkg/api/lookout" "github.com/doug-martin/goqu/v9" "github.com/doug-martin/goqu/v9/exp" "github.com/gogo/protobuf/types" - "github.com/lib/pq" - - "github.com/G-Research/armada/pkg/api/lookout" ) type jobSetCountsRow struct { @@ -20,21 +18,21 @@ type jobSetCountsRow struct { Running sql.NullInt64 `db:"running"` Succeeded sql.NullInt64 `db:"succeeded"` Failed sql.NullInt64 `db:"failed"` - Submitted pq.NullTime `db:"submitted"` - - RunningStatsMin pq.NullTime `db:"running_min"` - RunningStatsMax pq.NullTime `db:"running_max"` - RunningStatsAverage pq.NullTime `db:"running_average"` - RunningStatsMedian pq.NullTime `db:"running_median"` - RunningStatsQ1 pq.NullTime `db:"running_q1"` - RunningStatsQ3 pq.NullTime `db:"running_q3"` - - QueuedStatsMin pq.NullTime `db:"queued_min"` - QueuedStatsMax pq.NullTime `db:"queued_max"` - QueuedStatsAverage pq.NullTime `db:"queued_average"` - QueuedStatsMedian pq.NullTime `db:"queued_median"` - QueuedStatsQ1 pq.NullTime `db:"queued_q1"` - QueuedStatsQ3 pq.NullTime `db:"queued_q3"` + Submitted sql.NullTime `db:"submitted"` + + RunningStatsMin sql.NullTime `db:"running_min"` + RunningStatsMax sql.NullTime `db:"running_max"` + RunningStatsAverage sql.NullTime `db:"running_average"` + RunningStatsMedian sql.NullTime `db:"running_median"` + RunningStatsQ1 sql.NullTime `db:"running_q1"` + RunningStatsQ3 sql.NullTime `db:"running_q3"` + + QueuedStatsMin sql.NullTime `db:"queued_min"` + QueuedStatsMax sql.NullTime `db:"queued_max"` + QueuedStatsAverage sql.NullTime `db:"queued_average"` + QueuedStatsMedian sql.NullTime `db:"queued_median"` + QueuedStatsQ1 sql.NullTime `db:"queued_q1"` + QueuedStatsQ3 sql.NullTime `db:"queued_q3"` } func (r *SQLJobRepository) GetJobSetInfos(ctx context.Context, opts *lookout.GetJobSetsRequest) ([]*lookout.JobSetInfo, error) { @@ -216,7 +214,7 @@ func (r *SQLJobRepository) rowsToJobSets(rows []*jobSetCountsRow, queue string) return jobSetInfos } -func getProtoDuration(currentTime time.Time, maybeTime pq.NullTime) *types.Duration { +func getProtoDuration(currentTime time.Time, maybeTime sql.NullTime) *types.Duration { var duration *types.Duration if maybeTime.Valid { duration = types.DurationProto(currentTime.Sub(maybeTime.Time)) diff --git a/internal/lookout/repository/schema/migrations.go b/internal/lookout/repository/schema/migrations.go index 6d16cb4bac8..00d3376cc1c 100644 --- a/internal/lookout/repository/schema/migrations.go +++ b/internal/lookout/repository/schema/migrations.go @@ -23,16 +23,16 @@ func UpdateDatabase(db *sql.DB) error { log.Info("Updating database...") version, err := readVersion(db) log.Infof("Current version %v", version) - + log.Infof("fish") if err != nil { return err } - + log.Infof("1") migrations, err := getMigrations() if err != nil { return err } - + log.Infof("2") for _, m := range migrations { if m.id > version { log.Infof("Migration %v", m.name) @@ -41,12 +41,14 @@ func UpdateDatabase(db *sql.DB) error { if err != nil { return err } + log.Infof("3") version = m.id err = setVersion(db, version) if err != nil { return err } + log.Infof("4") } } log.Info("Database updated.") @@ -54,13 +56,19 @@ func UpdateDatabase(db *sql.DB) error { } func readVersion(db *sql.DB) (int, error) { + _, err := db.Exec( + `CREATE SEQUENCE IF NOT EXISTS database_version START WITH 0 MINVALUE 0;`) + if err != nil { + return 0, err + } + result, err := db.Query( - `CREATE SEQUENCE IF NOT EXISTS database_version START WITH 0 MINVALUE 0; - SELECT last_value FROM database_version`) + `SELECT last_value FROM database_version`) if err != nil { return 0, err } + log.Infof("chips") var version int result.Next() err = result.Scan(&version) diff --git a/internal/lookout/repository/sql_repository.go b/internal/lookout/repository/sql_repository.go index c3c9d3a03e2..0d59f7ff8e8 100644 --- a/internal/lookout/repository/sql_repository.go +++ b/internal/lookout/repository/sql_repository.go @@ -4,11 +4,9 @@ import ( "context" "database/sql" + "github.com/G-Research/armada/pkg/api/lookout" "github.com/doug-martin/goqu/v9" _ "github.com/doug-martin/goqu/v9/dialect/postgres" - "github.com/lib/pq" - - "github.com/G-Research/armada/pkg/api/lookout" ) // Emulates JobStates enum @@ -80,17 +78,17 @@ type JobRow struct { Owner sql.NullString `db:"owner"` JobSet sql.NullString `db:"jobset"` Priority sql.NullFloat64 `db:"priority"` - Submitted pq.NullTime `db:"submitted"` - Cancelled pq.NullTime `db:"cancelled"` + Submitted sql.NullTime `db:"submitted"` + Cancelled sql.NullTime `db:"cancelled"` JobJson sql.NullString `db:"job"` State sql.NullInt64 `db:"state"` RunId sql.NullString `db:"run_id"` PodNumber sql.NullInt64 `db:"pod_number"` Cluster sql.NullString `db:"cluster"` Node sql.NullString `db:"node"` - Created pq.NullTime `db:"created"` - Started pq.NullTime `db:"started"` - Finished pq.NullTime `db:"finished"` + Created sql.NullTime `db:"created"` + Started sql.NullTime `db:"started"` + Finished sql.NullTime `db:"finished"` Succeeded sql.NullBool `db:"succeeded"` Error sql.NullString `db:"error"` } diff --git a/internal/lookout/repository/store.go b/internal/lookout/repository/store.go index 5c26d7a0dc7..661d2f5e336 100644 --- a/internal/lookout/repository/store.go +++ b/internal/lookout/repository/store.go @@ -9,7 +9,6 @@ import ( "github.com/doug-martin/goqu/v9" "github.com/doug-martin/goqu/v9/exp" - _ "github.com/lib/pq" "github.com/G-Research/armada/internal/common/util" "github.com/G-Research/armada/pkg/api" diff --git a/internal/lookout/repository/util.go b/internal/lookout/repository/util.go index 225cf3abe27..528a5917675 100644 --- a/internal/lookout/repository/util.go +++ b/internal/lookout/repository/util.go @@ -7,7 +7,6 @@ import ( "github.com/doug-martin/goqu/v9" "github.com/doug-martin/goqu/v9/exp" - "github.com/lib/pq" "github.com/G-Research/armada/internal/common/util" ) @@ -97,14 +96,14 @@ func ParseNullFloat(nullFloat sql.NullFloat64) float64 { return nullFloat.Float64 } -func ParseNullTime(nullTime pq.NullTime) *time.Time { +func ParseNullTime(nullTime sql.NullTime) *time.Time { if !nullTime.Valid { return nil } return &nullTime.Time } -func ParseNullTimeDefault(nullTime pq.NullTime) time.Time { +func ParseNullTimeDefault(nullTime sql.NullTime) time.Time { if !nullTime.Valid { return time.Time{} } diff --git a/internal/lookout/testutil/db_testutil.go b/internal/lookout/testutil/db_testutil.go index eeafa141085..1d30184e25b 100644 --- a/internal/lookout/testutil/db_testutil.go +++ b/internal/lookout/testutil/db_testutil.go @@ -4,6 +4,7 @@ import ( "database/sql" "testing" + _ "github.com/jackc/pgx/v4/stdlib" "github.com/stretchr/testify/assert" "github.com/G-Research/armada/internal/common/util" @@ -13,7 +14,7 @@ import ( func WithDatabase(t *testing.T, action func(db *sql.DB)) { dbName := "test_" + util.NewULID() connectionString := "host=localhost port=5432 user=postgres password=psw sslmode=disable" - db, err := sql.Open("postgres", connectionString) + db, err := sql.Open("pgx", connectionString) defer db.Close() assert.Nil(t, err) @@ -21,7 +22,7 @@ func WithDatabase(t *testing.T, action func(db *sql.DB)) { _, err = db.Exec("CREATE DATABASE " + dbName) assert.Nil(t, err) - testDb, err := sql.Open("postgres", connectionString+" dbname="+dbName) + testDb, err := sql.Open("pgx", connectionString+" dbname="+dbName) assert.Nil(t, err) defer func() { From ba310c56f1fe442470b7262817081de347d40841 Mon Sep 17 00:00:00 2001 From: "awsdesktop\\chrisma" Date: Sun, 10 Apr 2022 11:21:53 +0100 Subject: [PATCH 2/5] removed log lines --- internal/lookout/repository/schema/migrations.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/internal/lookout/repository/schema/migrations.go b/internal/lookout/repository/schema/migrations.go index 00d3376cc1c..7eea77c8eaa 100644 --- a/internal/lookout/repository/schema/migrations.go +++ b/internal/lookout/repository/schema/migrations.go @@ -22,33 +22,27 @@ type migration struct { func UpdateDatabase(db *sql.DB) error { log.Info("Updating database...") version, err := readVersion(db) - log.Infof("Current version %v", version) - log.Infof("fish") if err != nil { return err } - log.Infof("1") + log.Infof("Current version %v", version) migrations, err := getMigrations() if err != nil { return err } - log.Infof("2") + for _, m := range migrations { if m.id > version { - log.Infof("Migration %v", m.name) - _, err := db.Exec(m.sql) if err != nil { return err } - log.Infof("3") version = m.id err = setVersion(db, version) if err != nil { return err } - log.Infof("4") } } log.Info("Database updated.") @@ -68,7 +62,6 @@ func readVersion(db *sql.DB) (int, error) { return 0, err } - log.Infof("chips") var version int result.Next() err = result.Scan(&version) From 424ae4fb41a713fadc48ade9dc5416c7d19f6d79 Mon Sep 17 00:00:00 2001 From: "awsdesktop\\chrisma" Date: Sun, 10 Apr 2022 11:26:07 +0100 Subject: [PATCH 3/5] fix import order --- internal/lookout/repository/job_sets.go | 3 ++- internal/lookout/repository/sql_repository.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/lookout/repository/job_sets.go b/internal/lookout/repository/job_sets.go index cfaba647df3..51ec93f29c6 100644 --- a/internal/lookout/repository/job_sets.go +++ b/internal/lookout/repository/job_sets.go @@ -5,10 +5,11 @@ import ( "database/sql" "time" - "github.com/G-Research/armada/pkg/api/lookout" "github.com/doug-martin/goqu/v9" "github.com/doug-martin/goqu/v9/exp" "github.com/gogo/protobuf/types" + + "github.com/G-Research/armada/pkg/api/lookout" ) type jobSetCountsRow struct { diff --git a/internal/lookout/repository/sql_repository.go b/internal/lookout/repository/sql_repository.go index 0d59f7ff8e8..bd213c9f931 100644 --- a/internal/lookout/repository/sql_repository.go +++ b/internal/lookout/repository/sql_repository.go @@ -4,9 +4,10 @@ import ( "context" "database/sql" - "github.com/G-Research/armada/pkg/api/lookout" "github.com/doug-martin/goqu/v9" _ "github.com/doug-martin/goqu/v9/dialect/postgres" + + "github.com/G-Research/armada/pkg/api/lookout" ) // Emulates JobStates enum From 5e8783ba0b52682c8724d9abca11dbb3803bb19a Mon Sep 17 00:00:00 2001 From: "awsdesktop\\chrisma" Date: Mon, 11 Apr 2022 11:12:34 +0100 Subject: [PATCH 4/5] fix test --- go.mod | 2 +- internal/lookout/repository/queues.go | 93 +++++++++++++++++---------- 2 files changed, 59 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index 62fbc264a18..24711b35c13 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/golang-lru v0.5.3 // indirect github.com/instrumenta/kubeval v0.0.0-20190918223246-8d013ec9fc56 - github.com/jackc/pgx/v4 v4.15.0 // indirect + github.com/jackc/pgx/v4 v4.15.0 github.com/jcmturner/gokrb5/v8 v8.4.2-0.20201112171129-78f56934d598 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v1.4.2 diff --git a/internal/lookout/repository/queues.go b/internal/lookout/repository/queues.go index 7ff697012b3..881e0c963fb 100644 --- a/internal/lookout/repository/queues.go +++ b/internal/lookout/repository/queues.go @@ -3,9 +3,7 @@ package repository import ( "context" "database/sql" - "fmt" "sort" - "strings" "time" "github.com/doug-martin/goqu/v9" @@ -21,24 +19,60 @@ type countsRow struct { Running uint32 `db:"running"` } +type rowsSql struct { + Counts string + OldestQueued string + LongestRunning string +} + func (r *SQLJobRepository) GetQueueInfos(ctx context.Context) ([]*lookout.QueueInfo, error) { queries, err := r.getQueuesSql() if err != nil { return nil, err } - rows, err := r.goquDb.Db.QueryContext(ctx, queries) - if err != nil { - return nil, err - } + var countRows *sql.Rows + var longestRunningRows *sql.Rows + var oldestQueuedRows *sql.Rows + defer func() { - err := rows.Close() - if err != nil { - logrus.Fatalf("Failed to close SQL connection: %v", err) + if countRows != nil { + err := countRows.Close() + if err != nil { + logrus.Errorf("Failed to close SQL connection: %v", err) + } + } + + if longestRunningRows != nil { + err := longestRunningRows.Close() + if err != nil { + logrus.Errorf("Failed to close SQL connection: %v", err) + } + } + + if oldestQueuedRows != nil { + err := oldestQueuedRows.Close() + if err != nil { + logrus.Errorf("Failed to close SQL connection: %v", err) + } } }() + countRows, err = r.goquDb.Db.QueryContext(ctx, queries.Counts) + if err != nil { + return nil, err + } - result, err := r.rowsToQueues(rows) + longestRunningRows, err = r.goquDb.Db.QueryContext(ctx, queries.LongestRunning) + if err != nil { + return nil, err + } + + oldestQueuedRows, err = r.goquDb.Db.QueryContext(ctx, queries.OldestQueued) + if err != nil { + return nil, err + } + + result, err := r.rowsToQueues(countRows, oldestQueuedRows, longestRunningRows) if err != nil { return nil, err } @@ -46,7 +80,7 @@ func (r *SQLJobRepository) GetQueueInfos(ctx context.Context) ([]*lookout.QueueI return result, nil } -func (r *SQLJobRepository) getQueuesSql() (string, error) { +func (r *SQLJobRepository) getQueuesSql() (rowsSql, error) { countsDs := r.goquDb. From(jobTable). Select( @@ -91,7 +125,6 @@ func (r *SQLJobRepository) getQueuesSql() (string, error) { jobRun_started). Distinct(job_queue). Where(job_state.Eq(JobStateToIntMap[JobRunning])). - Order(job_queue.Asc(), jobRun_started.Asc()). As("longest_running_sub") // Identify longest Running jobs longestRunningDs := r.goquDb. @@ -111,53 +144,43 @@ func (r *SQLJobRepository) getQueuesSql() (string, error) { jobRun_created, jobRun_started, jobRun_finished). + Order(jobRun_runId.Asc(), jobRun_started.Asc()). As("longest_running") countsSql, _, err := countsDs.ToSQL() if err != nil { - return "", err + return rowsSql{}, err } oldestQueuedSql, _, err := oldestQueuedDs.ToSQL() if err != nil { - return "", err + return rowsSql{}, err } longestRunningSql, _, err := longestRunningDs.ToSQL() if err != nil { - return "", err + return rowsSql{}, err } - - // Execute three unprepared statements sequentially. - // There are no parameters and we don't care if updates happen between queries. - return strings.Join([]string{countsSql, oldestQueuedSql, longestRunningSql}, " ; "), nil + return rowsSql{countsSql, oldestQueuedSql, longestRunningSql}, nil } -func (r *SQLJobRepository) rowsToQueues(rows *sql.Rows) ([]*lookout.QueueInfo, error) { +func (r *SQLJobRepository) rowsToQueues(counts *sql.Rows, oldestQueued *sql.Rows, longestRunning *sql.Rows) ([]*lookout.QueueInfo, error) { queueInfoMap := make(map[string]*lookout.QueueInfo) // Job counts - err := setJobCounts(rows, queueInfoMap) + err := setJobCounts(counts, queueInfoMap) if err != nil { return nil, err } // Oldest queued - if rows.NextResultSet() { - err = r.setOldestQueuedJob(rows, queueInfoMap) - if err != nil { - return nil, err - } - } else if rows.Err() != nil { - return nil, fmt.Errorf("expected result set for oldest queued job: %v", rows.Err()) + err = r.setOldestQueuedJob(oldestQueued, queueInfoMap) + if err != nil { + return nil, err } // Longest Running - if rows.NextResultSet() { - err = r.setLongestRunningJob(rows, queueInfoMap) - if err != nil { - return nil, err - } - } else if rows.Err() != nil { - return nil, fmt.Errorf("expected result set for longest Running job: %v", rows.Err()) + err = r.setLongestRunningJob(longestRunning, queueInfoMap) + if err != nil { + return nil, err } result := getSortedQueueInfos(queueInfoMap) From 68c83b57c48752c3e619e8c83b5f4cf0977ccd93 Mon Sep 17 00:00:00 2001 From: "awsdesktop\\chrisma" Date: Mon, 11 Apr 2022 20:05:39 +0100 Subject: [PATCH 5/5] fix test --- internal/lookout/repository/queues.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/lookout/repository/queues.go b/internal/lookout/repository/queues.go index 881e0c963fb..3f655eb65c7 100644 --- a/internal/lookout/repository/queues.go +++ b/internal/lookout/repository/queues.go @@ -125,6 +125,7 @@ func (r *SQLJobRepository) getQueuesSql() (rowsSql, error) { jobRun_started). Distinct(job_queue). Where(job_state.Eq(JobStateToIntMap[JobRunning])). + Order(job_queue.Asc(), jobRun_started.Asc()). As("longest_running_sub") // Identify longest Running jobs longestRunningDs := r.goquDb.