[experiments] add check for experiment string length (#32827)

Since we are adding an annotation for experiments internally, we need to
ensure the length of the annotation does not exceed 2 KB (used slightly
lower number in the check). Added a check to gen_experiments.py for
this.
This commit is contained in:
Alisha Nanda 2023-04-07 10:46:52 -07:00 committed by GitHub
parent 4a4e2889a1
commit ffafac3ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -76,6 +76,7 @@ BZL_LIST_FOR_DEFAULTS = {
error = False
today = datetime.date.today()
two_quarters_from_now = today + datetime.timedelta(days=180)
experiment_annotation = 'gRPC experiments:'
for attr in attrs:
if 'name' not in attr:
print("experiment with no name: %r" % attr)
@ -108,6 +109,11 @@ for attr in attrs:
(attr['name'], attr['expiry']))
print("expiry should be no more than two quarters from now")
error = True
experiment_annotation += attr['name'] + ':0,'
if len(experiment_annotation) > 2000:
print("comma-delimited string of experiments is too long")
error = True
if error:
sys.exit(1)