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

add support for termination grace period seconds #5058

Merged
merged 6 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Release History
===============
1.1.2
---
* Support configure Germination Grace Period Seconds for deployments.
* Fix the arguments parsing of the Command `az spring app create` with "--container-image".

1.1.1
Expand Down
6 changes: 3 additions & 3 deletions src/spring/azext_spring/_deployment_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def format_settings(self, **kwargs):
readiness_probe=self._format_readiness_probe(**kwargs)
)

def _get_termination_grace_period_seconds(self, termination_seconds=None, **_):
if termination_seconds is None:
def _get_termination_grace_period_seconds(self, termination_grace_period_seconds=None, **_):
if termination_grace_period_seconds is None:
return None
return termination_seconds
return termination_grace_period_seconds

def _format_startup_probe(self, enable_startup_probe=None, startup_probe_config_file_path=None, **_):
if enable_startup_probe is None:
Expand Down
3 changes: 3 additions & 0 deletions src/spring/azext_spring/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def load_arguments(self, _):
help='A json file path indicates the readiness probe config', arg_group='App Customization')
c.argument('startup_probe_config', type=str, is_preview=True,
help='A json file path indicates the startup probe config', arg_group='App Customization')
c.argument('termination_grace_period_seconds', type=str, is_preview=True,
options_list=['--termination-grace-period-seconds', '--grace-period'],
help='Optional duration in seconds the app instance needs to terminate gracefully', arg_group='App Customization')

with self.argument_context('spring app create') as c:
c.argument('assign_endpoint', arg_type=get_three_state_flag(),
Expand Down
8 changes: 8 additions & 0 deletions src/spring/azext_spring/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def app_create(cmd, client, resource_group, service, name,
liveness_probe_config=None,
readiness_probe_config=None,
startup_probe_config=None,
termination_grace_period_seconds=None,
assign_public_endpoint=None,
loaded_public_certificate_file=None):
'''app_create
Expand Down Expand Up @@ -104,6 +105,7 @@ def app_create(cmd, client, resource_group, service, name,
'liveness_probe_config_file_path': liveness_probe_config,
'readiness_probe_config_file_path': readiness_probe_config,
'startup_probe_config_file_path': startup_probe_config,
'termination_grace_period_seconds': termination_grace_period_seconds,
}
update_app_kwargs = {
'enable_persistent_storage': enable_persistent_storage,
Expand Down Expand Up @@ -163,6 +165,7 @@ def app_update(cmd, client, resource_group, service, name,
liveness_probe_config=None,
readiness_probe_config=None,
startup_probe_config=None,
termination_grace_period_seconds=None,
# general
no_wait=False):
'''app_update
Expand Down Expand Up @@ -196,6 +199,7 @@ def app_update(cmd, client, resource_group, service, name,
'liveness_probe_config_file_path': liveness_probe_config,
'readiness_probe_config_file_path': readiness_probe_config,
'startup_probe_config_file_path': startup_probe_config,
'termination_grace_period_seconds': termination_grace_period_seconds,
}

app_kwargs = {
Expand Down Expand Up @@ -268,6 +272,7 @@ def app_deploy(cmd, client, resource_group, service, name,
liveness_probe_config=None,
readiness_probe_config=None,
startup_probe_config=None,
termination_grace_period_seconds=None,
# general
no_wait=False):
'''app_deploy
Expand Down Expand Up @@ -316,6 +321,7 @@ def app_deploy(cmd, client, resource_group, service, name,
'liveness_probe_config_file_path': liveness_probe_config,
'readiness_probe_config_file_path': readiness_probe_config,
'startup_probe_config_file_path': startup_probe_config,
'termination_grace_period_seconds': termination_grace_period_seconds,
'no_wait': no_wait
}

Expand Down Expand Up @@ -373,6 +379,7 @@ def deployment_create(cmd, client, resource_group, service, app, name,
liveness_probe_config=None,
readiness_probe_config=None,
startup_probe_config=None,
termination_grace_period_seconds=None,
# general
no_wait=False):
'''deployment_create
Expand Down Expand Up @@ -420,6 +427,7 @@ def deployment_create(cmd, client, resource_group, service, app, name,
'liveness_probe_config_file_path': liveness_probe_config,
'readiness_probe_config_file_path': readiness_probe_config,
'startup_probe_config_file_path': startup_probe_config,
'termination_grace_period_seconds': termination_grace_period_seconds,
'no_wait': no_wait
}

Expand Down
5 changes: 5 additions & 0 deletions src/spring/azext_spring/tests/latest/test_asa_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ def test_app_update_jvm_options(self):
self.assertEqual('Java_11', resource.properties.source.runtime_version)
self.assertEqual('test-option', resource.properties.source.jvm_options)

def test_app_set_termination_grace_period_seconds(self):
self._execute('rg', 'asc', 'app', deployment=self._get_deployment(), termination_grace_period_seconds=88)
resource = self.patch_deployment_resource
self.assertEqual(88, resource.properties.deployment_settings.termination_grace_period_seconds)

def test_app_disable_probes(self):
self._execute('rg', 'asc', 'app', deployment=self._get_deployment(), enable_liveness_probe=False,
enable_readiness_probe=False, enable_startup_probe=False)
Expand Down