Configuring GEO in Active/Active High Availability
ESC Active/Active HA has three VMs as a cluster in one datacenter. The second datacenter consists of GEO-HA.
Following are the 6 pre-defined roles in GEO:
-
init
: initial role of geo service -
pre_primary
-
primary
-
pre_secondary
-
secondary
-
unknown
: used when consul is not reachable
GEO can change one role to another. Transitions are defined in esc-config.yaml
. Each transition is divided into the following 3 parts:
-
from
: current role -
goto
: destination role -
condition
: when GEO changes the role
Transition Conditions
When A/A HA Geo comes up, the primary datacenter has to go through init
, pre_primary
, and primary
states; meanwhile, the secondary datacenter has to go through init, pre-secondary, and secondary states. When all ESC VMs'
health check pass on both primary and secondary datacenters, the ESC A/A HA GEO is up and running. It is ready for use.
Condition Functions
The following are all supported condition functions:
-
return
: do nothing but return the argument -
and
: return true if all arguments are true -
or
: return true if any of the argument is true -
len
: return the length of the argument -
equals
: return true if all arguments are equal -
true
: return true if args can be tested for truth value in python -
false
: opposite to 'true'
The following are samples for GEO configurations on primary datacenter:
on_init: consul start
on_primary: start
on_secondary: stop
on_stop: consul stop
startup: manual
transitions:
- condition:
return:
and:
- equals:
- len: service1
- 3
- equals:
- len: service2
- 3
rise: 3
service1:
dc: dc1
name: consul_agent
passing: true
type: service
service2:
dc: dc2
name: geo
passing: true
type: service
from: init
goto: primary
- condition:
fall: 2
return:
equals:
- len: service
- 3
service:
dc: dc1
name: consul_agent
from: primary
goto: secondary
The following are samples for GEO configurations on secondary datacenter:
on_init: consul start
on_primary: start
on_secondary: stop
on_stop: consul stop
startup: manual
transitions:
- condition:
return:
and:
- equals:
- len: service1
- 3
- equals:
- len: service2
- 3
rise: 3
service1:
dc: dc1
name: consul_agent
passing: true
type: service
service2:
dc: dc2
name: geo
passing: true
type: service
from: init
goto: secondary
- condition:
fall: 2
return:
equals:
- len: service
- 3
service:
dc: dc1
name: consul_agent
from: secondary
goto: primary