From 1c2790cf2fb24060e386610c3fa66fd61601215e Mon Sep 17 00:00:00 2001 From: Qingyi Liu Date: Thu, 14 Oct 2021 14:49:21 +0800 Subject: [PATCH 1/3] feat(kpack): add a parameter '--builder' when deploy app --- .../azext_spring_cloud/_enterprise.py | 15 ++++++++------- src/spring-cloud/azext_spring_cloud/_params.py | 2 ++ .../azext_spring_cloud/tier_routing_app.py | 3 ++- .../azext_spring_cloud/tier_routing_deployment.py | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_enterprise.py b/src/spring-cloud/azext_spring_cloud/_enterprise.py index fa4223f39fc..8103f188b38 100644 --- a/src/spring-cloud/azext_spring_cloud/_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_enterprise.py @@ -105,7 +105,7 @@ def app_update_enterprise(cmd, client, resource_group, service, name, def app_deploy_enterprise(cmd, client, resource_group, service, name, - version, deployment, artifact_path, target_module, jvm_options, + version, deployment, artifact_path, builder, target_module, jvm_options, env, config_file_patterns, no_wait): '''app_deploy_enterprise Deploy artifact to deployment under the existing app. @@ -122,7 +122,7 @@ def app_deploy_enterprise(cmd, client, resource_group, service, name, deployment = _deployment_or_active_deployment_name(client, resource_group, service, name, deployment) deployment_settings = _format_deployment_settings(jvm_options=jvm_options, env=env, config_file_patterns=config_file_patterns) - user_source_info = _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, target_module, additional_steps=1) + user_source_info = _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, builder, target_module, additional_steps=1) logger.warning("[5/5] Deploying the built docker image to deployment {} under app {}".format(deployment, name)) resource = models.DeploymentResource( properties=models.DeploymentResourceProperties( @@ -196,6 +196,7 @@ def deployment_create_enterprise(cmd, client, resource_group, service, app, name skip_clone_settings=False, version=None, artifact_path=None, + builder=None, target_module=None, jvm_options=None, cpu=None, @@ -213,7 +214,7 @@ def deployment_create_enterprise(cmd, client, resource_group, service, app, name jvm_options=jvm_options, env=env or origin_settings.environment_variables, config_file_patterns=config_file_patterns or _get_config_file_patterns(origin_settings.addon_configs)) - user_source_info = _build_and_get_result(cmd, client, resource_group, service, app, version, artifact_path, target_module, additional_steps=1) + user_source_info = _build_and_get_result(cmd, client, resource_group, service, app, version, builder, artifact_path, target_module, additional_steps=1) resource = models.DeploymentResource( properties=models.DeploymentResourceProperties( source=user_source_info, @@ -226,14 +227,14 @@ def deployment_create_enterprise(cmd, client, resource_group, service, app, name resource_group, service, app, name, resource) -def _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, target_module, additional_steps=0): +def _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, builder, target_module, additional_steps=0): total_steps = 4 + additional_steps logger.warning("[1/{}] Requesting for upload URL.".format(total_steps)) upload_url, relative_path = _request_upload_url(client, resource_group, service, name) logger.warning("[2/{}] Uploading package to blob.".format(total_steps)) _compress_and_upload(cmd, client, upload_url, artifact_path) logger.warning("[3/{}] Creating or Updating build '{}'.".format(total_steps, name)) - build_result_id = _queue_build(client, resource_group, service, name, relative_path, target_module) + build_result_id = _queue_build(client, resource_group, service, name, relative_path, builder, target_module) logger.warning("[4/{}] Waiting for building docker image to finish. This may take a few minutes.".format(total_steps)) _wait_build_finished(cmd, client, service, build_result_id) return models.BuildResultUserSourceInfo(version=version, build_result_id=build_result_id) @@ -304,9 +305,9 @@ def _is_build_result_still_building(build_result): return build_result.properties.status == "Building" or build_result.properties.status == "Queuing" -def _queue_build(client, resource_group, service, name, relative_path, target_module=None): +def _queue_build(client, resource_group, service, name, relative_path, builder=None, target_module=None): properties = models.BuildProperties( - builder="default-enterprise-builder", + builder= builder if builder else "default", relative_path=relative_path, env={"BP_MAVEN_BUILT_MODULE": target_module} if target_module else None) build = models.Build(properties=properties) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 5fb668a82a7..df011f35003 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -168,6 +168,8 @@ def prepare_logs_argument(c): c.argument( 'main_entry', options_list=[ '--main-entry', '-m'], help="A string containing the path to the .NET executable relative to zip root.") + c.argument( + 'builder', help="The name of builder. For enterprise private preview users, please use 'default-enterprise-builder'.") c.argument( 'target_module', help='Child module to be deployed, required for multiple jar packages built from source code.') c.argument( diff --git a/src/spring-cloud/azext_spring_cloud/tier_routing_app.py b/src/spring-cloud/azext_spring_cloud/tier_routing_app.py index a4efedc52f7..79e6e7f9aec 100644 --- a/src/spring-cloud/azext_spring_cloud/tier_routing_app.py +++ b/src/spring-cloud/azext_spring_cloud/tier_routing_app.py @@ -144,6 +144,7 @@ def app_deploy(cmd, client, resource_group, service, name, version=None, deployment=None, artifact_path=None, + builder=None, target_module=None, runtime_version=None, jvm_options=None, @@ -154,7 +155,7 @@ def app_deploy(cmd, client, resource_group, service, name, if is_enterprise_tier(cmd, resource_group, service): # runtime_version, assign_ideneity, main_entry not support return app_deploy_enterprise(cmd, get_client(cmd), resource_group, service, name, - version, deployment, artifact_path, target_module, + version, deployment, artifact_path, builder, target_module, jvm_options, env, config_file_patterns, no_wait) else: # config_file_patterns not support diff --git a/src/spring-cloud/azext_spring_cloud/tier_routing_deployment.py b/src/spring-cloud/azext_spring_cloud/tier_routing_deployment.py index b9d5b8c135f..d6cf31c22c2 100644 --- a/src/spring-cloud/azext_spring_cloud/tier_routing_deployment.py +++ b/src/spring-cloud/azext_spring_cloud/tier_routing_deployment.py @@ -38,6 +38,7 @@ def deployment_create(cmd, client, resource_group, service, app, name, skip_clone_settings=False, version=None, artifact_path=None, + builder=None, target_module=None, runtime_version=None, jvm_options=None, @@ -50,7 +51,7 @@ def deployment_create(cmd, client, resource_group, service, app, name, no_wait=False): if is_enterprise_tier(cmd, resource_group, service): return deployment_create_enterprise(cmd, get_client(cmd), resource_group, service, app, name, - skip_clone_settings, version, artifact_path, target_module, + skip_clone_settings, version, artifact_path, builder, target_module, jvm_options, cpu, memory, instance_count, env, config_file_patterns, no_wait) else: return deployment_create_standard(cmd, client, resource_group, service, app, name, From 25f11fab986183f0b62a064ecf1a6452d453e5ba Mon Sep 17 00:00:00 2001 From: Qingyi Liu Date: Thu, 14 Oct 2021 15:26:38 +0800 Subject: [PATCH 2/3] fix the word of help --- src/spring-cloud/azext_spring_cloud/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index df011f35003..7b7d394ca2a 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -169,7 +169,7 @@ def prepare_logs_argument(c): 'main_entry', options_list=[ '--main-entry', '-m'], help="A string containing the path to the .NET executable relative to zip root.") c.argument( - 'builder', help="The name of builder. For enterprise private preview users, please use 'default-enterprise-builder'.") + 'builder', help="The name of builder. By default, the builder name is 'default'.") c.argument( 'target_module', help='Child module to be deployed, required for multiple jar packages built from source code.') c.argument( From 8bfc1a8dfa7179cdf3729f957621adf3f816e99e Mon Sep 17 00:00:00 2001 From: Qingyi Liu Date: Thu, 14 Oct 2021 16:59:32 +0800 Subject: [PATCH 3/3] fix the default builder name --- src/spring-cloud/azext_spring_cloud/_enterprise.py | 2 +- src/spring-cloud/azext_spring_cloud/_params.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spring-cloud/azext_spring_cloud/_enterprise.py b/src/spring-cloud/azext_spring_cloud/_enterprise.py index 8103f188b38..465dfe07fbf 100644 --- a/src/spring-cloud/azext_spring_cloud/_enterprise.py +++ b/src/spring-cloud/azext_spring_cloud/_enterprise.py @@ -307,7 +307,7 @@ def _is_build_result_still_building(build_result): def _queue_build(client, resource_group, service, name, relative_path, builder=None, target_module=None): properties = models.BuildProperties( - builder= builder if builder else "default", + builder= builder, relative_path=relative_path, env={"BP_MAVEN_BUILT_MODULE": target_module} if target_module else None) build = models.Build(properties=properties) diff --git a/src/spring-cloud/azext_spring_cloud/_params.py b/src/spring-cloud/azext_spring_cloud/_params.py index 7b7d394ca2a..706932b77aa 100644 --- a/src/spring-cloud/azext_spring_cloud/_params.py +++ b/src/spring-cloud/azext_spring_cloud/_params.py @@ -169,7 +169,7 @@ def prepare_logs_argument(c): 'main_entry', options_list=[ '--main-entry', '-m'], help="A string containing the path to the .NET executable relative to zip root.") c.argument( - 'builder', help="The name of builder. By default, the builder name is 'default'.") + 'builder', help="The name of builder.", default="default") c.argument( 'target_module', help='Child module to be deployed, required for multiple jar packages built from source code.') c.argument(