def _SubmitBuild(build, image, project, parallel_build): """Builds and pushes a set of docker images. Args: build: A fixed up Build object. image: docker_image.Image, A docker image. project: str, The project being deployed to. parallel_build: bool, if True, enable parallel build and deploy. Returns: BuildArtifact, Representing the pushed container image or in-progress build. """ build_timeout = cloud_build.GetServiceTimeoutSeconds( properties.VALUES.app.cloud_build_timeout.Get()) if build_timeout and build_timeout > MAX_PARALLEL_BUILD_TIME: parallel_build = False log.info( 'Property cloud_build_timeout configured to [{0}], which exceeds ' 'the maximum build time for parallelized beta deployments of [{1}] ' 'seconds. Performing serial deployment.'.format( build_timeout, MAX_PARALLEL_BUILD_TIME)) if parallel_build: metrics.CustomTimedEvent(metric_names.CLOUDBUILD_EXECUTE_ASYNC_START) build_op = cloudbuild_build.CloudBuildClient().ExecuteCloudBuildAsync( build, project=project) return app_build.BuildArtifact.MakeBuildIdArtifactFromOp(build_op) else: metrics.CustomTimedEvent(metric_names.CLOUDBUILD_EXECUTE_START) cloudbuild_build.CloudBuildClient().ExecuteCloudBuild(build, project=project) metrics.CustomTimedEvent(metric_names.CLOUDBUILD_EXECUTE) return app_build.BuildArtifact.MakeImageArtifact(image.tagged_repo)
def testGetServiceTimeoutSeconds(self, expected, timeout): self.assertEqual(expected, cloud_build.GetServiceTimeoutSeconds(timeout))