Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[containerapp] 'az containerapp create/update/up': don't compress jar/war/zip file before upload source code; update source to cloud builder to 20240124.1 #7227

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/containerapp/azext_containerapp/_cloud_build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long, too-many-locals, missing-timeout, too-many-statements, consider-using-with, too-many-branches

import shutil
KaiqianYang marked this conversation as resolved.
Show resolved Hide resolved
from threading import Thread
import os
import re
Expand All @@ -18,6 +19,7 @@
from ._archive_utils import archive_source_code

from ._clients import BuilderClient, BuildClient
import mimetypes

from ._utils import (
log_in_file,
Expand Down Expand Up @@ -128,27 +130,32 @@ def spin():

# Source code compression
done_spinner = False
thread = display_spinner(f"Compressing data: {font_bold}{source}{font_default}")
tar_file_path = os.path.join(tempfile.gettempdir(), f"{build_name}.tar.gz")
archive_source_code(tar_file_path, source)
source_file_path = source
KaiqianYang marked this conversation as resolved.
Show resolved Hide resolved
if os.path.isdir(source):
thread = display_spinner(f"Compressing data: {font_bold}{source}{font_default}")
source_file_path = os.path.join(tempfile.gettempdir(), f"{build_name}.tar.gz")
archive_source_code(source_file_path, source)
done_spinner = True
thread.join()
KaiqianYang marked this conversation as resolved.
Show resolved Hide resolved

# File upload
done_spinner = False
thread = display_spinner("Uploading compressed data")
thread = display_spinner("Uploading data")
headers = {'Authorization': 'Bearer ' + token}
try:
tar_file = open(tar_file_path, "rb")
files = [("file", ("build_data.tar.gz", tar_file, "application/x-tar"))]
source_file = open(source_file_path, "rb")
file_extension = os.path.splitext(source_file_path)[1]
KaiqianYang marked this conversation as resolved.
Show resolved Hide resolved
files = [("file", ("build_data" + file_extension, source_file))]
KaiqianYang marked this conversation as resolved.
Show resolved Hide resolved
response_file_upload = requests.post(
upload_endpoint,
files=files,
headers=headers)
finally:
# Close and delete the file now that it was uploaded.
tar_file.close()
os.unlink(tar_file_path)
# Close the file now that it was uploaded.
source_file.close()
# if the source file is tar.gz, delete the temp file
if file_extension == ".tar.gz":
KaiqianYang marked this conversation as resolved.
Show resolved Hide resolved
os.unlink(source_file_path)
if not response_file_upload.ok:
raise ValidationError(f"Error when uploading the file, request exited with {response_file_upload.status_code}")
done_spinner = True
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interactions:
ParameterSetName:
- -g -n
User-Agent:
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22631-SP0)
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.App?api-version=2022-09-01
response:
Expand Down Expand Up @@ -224,7 +224,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:29:53 GMT
- Fri, 12 Jan 2024 08:09:56 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -252,25 +252,25 @@ interactions:
ParameterSetName:
- -g -n
User-Agent:
- python/3.10.11 (Windows-10-10.0.22631-SP0) AZURECLI/2.56.0
- python/3.10.11 (Windows-10-10.0.22621-SP0) AZURECLI/2.56.0
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/client.env_rg_northcentralusstage/providers/Microsoft.App/managedEnvironments/env-northcentralusstage?api-version=2023-11-02-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/client.env_rg_eastasia/providers/Microsoft.App/managedEnvironments/env-eastasia?api-version=2023-08-01-preview
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/client.env_rg_northcentralusstage/providers/Microsoft.App/managedEnvironments/env-northcentralusstage","name":"env-northcentralusstage","type":"Microsoft.App/managedEnvironments","location":"North
Central US (Stage)","systemData":{"createdBy":"[email protected]","createdByType":"User","createdAt":"2023-11-20T08:08:11.0019945","lastModifiedBy":"[email protected]","lastModifiedByType":"User","lastModifiedAt":"2023-11-20T08:08:11.0019945"},"properties":{"provisioningState":"Succeeded","daprAIInstrumentationKey":null,"daprAIConnectionString":null,"vnetConfiguration":null,"defaultDomain":"salmonpond-ed867706.northcentralusstage.azurecontainerapps.io","staticIp":"20.221.43.228","appLogsConfiguration":{"destination":null,"logAnalyticsConfiguration":null},"openTelemetryConfiguration":null,"zoneRedundant":false,"kedaConfiguration":{"version":"2.12.0"},"daprConfiguration":{"version":"1.11.6"},"eventStreamEndpoint":"https://northcentralusstage.azurecontainerapps.dev/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/client.env_rg_northcentralusstage/managedEnvironments/env-northcentralusstage/eventstream","customDomainConfiguration":{"customDomainVerificationId":"D3F71C85EB6552E36A89A3E4A080C3CFB00181670B659B0003264FC673AA9B00","dnsSuffix":null,"certificateKeyVaultProperties":null,"certificateValue":null,"certificatePassword":null,"thumbprint":null,"subjectName":null,"expirationDate":null},"workloadProfiles":[{"workloadProfileType":"Consumption","name":"Consumption"}],"appInsightsConfiguration":null,"infrastructureResourceGroup":null,"peerAuthentication":{"mtls":{"enabled":false}}}}'
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/client.env_rg_eastasia/providers/Microsoft.App/managedEnvironments/env-eastasia","name":"env-eastasia","type":"Microsoft.App/managedEnvironments","location":"East
Asia","systemData":{"createdBy":"[email protected]","createdByType":"User","createdAt":"2024-01-08T04:23:57.0848447","lastModifiedBy":"[email protected]","lastModifiedByType":"User","lastModifiedAt":"2024-01-08T04:23:57.0848447"},"properties":{"provisioningState":"Succeeded","daprAIInstrumentationKey":null,"daprAIConnectionString":null,"vnetConfiguration":null,"defaultDomain":"happyforest-bbc3d880.eastasia.azurecontainerapps.io","staticIp":"20.239.108.247","appLogsConfiguration":{"destination":null,"logAnalyticsConfiguration":null},"openTelemetryConfiguration":null,"zoneRedundant":false,"kedaConfiguration":{"version":"2.12.0"},"daprConfiguration":{"version":"1.11.6"},"eventStreamEndpoint":"https://eastasia.azurecontainerapps.dev/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/client.env_rg_eastasia/managedEnvironments/env-eastasia/eventstream","customDomainConfiguration":{"customDomainVerificationId":"0674969772E03EB0DD7BBCAE645CC3BE5D0663C94605C1ED83DBE7FAF0E5C9E4","dnsSuffix":null,"certificateValue":null,"certificatePassword":null,"thumbprint":null,"subjectName":null,"expirationDate":null},"workloadProfiles":[{"workloadProfileType":"Consumption","name":"Consumption"}],"appInsightsConfiguration":null,"infrastructureResourceGroup":null,"peerAuthentication":{"mtls":{"enabled":false}}}}'
headers:
api-supported-versions:
- 2022-03-01, 2022-06-01-preview, 2022-10-01, 2022-11-01-preview, 2023-04-01-preview,
2023-05-01, 2023-05-02-preview, 2023-08-01-preview, 2023-11-02-preview
cache-control:
- no-cache
content-length:
- '1699'
- '1564'
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:29:55 GMT
- Fri, 12 Jan 2024 08:09:56 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -304,7 +304,7 @@ interactions:
ParameterSetName:
- -g -n --environment --repo --environment-type
User-Agent:
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22631-SP0)
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.App?api-version=2022-09-01
response:
Expand Down Expand Up @@ -515,7 +515,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:29:56 GMT
- Fri, 12 Jan 2024 08:09:58 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -543,7 +543,7 @@ interactions:
ParameterSetName:
- -g -n --yes
User-Agent:
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22631-SP0)
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.App?api-version=2022-09-01
response:
Expand Down Expand Up @@ -754,7 +754,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:29:58 GMT
- Fri, 12 Jan 2024 08:09:58 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -784,17 +784,17 @@ interactions:
ParameterSetName:
- -g -n --yes
User-Agent:
- python/3.10.11 (Windows-10-10.0.22631-SP0) AZURECLI/2.56.0
- python/3.10.11 (Windows-10-10.0.22621-SP0) AZURECLI/2.56.0
method: DELETE
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps/containerapp000002?api-version=2023-11-02-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps/containerapp000002?api-version=2023-08-01-preview
response:
body:
string: ''
headers:
cache-control:
- no-cache
date:
- Thu, 11 Jan 2024 08:29:58 GMT
- Fri, 12 Jan 2024 08:10:00 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -822,7 +822,7 @@ interactions:
ParameterSetName:
- -g
User-Agent:
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22631-SP0)
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.App?api-version=2022-09-01
response:
Expand Down Expand Up @@ -1033,7 +1033,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:30:00 GMT
- Fri, 12 Jan 2024 08:10:00 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -1061,9 +1061,9 @@ interactions:
ParameterSetName:
- -g
User-Agent:
- python/3.10.11 (Windows-10-10.0.22631-SP0) AZURECLI/2.56.0
- python/3.10.11 (Windows-10-10.0.22621-SP0) AZURECLI/2.56.0
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps?api-version=2023-11-02-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps?api-version=2023-08-01-preview
response:
body:
string: '{"value":[]}'
Expand All @@ -1075,7 +1075,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:30:01 GMT
- Fri, 12 Jan 2024 08:10:00 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -1103,7 +1103,7 @@ interactions:
ParameterSetName:
- -g -n --yes
User-Agent:
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22631-SP0)
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.App?api-version=2022-09-01
response:
Expand Down Expand Up @@ -1314,7 +1314,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:30:02 GMT
- Fri, 12 Jan 2024 08:10:02 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -1344,17 +1344,17 @@ interactions:
ParameterSetName:
- -g -n --yes
User-Agent:
- python/3.10.11 (Windows-10-10.0.22631-SP0) AZURECLI/2.56.0
- python/3.10.11 (Windows-10-10.0.22621-SP0) AZURECLI/2.56.0
method: DELETE
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/managedEnvironments/env-northcentralusstage?api-version=2023-11-02-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/managedEnvironments/env-eastasia?api-version=2023-08-01-preview
response:
body:
string: ''
headers:
cache-control:
- no-cache
date:
- Thu, 11 Jan 2024 08:30:03 GMT
- Fri, 12 Jan 2024 08:10:02 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -1382,7 +1382,7 @@ interactions:
ParameterSetName:
- -g
User-Agent:
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22631-SP0)
- AZURECLI/2.56.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.11 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.App?api-version=2022-09-01
response:
Expand Down Expand Up @@ -1593,7 +1593,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:30:04 GMT
- Fri, 12 Jan 2024 08:10:04 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -1621,9 +1621,9 @@ interactions:
ParameterSetName:
- -g
User-Agent:
- python/3.10.11 (Windows-10-10.0.22631-SP0) AZURECLI/2.56.0
- python/3.10.11 (Windows-10-10.0.22621-SP0) AZURECLI/2.56.0
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/managedEnvironments?api-version=2023-11-02-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/managedEnvironments?api-version=2023-08-01-preview
response:
body:
string: '{"value":[]}'
Expand All @@ -1635,7 +1635,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 11 Jan 2024 08:30:05 GMT
- Fri, 12 Jan 2024 08:10:05 GMT
expires:
- '-1'
pragma:
Expand Down
Loading
Loading