Merge ~cjwatson/launchpad:db-builder-resources into launchpad:db-devel

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: cb3f1912c2c338e3b4e64fe797ae0f217759c6eb
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:db-builder-resources
Merge into: launchpad:db-devel
Diff against target: 25 lines (+19/-0)
1 file modified
database/schema/patch-2211-13-0.sql (+19/-0)
Reviewer Review Type Date Requested Status
William Grant db Approve
Andrey Fedoseev (community) Approve
Review via email: mp+433377@code.launchpad.net

This proposal supersedes a proposal from 2022-11-17.

Commit message

Add columns for builder resources and constraints

Description of the change

This will allow us to mark some builders as having extra hardware resources available to them, and to mark certain Git repositories as requiring those for their CI builds. (If necessary, this could be extended to other build types in future.) This amounts to partitioning the build farm, and we should do that cautiously to avoid reducing overall throughput too much; however, we don't always have a practical alternative, and our build farm is much better-provisioned than it used to be.

The distinction between open and restricted resources allows us to mark some builders as having extra features that might be required by some builds but as being available for use by other builds (e.g. we might put "large" builders in this category), while also having some builders that may only be used by builds that need their features (e.g. we might put specialized GPU hardware in this category).

To post a comment you must log in.
Revision history for this message
Andrey Fedoseev (andrey-fedoseev) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Andrey Fedoseev (andrey-fedoseev) wrote :

Colin,

Have you considered using arrays instead of `jsonb` for the new columns?

Revision history for this message
Colin Watson (cjwatson) wrote :

It mostly just didn't really occur to me, because my basic mental model nowadays has `jsonb` as being sufficiently capable that I can drop it in as a replacement for things like that.

Are you thinking of arrays because they're more strongly-typed? One concern I have is that I'm not 100% sure that this simple resources/constraints system will be entirely sufficient in the long term; with `jsonb` it would be fairly easy to extend the array elements to be something more sophisticated than strings if we needed to.

Revision history for this message
Andrey Fedoseev (andrey-fedoseev) wrote :

I don't have strong preference for using arrays here.

I actually used `jsonb` in a similar case (https://code.launchpad.net/~andrey-fedoseev/launchpad/+git/launchpad/+merge/423916), but then changed it to `text[]` following William's suggestion here https://chat.canonical.com/canonical/pl/pztnxzshp7gqpxtigi1xh5y1hc

I defer this to William :)

review: Approve
Revision history for this message
William Grant (wgrant) :
review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2211-13-0.sql b/database/schema/patch-2211-13-0.sql
2new file mode 100644
3index 0000000..56fa9a1
4--- /dev/null
5+++ b/database/schema/patch-2211-13-0.sql
6@@ -0,0 +1,19 @@
7+-- Copyright 2022 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+ALTER TABLE Builder
13+ ADD COLUMN open_resources jsonb,
14+ ADD COLUMN restricted_resources jsonb;
15+ALTER TABLE BuildQueue ADD COLUMN builder_constraints jsonb;
16+ALTER TABLE CIBuild ADD COLUMN builder_constraints jsonb;
17+ALTER TABLE GitRepository ADD COLUMN builder_constraints jsonb;
18+
19+COMMENT ON COLUMN Builder.open_resources IS 'An array of resource tags offered by this builder, that can be required by a build and if required must match.';
20+COMMENT ON COLUMN Builder.restricted_resources IS 'An array of resource tags offered by this builder, indicating that the builder may only be used by builds that explicitly require these tags.';
21+COMMENT ON COLUMN BuildQueue.builder_constraints IS 'An array of builder resource tags required by the associated build farm job.';
22+COMMENT ON COLUMN CIBuild.builder_constraints IS 'An array of builder resource tags required by this CI build.';
23+COMMENT ON COLUMN GitRepository.builder_constraints IS 'An array of builder resource tags required by builds of this repository.';
24+
25+INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 13, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: