Skip to content

Commit 5cf5ba3

Browse files
committed
core-services/prow/02_config/generate-boskos: For spitting out lots of names
Quotas for some providers depend on both account-scoped resources (e.g. AWS elastic IPs default to five per account [1]), region-scoped resources (e.g. AWS VPCs default to five per region [1]), potentialy other scoping (e.g. AWS NAT gateways default to five per availability zone [1]). This commit moves us away from account-scoped leases and towards region-scoped leases in account-scoped buckets. That allows us to say things like "on Azure, we have more capacity in centralus than we do in our other regions". The generating script is because typing out "us-east-1" 50 times is tedious and hard to review, and today there is apparently no support in the Boskos config directly to ask for $N copies of a given name. I'm also adding myself as an owner, so DPTP doesn't have to bother with lease adjustment. Other CI-platform maintainers should feel free to add themselves as well, if they want to approve lease adjustments to their platforms. Currently a mostly-no-op reshuffling of the exisiting Boskos config. The python-validation image follows the pattern set by the existing prow-config-semantics job. This script works with both Python 2 and Python 3, but I'm using python3 in the shebang because the verification image currently has 'python' pointed at Python 2 but only installs PyYAML for Python 3, and I've been unable to land a pivot to point it at Python 3 [2]. [1]: https://docs.openshift.com/container-platform/4.5/installing/installing_aws/installing-aws-account.html#installation-aws-limits_installing-aws-account [2]: #11869
1 parent dd9f7f1 commit 5cf5ba3

File tree

6 files changed

+200
-61
lines changed

6 files changed

+200
-61
lines changed

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL=/usr/bin/env bash -o errexit
22

3-
.PHONY: help check check-core check-services dry-core core dry-services services all
3+
.PHONY: help check check-boskos check-core check-services dry-core core dry-services services all
44

55
CONTAINER_ENGINE ?= docker
66

@@ -9,9 +9,13 @@ help:
99

1010
all: core services
1111

12-
check: check-core check-services
12+
check: check-core check-services check-boskos
1313
@echo "Service config check: PASS"
1414

15+
check-boskos:
16+
hack/validate-boskos.sh
17+
@echo "Boskos config check: PASS"
18+
1519
check-core:
1620
core-services/_hack/validate-core-services.sh core-services
1721
@echo "Core service config check: PASS"
@@ -38,6 +42,7 @@ services:
3842
update:
3943
$(MAKE) jobs
4044
$(MAKE) ci-operator-config
45+
$(MAKE) boskos-config
4146
$(MAKE) prow-config
4247
$(MAKE) registry-metadata
4348

@@ -59,6 +64,10 @@ registry-metadata:
5964
$(CONTAINER_ENGINE) pull registry.svc.ci.openshift.org/ci/generate-registry-metadata:latest
6065
$(CONTAINER_ENGINE) run --rm -v "$(CURDIR)/ci-operator/step-registry:/ci-operator/step-registry:z" registry.svc.ci.openshift.org/ci/generate-registry-metadata:latest --registry /ci-operator/step-registry
6166

67+
boskos-config:
68+
cd core-services/prow/02_config && ./generate-boskos.py
69+
.PHONY: boskos-config
70+
6271
prow-config:
6372
$(CONTAINER_ENGINE) pull registry.svc.ci.openshift.org/ci/determinize-prow-config:latest
6473
$(CONTAINER_ENGINE) run --rm -v "$(CURDIR)/core-services/prow/02_config:/config:z" registry.svc.ci.openshift.org/ci/determinize-prow-config:latest --prow-config-dir /config

