Skip to content

[spring-cloud] Refactor app create update and deploy logic#4266

Merged
zhoxing-ms merged 9 commits intoAzure:mainfrom
VSChina:yuwzho/refactor-app
Dec 30, 2021
Merged

[spring-cloud] Refactor app create update and deploy logic#4266
zhoxing-ms merged 9 commits intoAzure:mainfrom
VSChina:yuwzho/refactor-app

Conversation

@yuwzho
Copy link
Copy Markdown
Contributor

@yuwzho yuwzho commented Dec 28, 2021


This PR refactors the logic when app create, app deploy, app update and deployment create.

This PR will NOT upgrade the version and will update together with other PRs.

App's command usually operates an Spring/Apps and the active Spring/Apps/Deployments under the app.
The general idea of these command is putting all input command in parameter dict and let the Resource factory to construct the payload.

  • _app_factory construct the App's properties
  • _deployment_factory construct the Deployment's properties, which includes source and other settings.
  • There are 5 types for different deployment source types, here use _deployment_source_factory to construct the payload according to the source_type
  • A deployment must consume a path can be deployable, it can be a relative path, custom container or build result resource id,
    • _deployment_deployable_factory determines the deployable type and upload necessary binary/code to the service when constructing the deployable_path.
    • _deployment_uploadable_factory will upload the local file to a given destination, or compress the local folder and upload according to the parameter.

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

g.custom_command('repo list', 'config_repo_list')

with self.command_group('spring-cloud app', client_factory=cf_spring_cloud_20220101preview,
with self.command_group('spring-cloud app', custom_command_type=app_command,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 4 commands' traffic will be routing to the app.py

  • spring-cloud app create
  • spring-cloud app update
  • spring-cloud app deploy
  • spring-cloud app deployment create

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Dec 28, 2021

spring-cloud

@yuwzho
Copy link
Copy Markdown
Contributor Author

yuwzho commented Dec 29, 2021

ready_to_review

Comment on lines +53 to +58
raise CLIError("Failed to get a SAS URL to upload context.")
return response
except CloudError as e:
raise CLIError("Failed to get a SAS URL to upload context. Error: {}".format(e.message))
except AttributeError as e:
raise CLIError("Failed to get a SAS URL to upload context. Error: {}".format(e))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the specific error type instead of CLIError

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

app,
build).properties.triggered_build_result.id
except (AttributeError, CloudError) as e:
raise CLIError("Failed to create or update a build. Error: {}".format(e.message))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


if result.properties.provisioning_state != "Succeeded":
log_url = self._try_get_build_log_url(build_result_id)
raise CLIError("Failed to build docker image, please check the build logs {} and retry.".format(log_url))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

# ignore
return
if app:
raise CLIError('App {} already exist.'.format(app.id))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

from azure.core.exceptions import (ResourceNotFoundError)
from ._client_factory import cf_spring_cloud
from ._resource_quantity import (validate_cpu as validate_cpu_value, validate_memory as validate_memory_value)
from ._client_factory import cf_spring_cloud_20220101preview
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why did you add the api-version number to the name of _client_factory ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here follows the current implementation about client factory. The default client factory uses the latest stable API version. But some features in previewed is only available in preview API version. Ideally, we, service team will flush all preview features in a new stable API version, at that time, we can remove the factory_preview_api_version and replace them as the new default client factory.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks

@zhoxing-ms zhoxing-ms merged commit 47c9f28 into Azure:main Dec 30, 2021
@yuwzho yuwzho deleted the yuwzho/refactor-app branch December 30, 2021 07:43
@yuwzho
Copy link
Copy Markdown
Contributor Author

yuwzho commented Jan 5, 2022

#4294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants