Skip to content
This repository was archived by the owner on Jan 1, 2024. It is now read-only.

Commit 18fe342

Browse files
authored
Disable restart for hot reload (#118)
1 parent 942f3f9 commit 18fe342

File tree

6 files changed

+28
-10
lines changed

6 files changed

+28
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ README.md and examples/getting-started-app/README.md
1111
to use the newest tag with new release
1212
-->
1313

14+
### Added
15+
16+
- `restarted: false` to disable instance restart
17+
1418
## [1.4.0] - 2020-07-15
1519

1620
### Added

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ all:
8888
advertise_uri: '172.19.0.2:3302'
8989
http_port: 8082
9090
restarted: true # force instance restart
91+
# restarted: false # disable instance restart
9192
9293
storage-1:
9394
config:
@@ -172,7 +173,9 @@ Configuration format is described in detail in the
172173
indicates if the Tarantool repository should be enabled (for packages with
173174
open-source Tarantool dependency);
174175
* `config` (`dict`, required): [instance configuration](#instances);
175-
* `restarted` (`boolean`, optional, default: `false`): indicates that instance must be forcedly restarted;
176+
* `restarted` (`boolean`, optional): flag indicates if instance should be
177+
restarted or not (if this flag isn't specified, instance will be restarted if
178+
it's needed to apply configuration changes);
176179
* `expelled` (`boolean`, optional, default: `false`): boolean flag that indicates if instance must be expelled from topology;
177180
* `stateboard` (`boolean`, optional, default: `false`): boolean flag that indicates
178181
that the instance is a [stateboard](#stateboard-instance);
@@ -181,7 +184,7 @@ Configuration format is described in detail in the
181184
* `failover_priority` (`list-of-string`): failover priority;
182185
* `roles` (`list-of-strings`, required if `replicaset_alias` specified): roles to be enabled on the replicaset;
183186
* `all_rw` (`boolean`, optional): indicates that that all servers in the replicaset should be read-write;
184-
* `weight` (`number`, optional): vshard replicaset weight (matters only if `vshard-storage` role is enabled.
187+
* `weight` (`number`, optional): vshard replicaset weight (matters only if `vshard-storage` role is enabled);
185188
* [DEPRECATED] `cartridge_failover` (`boolean`, optional): boolean flag that
186189
indicates if eventual failover should be enabled or disabled;
187190

defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
cartridge_defaults: {}
33
cartridge_enable_tarantool_repo: true
4-
restarted: false
4+
restarted: null
55
expelled: false
66
stateboard: false
77
instance_start_timeout: 60

library/cartridge_needs_restart.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
argument_spec = {
11-
'restart_forced': {'required': True, 'type': 'bool'},
11+
'restarted': {'required': False, 'type': 'bool'},
1212
'control_sock': {'required': True, 'type': 'str'},
1313
'appname': {'required': True, 'type': 'str'},
1414
'instance_conf_file': {'required': True, 'type': 'str'},
@@ -77,10 +77,13 @@ def get_memtx_memory(control_console):
7777

7878

7979
def needs_restart(params):
80-
restart_forced = params['restart_forced']
81-
if restart_forced:
80+
restarted = params['restarted']
81+
if restarted is True:
8282
return ModuleRes(success=True, changed=True)
8383

84+
if restarted is False:
85+
return ModuleRes(success=True, changed=False)
86+
8487
stateboard = params['stateboard']
8588

8689
control_sock = params['control_sock']

tasks/start_instance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
- name: Check if instance restart is forced or required to apply changes
1313
cartridge_needs_restart:
14-
restart_forced: '{{ restarted }}'
14+
restarted: '{{ restarted }}'
1515
control_sock: '{{ instance_control_sock }}'
1616
appname: '{{ cartridge_app_name }}'
1717
instance_conf_file: '{{ instance_conf_file }}'

unit/test_needs_restart.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
def call_needs_restart(control_sock,
18-
restart_forced=False,
18+
restarted=None,
1919
appname=Instance.APPNAME,
2020
instance_conf_file=Instance.INSTANCE_CONF_PATH,
2121
conf_section_name=Instance.CONF_SECTION,
@@ -24,7 +24,7 @@ def call_needs_restart(control_sock,
2424
cartridge_defaults={},
2525
stateboard=False):
2626
return needs_restart({
27-
'restart_forced': restart_forced,
27+
'restarted': restarted,
2828
'control_sock': control_sock,
2929
'appname': appname,
3030
'instance_conf_file': instance_conf_file,
@@ -47,11 +47,19 @@ def setUp(self):
4747
def test_restart_forced(self):
4848
res = call_needs_restart(
4949
control_sock=self.console_sock,
50-
restart_forced=True
50+
restarted=True
5151
)
5252
self.assertTrue(res.success, msg=res.msg)
5353
self.assertTrue(res.changed)
5454

55+
def test_restart_disabled(self):
56+
res = call_needs_restart(
57+
control_sock=self.console_sock,
58+
restarted=False
59+
)
60+
self.assertTrue(res.success, msg=res.msg)
61+
self.assertFalse(res.changed)
62+
5563
def test_instance_not_started(self):
5664
# console sock doesn't exists
5765
self.instance.remove_file(self.console_sock)

0 commit comments

Comments
 (0)