ci-operator/jobs/openshift/release/openshift-release-master-presubmits.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ presubmits:
3838
cpu: 10m
3939
serviceAccountName: config-updater
4040
trigger: (?m)^/test( | .* )app-ci-config-dry,?($|\s.*)
41+
- agent: kubernetes
42+
always_run: true
43+
branches:
44+
- master
45+
cluster: build01
46+
context: ci/prow/boskos-config
47+
decorate: true
48+
labels:
49+
pj-rehearse.openshift.io/can-be-rehearsed: "true"
50+
name: pull-ci-openshift-release-master-boskos-config
51+
rerun_command: /test boskos-config
52+
spec:
53+
containers:
54+
- command:
55+
- hack/validate-boskos.sh
56+
image: registry.svc.ci.openshift.org/ci/python-validation
57+
imagePullPolicy: Always
58+
name: ""
59+
resources:
60+
requests:
61+
cpu: 10m
62+
trigger: (?m)^/test( | .* )boskos-config,?($|\s.*)
4163
- agent: kubernetes
4264
always_run: true
4365
branches:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
approvers:
2+
- dptp
3+
- wking
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,78 @@
1-
---
1+
# generated with generate-boskos.py; do not edit directly
22
resources:
3-
- type: aws-quota-slice
4-
state: free
3+
- max-count: 150
54
min-count: 150
6-
max-count: 150
7-
- type: azure4-quota-slice
85
state: free
6+
type: aws-quota-slice
7+
- max-count: 30
98
min-count: 30
10-
max-count: 30
11-
- type: gcp-quota-slice
129
state: free
10+
type: azure4-quota-slice
11+
- max-count: 120
1312
min-count: 120
14-
max-count: 120
15-
- type: libvirt-s390x-quota-slice
1613
state: free
17-
names:
18-
- "libvirt-s390x-0-0"
19-
- "libvirt-s390x-0-1"
20-
- "libvirt-s390x-0-2"
21-
- "libvirt-s390x-0-3"
22-
- "libvirt-s390x-0-4"
23-
- type: libvirt-ppc64le-quota-slice
14+
type: gcp-quota-slice
15+
- names:
16+
- libvirt-ppc64le-0-0
17+
- libvirt-ppc64le-0-1
18+
- libvirt-ppc64le-0-2
19+
- libvirt-ppc64le-0-3
20+
- libvirt-ppc64le-1-0
21+
- libvirt-ppc64le-1-1
22+
- libvirt-ppc64le-1-2
23+
- libvirt-ppc64le-1-3
2424
state: free
25-
names:
26-
- "libvirt-ppc64le-0-0"
27-
- "libvirt-ppc64le-0-1"
28-
- "libvirt-ppc64le-0-2"
29-
- "libvirt-ppc64le-0-3"
30-
- "libvirt-ppc64le-1-0"
31-
- "libvirt-ppc64le-1-1"
32-
- "libvirt-ppc64le-1-2"
33-
- "libvirt-ppc64le-1-3"
34-
- type: metal-quota-slice
25+
type: libvirt-ppc64le-quota-slice
26+
- names:
27+
- libvirt-s390x-0-0
28+
- libvirt-s390x-0-1
29+
- libvirt-s390x-0-2
30+
- libvirt-s390x-0-3
31+
- libvirt-s390x-0-4
3532
state: free
33+
type: libvirt-s390x-quota-slice
34+
- max-count: 1000
3635
min-count: 1000
37-
max-count: 1000
38-
- type: openstack-quota-slice
3936
state: free
37+
type: metal-quota-slice
38+
- names:
39+
- openstack-osuosl-ppc64le-01
40+
- openstack-osuosl-ppc64le-02
41+
- openstack-osuosl-ppc64le-03
42+
- openstack-osuosl-ppc64le-04
43+
state: free
44+
type: openstack-osuosl-ppc64le-quota-slice
45+
- names:
46+
- openstack-ppc64le-00
47+
- openstack-ppc64le-01
48+
- openstack-ppc64le-02
49+
- openstack-ppc64le-03
50+
state: free
51+
type: openstack-ppc64le-quota-slice
52+
- max-count: 7
4053
min-count: 7
41-
max-count: 7
42-
- type: openstack-vexxhost-quota-slice
4354
state: free
55+
type: openstack-quota-slice
56+
- max-count: 3
4457
min-count: 3
45-
max-count: 3
46-
- type: openstack-ppc64le-quota-slice
4758
state: free
48-
names:
49-
- "openstack-ppc64le-00"
50-
- "openstack-ppc64le-01"
51-
- "openstack-ppc64le-02"
52-
- "openstack-ppc64le-03"
53-
- type: openstack-osuosl-ppc64le-quota-slice
59+
type: openstack-vexxhost-quota-slice
60+
- names:
61+
- ovirt-10
62+
- ovirt-11
63+
- ovirt-12
64+
- ovirt-13
65+
- ovirt-14
66+
- ovirt-15
67+
- ovirt-16
68+
- ovirt-17
5469
state: free
55-
names:
56-
- "openstack-osuosl-ppc64le-01"
57-
- "openstack-osuosl-ppc64le-02"
58-
- "openstack-osuosl-ppc64le-03"
59-
- "openstack-osuosl-ppc64le-04"
60-
- type: vsphere-quota-slice
70+
type: ovirt-quota-slice
71+
- max-count: 20
72+
min-count: 20
6173
state: free
74+
type: packet-quota-slice
75+
- max-count: 10
6276
min-count: 10
63-
max-count: 10
64-
- type: ovirt-quota-slice
65-
state: free
66-
names:
67-
- "ovirt-10"
68-
- "ovirt-11"
69-
- "ovirt-12"
70-
- "ovirt-13"
71-
- "ovirt-14"
72-
- "ovirt-15"
73-
- "ovirt-16"
74-
- "ovirt-17"
75-
- type: packet-quota-slice
7677
state: free
77-
min-count: 20
78-
max-count: 20
78+
type: vsphere-quota-slice
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env python3
2+
3+
import yaml
4+
5+
6+
CONFIG = {
7+
'aws-quota-slice': {
8+
'default': 150,
9+
},
10+
'azure4-quota-slice': {
11+
'default': 30,
12+
},
13+
'gcp-quota-slice': {
14+
'default': 120,
15+
},
16+
'libvirt-s390x-quota-slice': {},
17+
'libvirt-ppc64le-quota-slice': {},
18+
'metal-quota-slice': {
19+
# Wild guesses. We'll see when we hit quota issues
20+
'default': 1000,
21+
},
22+
'openstack-osuosl-ppc64le-quota-slice': {},
23+
'openstack-quota-slice': {
24+
'default': 7,
25+
},
26+
'openstack-vexxhost-quota-slice': {
27+
'default': 3,
28+
},
29+
'openstack-ppc64le-quota-slice': {},
30+
'ovirt-quota-slice': {},
31+
'packet-quota-slice': {
32+
'default': 20,
33+
},
34+
'vsphere-quota-slice': {
35+
'default': 10,
36+
},
37+
}
38+
39+
for i in range(1):
40+
for j in range(5):
41+
CONFIG['libvirt-s390x-quota-slice']['libvirt-s390x-{}-{}'.format(i, j)] = 1
42+
43+
for i in range(2):
44+
for j in range(4):
45+
CONFIG['libvirt-ppc64le-quota-slice']['libvirt-ppc64le-{}-{}'.format(i, j)] = 1
46+
47+
for i in range(1, 5):
48+
CONFIG['openstack-osuosl-ppc64le-quota-slice']['openstack-osuosl-ppc64le-{0:0>2}'.format(i)] = 1
49+
50+
for i in range(4):
51+
CONFIG['openstack-ppc64le-quota-slice']['openstack-ppc64le-{0:0>2}'.format(i)] = 1
52+
53+
for i in range(10, 18):
54+
CONFIG['ovirt-quota-slice']['ovirt-{}'.format(i)] = 1
55+
56+
config = {
57+
'resources': [],
58+
}
59+
60+
for typeName, data in sorted(CONFIG.items()):
61+
resource = {
62+
'type': typeName,
63+
'state': 'free',
64+
}
65+
if set(data.keys()) == {'default'}:
66+
resource['min-count'] = resource['max-count'] = data['default']
67+
else:
68+
resource['names'] = []
69+
for name, count in sorted(data.items()):
70+
resource['names'].extend([name]*count)
71+
config['resources'].append(resource)
72+
73+
with open('_boskos.yaml', 'w') as f:
74+
f.write('# generated with generate-boskos.py; do not edit directly\n')
75+
yaml.dump(config, f, default_flow_style=False)

hack/validate-boskos.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# This script ensures that the Boskos configuration checked into git is up-to-date
4+
# with the generator. If it is not, re-generate the configuration to update it.
5+
6+
set -o errexit
7+
set -o nounset
8+
set -o pipefail
9+
10+
base_dir=.
11+
12+
cd "${base_dir}/core-services/prow/02_config"
13+
./generate-boskos.py
14+
DIFF="$(git diff)"
15+
if test -n "${DIFF}"
16+
then
17+
cat << EOF
18+
ERROR: This check enforces that the Boskos configuration is generated
19+
ERROR: correctly. We have automation in place that updates the configuration and
20+
ERROR: new changes to the configuration should be followed with a re-generation.
21+
22+
ERROR: Run the following command to re-generate the Boskos configuration:
23+
ERROR: $ make boskos-config
24+
25+
ERROR: The following errors were found:
26+
27+
EOF
28+
echo "${DIFF}"
29+
exit 1
30+
fi

0 commit comments

Comments
 (0)