From d4e4be4fd18d86826501e85e5f0195e49e2e3d1e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 27 Jul 2020 18:24:10 +0200 Subject: [PATCH] Remove SHA-1 hash from BuildProducts SHA-1 is deprecated and it will be expensive to compute with the streaming NAR handler. --- doc/manual/api.xml | 1 - hydra-api.yaml | 5 ----- src/hydra-queue-runner/build-result.cc | 1 - src/hydra-queue-runner/build-result.hh | 2 +- src/hydra-queue-runner/hydra-queue-runner.cc | 3 +-- src/hydra-queue-runner/queue-monitor.cc | 14 ++++++-------- src/lib/Hydra/Plugin/RunCommand.pm | 1 - src/lib/Hydra/Schema/BuildProducts.pm | 12 ++---------- src/root/product-list.tt | 1 - src/sql/hydra.sql | 1 - src/sql/upgrade-68.sql | 1 + 11 files changed, 11 insertions(+), 31 deletions(-) create mode 100644 src/sql/upgrade-68.sql diff --git a/doc/manual/api.xml b/doc/manual/api.xml index 6656d98b..db5ba07e 100644 --- a/doc/manual/api.xml +++ b/doc/manual/api.xml @@ -311,7 +311,6 @@ Content-Type: application/json "buildproducts": { "1": { "path": "/nix/store/lzrxkjc35mhp8w7r8h82g0ljyizfchma-vm-test-run-unnamed", - "sha1hash": null, "defaultpath": "log.html", "type": "report", "sha256hash": null, diff --git a/hydra-api.yaml b/hydra-api.yaml index 5a4e36a1..7da99eb8 100644 --- a/hydra-api.yaml +++ b/hydra-api.yaml @@ -672,10 +672,6 @@ components: name: description: Name of the file type: string - sha1hash: - nullable: true - description: sha1 hash of the file - type: string path: description: the nix store path type: string @@ -863,7 +859,6 @@ components: defaultpath: '' name: hello-2.10 type: nix-build - sha1hash: null sha256hash: null subtype: '' path: /nix/store/y26qxcq1gg2hrqpxdc58b2fghv2bhxjg-hello-2.10 diff --git a/src/hydra-queue-runner/build-result.cc b/src/hydra-queue-runner/build-result.cc index f11d0a7c..868ccb15 100644 --- a/src/hydra-queue-runner/build-result.cc +++ b/src/hydra-queue-runner/build-result.cc @@ -78,7 +78,6 @@ BuildOutput getBuildOutput(nix::ref store, product.isRegular = true; product.fileSize = st.fileSize; auto contents = accessor->readFile(product.path); - product.sha1hash = hashString(htSHA1, contents); product.sha256hash = hashString(htSHA256, contents); } diff --git a/src/hydra-queue-runner/build-result.hh b/src/hydra-queue-runner/build-result.hh index 72e8b4df..57676797 100644 --- a/src/hydra-queue-runner/build-result.hh +++ b/src/hydra-queue-runner/build-result.hh @@ -11,7 +11,7 @@ struct BuildProduct nix::Path path, defaultPath; std::string type, subtype, name; bool isRegular = false; - nix::Hash sha1hash, sha256hash; + nix::Hash sha256hash; off_t fileSize = 0; BuildProduct() { } }; diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 52ed1b23..0da14bcd 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -414,13 +414,12 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build, unsigned int productNr = 1; for (auto & product : res.products) { txn.exec_params0 - ("insert into BuildProducts (build, productnr, type, subtype, fileSize, sha1hash, sha256hash, path, name, defaultPath) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + ("insert into BuildProducts (build, productnr, type, subtype, fileSize, sha256hash, path, name, defaultPath) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)", build->id, productNr++, product.type, product.subtype, product.isRegular ? std::make_optional(product.fileSize) : std::nullopt, - product.isRegular ? std::make_optional(product.sha1hash.to_string(Base16, false)) : std::nullopt, product.isRegular ? std::make_optional(product.sha256hash.to_string(Base16, false)) : std::nullopt, product.path, product.name, diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc index 24f4d04e..5bfcb1eb 100644 --- a/src/hydra-queue-runner/queue-monitor.cc +++ b/src/hydra-queue-runner/queue-monitor.cc @@ -632,7 +632,7 @@ BuildOutput State::getBuildOutputCached(Connection & conn, nix::ref res.size = r[0][4].is_null() ? 0 : r[0][4].as(); auto products = txn.exec_params - ("select type, subtype, fileSize, sha1hash, sha256hash, path, name, defaultPath from BuildProducts where build = $1 order by productnr", + ("select type, subtype, fileSize, sha256hash, path, name, defaultPath from BuildProducts where build = $1 order by productnr", id); for (auto row : products) { @@ -646,14 +646,12 @@ BuildOutput State::getBuildOutputCached(Connection & conn, nix::ref product.fileSize = row[2].as(); } if (!row[3].is_null()) - product.sha1hash = Hash(row[3].as(), htSHA1); + product.sha256hash = Hash(row[3].as(), htSHA256); if (!row[4].is_null()) - product.sha256hash = Hash(row[4].as(), htSHA256); - if (!row[5].is_null()) - product.path = row[5].as(); - product.name = row[6].as(); - if (!row[7].is_null()) - product.defaultPath = row[7].as(); + product.path = row[4].as(); + product.name = row[5].as(); + if (!row[6].is_null()) + product.defaultPath = row[6].as(); res.products.emplace_back(product); } diff --git a/src/lib/Hydra/Plugin/RunCommand.pm b/src/lib/Hydra/Plugin/RunCommand.pm index f7ca45a9..8ae70c6f 100644 --- a/src/lib/Hydra/Plugin/RunCommand.pm +++ b/src/lib/Hydra/Plugin/RunCommand.pm @@ -90,7 +90,6 @@ sub buildFinished { type => $product->type, subtype => $product->subtype, fileSize => $product->filesize, - sha1hash => $product->sha1hash, sha256hash => $product->sha256hash, path => $product->path, name => $product->name, diff --git a/src/lib/Hydra/Schema/BuildProducts.pm b/src/lib/Hydra/Schema/BuildProducts.pm index f52b2937..788cc390 100644 --- a/src/lib/Hydra/Schema/BuildProducts.pm +++ b/src/lib/Hydra/Schema/BuildProducts.pm @@ -61,11 +61,6 @@ __PACKAGE__->table("buildproducts"); data_type: 'bigint' is_nullable: 1 -=head2 sha1hash - - data_type: 'text' - is_nullable: 1 - =head2 sha256hash data_type: 'text' @@ -99,8 +94,6 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0 }, "filesize", { data_type => "bigint", is_nullable => 1 }, - "sha1hash", - { data_type => "text", is_nullable => 1 }, "sha256hash", { data_type => "text", is_nullable => 1 }, "path", @@ -143,8 +136,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-02-06 12:22:36 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iI0gmKqQxiPBTy5QsM6tpQ +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-07-27 18:21:03 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:O4R8b/GukNaUmmAErb3Jlw my %hint = ( columns => [ @@ -152,7 +145,6 @@ my %hint = ( 'subtype', 'name', 'filesize', - 'sha1hash', 'sha256hash', 'path', 'defaultpath' diff --git a/src/root/product-list.tt b/src/root/product-list.tt index 298d0a66..efb3043b 100644 --- a/src/root/product-list.tt +++ b/src/root/product-list.tt @@ -191,7 +191,6 @@ [% INCLUDE renderProductLinks %] -
File size:[% product.filesize %] bytes ([% mibs(product.filesize / (1024 * 1024)) %] MiB)
SHA-1 hash:[% product.sha1hash %]
SHA-256 hash:[% product.sha256hash %]
Full path:[% product.path %]
diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index a0db622a..88c4c330 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -330,7 +330,6 @@ create table BuildProducts ( type text not null, -- "nix-build", "file", "doc", "report", ... subtype text not null, -- "source-dist", "rpm", ... fileSize bigint, - sha1hash text, sha256hash text, path text, name text not null, -- generally just the filename part of `path' diff --git a/src/sql/upgrade-68.sql b/src/sql/upgrade-68.sql new file mode 100644 index 00000000..368ed82b --- /dev/null +++ b/src/sql/upgrade-68.sql @@ -0,0 +1 @@ +alter table BuildProducts drop column sha1hash;