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

Commit c1660e0

Browse files
authored
Starting stateboard instance (#97)
1 parent 4dc7865 commit c1660e0

33 files changed

+536
-136
lines changed

README.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ to learn how to set up topology using this role.
2525
* [Failover](#failover)
2626
* [Cartridge authorization](#cartridge-authorization)
2727
* [Application configuration](#application-configuration)
28+
* [Stateboard instance](#stateboard-instance)
2829

2930

3031
## Requirements
@@ -69,6 +70,7 @@ To deploy an application and set up this topology:
6970
---
7071
all:
7172
vars:
73+
cartridge_app_name: myapp
7274
cartridge_package_path: ./myapp-1.0.0-0.rpm
7375
cartridge_cluster_cookie: secret-cookie
7476
cartridge_defaults:
@@ -171,6 +173,8 @@ Configuration format is described in detail in the
171173
* `config` (`dict`, required): [instance configuration](#instances);
172174
* `restarted` (`boolean`, optional, default: `false`): indicates that instance must be forcedly restarted;
173175
* `expelled` (`boolean`, optional, default: `false`): boolean flag that indicates if instance must be expelled from topology;
176+
* `stateboard` (`boolean`, optional, default: `false`): boolean flag that indicates
177+
that the instance is a [stateboard](#stateboard-instance);
174178
* `instance_start_timeout` (`number`, optional, default: 60): time in seconds to wait for instance to be started;
175179
* `replicaset_alias` (`string`, optional): replicaset alias, will be displayed in Web UI;
176180
* `failover_priority` (`list-of-string`): failover priority;
@@ -439,7 +443,7 @@ cartridge_failover_params:
439443

440444
#### Stateful
441445

442-
**Note** that stateful failover is supported since `Cartridge` 2.1.0.
446+
**Note** that stateful failover is supported since `Cartridge` 2.1.2.
443447

444448
`stateful` failover requires these parameters:
445449

@@ -559,3 +563,72 @@ section-1: value-1 # hasn't been changed
559563
section-2:
560564
key-21: value-21-new # body was replaced
561565
```
566+
567+
### Stateboard instance
568+
569+
Stateboard is a Tarantool state provider for stateful failover.
570+
It is delivered within an application's RPM/DEB package, if the application contains the
571+
`stateboard.init.lua` file in its root. In this case, the application package contains the
572+
`/etc/systemd/system/<appname>-stateboard.service` unit file.
573+
574+
It starts a Tarantool stateboard instance with an entry point
575+
`/usr/share/tarantool/<appname>/stateboard.init.lua`.
576+
This instance looks for its configuration in the `<appname>-stateboard` section
577+
across all files in the `/etc/tarantool/conf.d` directory.
578+
579+
This instance can be started using the [Tarantool Cartridge Ansible role](https://github.com/tarantool/ansible-cartridge).
580+
To mark an instance as a stateboard, use the `stateboard` flag.
581+
582+
A stateboard instance is started as a systemd service named `<app_name>-stateboard`.
583+
584+
Stateboard can be configured using the `config` variable as well as other instances.
585+
This variable describes stateboard parameters that would be passed to its
586+
configuration.
587+
588+
**Note:** `cartridge_defaults` doesn't affect a stateboard instance.
589+
590+
#### Required config parameters
591+
592+
* `listen` - stateboard instance URI.
593+
It must be specified in the `<host>:<port>` format.
594+
595+
* `password` - stateboard instance password.
596+
597+
#### Forbidden config parameters
598+
599+
`alias`, `console_sock`, `pid_file`, and `workdir` parameters are forbidden
600+
for a stateboard instance.
601+
602+
*Example*
603+
604+
```yaml
605+
---
606+
all:
607+
vars:
608+
cartridge_app_name: myapp
609+
cartridge_package_path: ./myapp-1.0.0-0.rpm
610+
611+
# other cartridge params
612+
...
613+
614+
# FAILOVER PARAMS
615+
cartridge_failover_params:
616+
mode: stateful
617+
state_provider: stateboard
618+
stateboard_params:
619+
uri: 172.19.0.2:3310 # <- STATEBOARD URI
620+
password: secret-stateboard # <- STATEBOARD PASSWORD
621+
622+
hosts:
623+
# STATEBOARD INSTANCE
624+
my-stateboard-instance: # instance name doesn't matter
625+
stateboard: true # this matters - instance is a stateboard
626+
config:
627+
listen: '172.19.0.2:3310' # <- STATEBOARD URI
628+
password: 'stateboard-secret' # <- STATEBOARD PASSWORD
629+
630+
# APPLICATION INSTANCES
631+
core-1:
632+
...
633+
...
634+
```

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ cartridge_defaults: {}
33
cartridge_enable_tarantool_repo: true
44
restarted: false
55
expelled: false
6+
stateboard: false
67
instance_start_timeout: 60

examples/getting-started-app/README.md

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set up the topology, and configure a cluster.
1414
* [Start instances](#start-instances)
1515
* [Set up replica sets](#set-up-replica-sets)
1616
* [Bootstrap vshard](#bootstrap-vshard)
17-
* [Manage failover](#manage-failover)
17+
* [Failover](#failover)
1818
* [Manage authorization](#manage-authorization)
1919
* [Application configuration](#application-configuration)
2020
* [Final checks](#final-checks)
@@ -64,7 +64,9 @@ Our example application implements two roles:
6464
We will set up a simple topology on 2 virtual machines, `vm1` and `vm2`:
6565

6666
* replicaset `app-1`:
67-
* roles: `api` (+ `vshard-router`)
67+
* roles:
68+
* `api` (+ `vshard-router`)
69+
* `failover-coordinator`
6870
* instances:
6971
* `app-1` (`vm1`)
7072

@@ -393,7 +395,9 @@ all:
393395
replicaset_alias: app-1
394396
failover_priority:
395397
- app-1 # leader
396-
roles: ['api']
398+
roles:
399+
- api
400+
- failover-coordinator
397401
398402
hosts: # instances
399403
app-1:
@@ -472,6 +476,7 @@ To disable failover just set it's mode to `disabled`:
472476
---
473477
all:
474478
vars:
479+
...
475480
cartridge_failover_params:
476481
mode: disabled
477482
...
@@ -481,9 +486,70 @@ If this value is unset, the failover status won't be affected.
481486

482487
### Stateful failover
483488

484-
The full example for [stateful failover](https://www.tarantool.io/en/doc/2.2/book/cartridge/cartridge_api/topics/failover.md#stateful-failover)
485-
is coming soon.
486-
Now you can [read the doc](../../README.md#stateful).
489+
**Note** that stateful failover is supported since `Cartridge` 2.1.2.
490+
491+
[Read the doc](../../README.md#stateful) to learn more about stateful failover.
492+
493+
First, let's set failover mode to stateful:
494+
495+
```yaml
496+
---
497+
all:
498+
vars:
499+
...
500+
cartridge_failover_params:
501+
mode: stateful
502+
state_provider: stateboard
503+
stateboard_params:
504+
uri: 172.19.0.2:3310
505+
password: secret-stateboard
506+
...
507+
```
508+
509+
Now, check the `Failover` button in the Admin UI:
510+
511+
![](./images/stateful-failover.png)
512+
513+
Stateful failover was enabled, but we didn't start the Stateboard instance.
514+
If you click the `Issues` button, you can see that there are problems with
515+
state provider availability.
516+
517+
![](./images/issues.png)
518+
519+
Now we need to start [Stateboard instance](../../README.md#stateboard-instance).
520+
521+
Add host marked as `stateboard` to the first machine:
522+
523+
```yaml
524+
---
525+
all:
526+
vars:
527+
...
528+
hosts:
529+
...
530+
my-stateboard:
531+
config:
532+
listen: 172.19.0.2:3310
533+
password: secret-stateboard
534+
stateboard: true
535+
...
536+
children:
537+
machine1:
538+
vars:
539+
...
540+
hosts:
541+
...
542+
my-stateboard:
543+
```
544+
545+
Check that there aren't any issues anymore.
546+
Additionally, you can check stateboard service status and logs:
547+
548+
```bash
549+
vagrant ssh vm1
550+
[vagrant@vm1 ~]$ sudo systemctl status getting-started-app-stateboard
551+
[vagrant@vm1 ~]$ sudo journalctl -u getting-started-app-stateboard
552+
```
487553

488554
### Manage authorization
489555

2.9 MB
Binary file not shown.

examples/getting-started-app/hosts.updated.yml

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ all:
88
cartridge_defaults: # default instance parameters
99
log_level: 5
1010

11+
cartridge_bootstrap_vshard: true # bootstrap vshard
12+
13+
# cartridge_failover_params:
14+
# mode: eventual
15+
16+
# cartridge_failover_params:
17+
# mode: stateful
18+
# state_provider: stateboard
19+
# stateboard_params:
20+
# uri: 172.19.0.2:3310
21+
# password: secret-stateboard
22+
1123
# common ssh options
1224
ansible_ssh_private_key_file: ~/.vagrant.d/insecure_private_key
1325
ansible_ssh_common_args: '-o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
@@ -29,6 +41,12 @@ all:
2941
advertise_uri: '172.19.0.3:3302'
3042
http_port: 8183
3143

44+
# my-stateboard:
45+
# config:
46+
# listen: 172.19.0.2:3310
47+
# password: secret-stateboard
48+
# stateboard: true
49+
3250
children:
3351
# GROUP INSTANCES BY MACHINES
3452
machine1:
@@ -39,6 +57,7 @@ all:
3957

4058
hosts: # instances to be started on this machine
4159
storage-1:
60+
# my-stateboard:
4261

4362
machine2:
4463
vars:
@@ -50,26 +69,28 @@ all:
5069
app-1:
5170
storage-1-replica:
5271

53-
# GROUP INSTANCES BY REPLICASETS
54-
storage_1_replicaset: # replicaset storage-1
55-
vars: # replicaset configuration
56-
replicaset_alias: storage-1
57-
weight: 3
58-
failover_priority:
59-
- storage-1 # leader
60-
- storage-1-replica
61-
roles: ['storage']
62-
63-
hosts: # instances
64-
storage-1:
65-
storage-1-replica:
72+
# GROUP INSTANCES BY REPLICASETS
73+
storage_1_replicaset: # replicaset storage-1
74+
vars: # replicaset configuration
75+
replicaset_alias: storage-1
76+
weight: 3
77+
failover_priority:
78+
- storage-1 # leader
79+
- storage-1-replica
80+
roles: ['storage']
6681

67-
app_1_replicaset: # replicaset app-1
68-
vars: # replicaset configuration
69-
replicaset_alias: app-1
70-
failover_priority:
71-
- app-1 # leader
72-
roles: ['api']
82+
hosts: # instances
83+
storage-1:
84+
storage-1-replica:
7385

74-
hosts: # instances
75-
app-1:
86+
app_1_replicaset: # replicaset app-1
87+
vars: # replicaset configuration
88+
replicaset_alias: app-1
89+
failover_priority:
90+
- app-1 # leader
91+
roles:
92+
- api
93+
- failover-coordinator
94+
95+
hosts: # instances
96+
app-1:
-247 KB
Binary file not shown.
304 KB
Loading
20.4 KB
Loading
348 KB
Loading
11.7 KB
Loading

0 commit comments

Comments
 (0)