From 148c54ed941b9373f6e1a1b3a0b5df6edb8e7aef Mon Sep 17 00:00:00 2001 From: Dana Dahlstrom Date: Tue, 7 Jan 2025 07:00:00 -0800 Subject: [PATCH] Remove unused and unneeded code Issue: 365150653 Reviewed-on: https://github.com/youtube/cobalt/pull/4675 --- cobalt/devinfra/kokoro/bin/dind_py/utils.py | 17 ----------------- .../devinfra/kokoro/bin/dind_py/utils_test.py | 2 -- 2 files changed, 19 deletions(-) diff --git a/cobalt/devinfra/kokoro/bin/dind_py/utils.py b/cobalt/devinfra/kokoro/bin/dind_py/utils.py index cd7eb8c11adc6..b9ca134063440 100644 --- a/cobalt/devinfra/kokoro/bin/dind_py/utils.py +++ b/cobalt/devinfra/kokoro/bin/dind_py/utils.py @@ -26,14 +26,12 @@ _REGISTRY_PATH_VAR = 'REGISTRY_PATH' _REGISTRY_IMAGE_VAR = 'REGISTRY_IMAGE_NAME' _PLATFORM_VAR = 'PLATFORM' -_KOKORO_BUILD_NUM_VAR = 'KOKORO_BUILD_NUMBER' _WORKSPACE_COBALT_VAR = 'WORKSPACE_COBALT' # These values are used to determine Floating Tag parameters for images used in # Docker/Cobalt build steps. _BASE_BRANCH_VAR = 'KOKORO_GOB_BRANCH_src' _GERRIT_CHANGE_NUMBER_VAR = 'KOKORO_GERRIT_CHANGE_NUMBER_src' -_GERRIT_PATCH_NUMBER_VAR = 'KOKORO_GERRIT_PATCHSET_NUMBER_src' _KOKORO_JOB_TYPE_VAR = 'KOKORO_ROOT_JOB_TYPE' @@ -55,9 +53,6 @@ class EnvArgs(object): # Target platform to build Cobalt for platform = None - # The cardinal number of the Kokoro job being run - build_num = None - # Path to the checkout of Cobalt repo's root src_root = '' @@ -79,12 +74,6 @@ class EnvArgs(object): # reused for image build cache purposes when running presubmit tests. gerrit_change_number = '' - # This value is the current iteration of the changelist uploaded to Gerrit. - # Whenever new changes are made to an existing CL, it will increment this - # value from 1 onwards. This is not used in the floating tag, but can help - # uniquely identify Kokoro jobs running on the same CL. - gerrit_change_patch = '' - # Whether the root job of the Kokoro job chain that triggered this build is a # postsubmit card. This controls what type of floating tag is applied to any # built docker image. @@ -99,7 +88,6 @@ def __init__(self): if self.registry_img is None: self.registry_img = f'cobalt-build-{self.platform}' - self.build_num = os.environ[_KOKORO_BUILD_NUM_VAR] self.src_root = os.environ[_WORKSPACE_COBALT_VAR] self.base_branch_name = os.environ.get(_BASE_BRANCH_VAR) # Normalize LTS branch names: 24.lts.1+ => 24_lts @@ -108,14 +96,9 @@ def __init__(self): raise ValueError('Branch name was not set in the environment.') self.gerrit_change_number = int( os.environ.get(_GERRIT_CHANGE_NUMBER_VAR, 0)) - self.gerrit_change_patch = int(os.environ.get(_GERRIT_PATCH_NUMBER_VAR, 0)) job_type = os.environ.get(_KOKORO_JOB_TYPE_VAR, '') self.is_postsubmit = job_type in ['CONTINUOUS_INTEGRATION', 'RELEASE'] - if (not self.is_postsubmit) and (self.gerrit_change_number == 0 or - self.gerrit_change_patch == 0): - raise ValueError( - 'Gerrit change number/patch not set in environment for presubmits.') def get_args_from_env(): diff --git a/cobalt/devinfra/kokoro/bin/dind_py/utils_test.py b/cobalt/devinfra/kokoro/bin/dind_py/utils_test.py index 01796d8464536..3fe43de9d66b7 100644 --- a/cobalt/devinfra/kokoro/bin/dind_py/utils_test.py +++ b/cobalt/devinfra/kokoro/bin/dind_py/utils_test.py @@ -40,7 +40,6 @@ def tearDown(self): 'REGISTRY_PATH': 'us-central1-docker.pkg.dev', 'REGISTRY_IMAGE_NAME': 'docker-build-failure', 'PLATFORM': 'linux-x64x11', - 'KOKORO_BUILD_NUMBER': '999', 'WORKSPACE_COBALT': '/tmp' }, clear=True) @@ -50,7 +49,6 @@ def test_get_args_from_env(self): self.assertEqual(args.registry_path, 'us-central1-docker.pkg.dev') self.assertEqual(args.registry_img, 'docker-build-failure') self.assertEqual(args.platform, 'linux-x64x11') - self.assertEqual(args.build_num, '999') self.assertEqual(args.src_root, '/tmp') @mock.patch('subprocess.check_output')