Advanced managment
qjazz come with managment tools for Qgis service clusters.
It allows you to:
Retrieve infos about running Qgis clusters
Synchronize cache between instances of the same Qgis pools
Manage cache for each instances.
Get plugin’s infos
List project’s catalog
Watch health status
Serve REST managment api
Running managment from CLI
You may run the managment tool from CLI:
> pip install qjazz-admin
> python3 -m qjazz_admin --help
Usage: python -m qjazz_admin [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
cache Cache management
catalog Print catalog for 'host'
conf Configuration management
doc Manage documentation
plugins List backend's loaded plugins
pools List all pools
serve Run admin server
stats Output qgis gRPC services stats
watch Watch a cluster of qgis gRPC services
or from the docker image:
docker run -it --rm -v <path/to/configfile>:/etc/qjazz-server-admin.toml \
-e PY_QGIS_SERVER_ADMIN_CONFIGFILE=/etc/qjazz-server-admin.toml \
3liz/qjazz:ltr qjazz-server-admin
Managment from REST api
Managment may also be handler using REST api with the serve command:
> qjazz-server-admin serve
From this you can use your own dashboard for managing your Qgis clusters.
Api specification
See the Managment API
or download the Json specs
.
Configuration
Configuration is read from toml file or from remote http url.
The configuration define Qgis backend’s pool with resolvers that describe how to access the pools - actually only DNS résolution and unix socket are supported.
The following example define the qgis-rpc host as a DNS endpoint for a cluster of qgis services pool.
[resolvers]
[[resolvers.pools]]
label = "basic"
type = "dns"
host = "qgis-rpc"
port = 23456
If you are using the basic docker-compose example and your running admin container is attached to the compose network stack, then your configuration will point to the qgis-rpc services.
Examples:
> qjazz-server-admin pools
Pool 1. basic qgis-rpc:23456 backends: 3
* 172.25.0.5:23456
* 172.25.0.2:23456
* 172.25.0.6:23456
> qjazz-server-admin stats --host qgis-rpc
[
{
"address": "172.25.0.2:23456",
"numWorkers": 1,
"requestPressure": 0.0,
"status": "ok",
"stoppedWorkers": 0,
"uptime": 6217,
"workerFailurePressure": 0.0
},
{
"address": "172.25.0.5:23456",
"numWorkers": 1,
"requestPressure": 0.0,
"status": "ok",
"stoppedWorkers": 0,
"uptime": 132,
"workerFailurePressure": 0.0
},
{
"address": "172.25.0.6:23456",
"numWorkers": 1,
"requestPressure": 0.0,
"status": "ok",
"stoppedWorkers": 0,
"uptime": 131,
"workerFailurePressure": 0.0
}
]
Configuration schema
When reading configuration from file, the format is TOML by default.
The configuration schema may be output as different format using the doc command from the CLI: the json or yaml format may be used for validation.
[logging]
level = "INFO"
[admin_http]
#
# Interfaces to listen to
listen = ["127.0.0.1",9871]
#
# Use ssl
use_ssl = false
#
# CORS origin
#
# Allows to specify origin for CORS. If set 'all' will set
# Access-Control-Allow-Origin to '*'; 'same-origin' return
# the same value as the 'Origin' request header.
# An url may may be specified, restricting allowed origin to this url.
cross_origin = "all"
#
# Enable proxy_configuration
#
# Indicates that the server is behind a reverse proxy.
# This enable handling of forwarded proxy headers
proxy_conf = false
#
# List of authorized tokens
auth_tokens = []
#
# TLS certificats
#
[admin_http.ssl]
#
# CA file
#cafile = # Optional
#
# TLS certificat
#
# Path to the TLS cert file
#certfile = # Optional
#
# TLS key file
#
# Path to the TLS key file
#keyfile = # Optional
# Remote configuration settings
[admin_config_url]
#
# External configuration Url
#
# The server will issue a GET method against this url at startup.
# The method should returns a valid configuration fragment.
# Note that this overrides all local settings.
#url = # Optional
#
# TLS configuration
#
[admin_config_url.ssl]
#
# CA file
#cafile = # Optional
#
# TLS certificat
#
# Path to the TLS cert file
#certfile = # Optional
#
# TLS key file
#
# Path to the TLS key file
#keyfile = # Optional
[resolvers]
#
# List of Rpc backends
#
[[resolvers.resolvers]]
#
# Unique label
#
# Unique resolver label. The label must be compatible with an url path component.
#label = # Required
#
# RPC address
address = ["::1",23456]
#
# Check for ipv6
ipv6 = false
#
# Use ssl connection
use_ssl = false
title = ""
#description = # Optional
#
# TLS certificats
#
[resolvers.resolvers.ssl]
#
# CA file
#cafile = # Optional
#
# TLS certificat
#
# Path to the TLS cert file
#certfile = # Optional
#
# TLS key file
#
# Path to the TLS key file
#keyfile = # Optional
Case scenarios
Synchronizing pool cache
In pool of Qgis services, cache may be desynchronized for different reasons:
Scaling up the pool
Using the load_project_on_request
Updating container in a orchestrated environment
The cache restoration mecanism may prevent most of desynchronization mecanism, it may be required to manually resync caches:
The cli managment tool provide the sync command while the REST api provides the http method:
- PATCH /v1/pools/{Id}/cache
Synchronize and update cache between all pool instances
Adding, modifying or removing pool to managment service
If you add or remove resolver’s you will need to reload the configuration.
The REST api provide a method for reloading the configuration:
- PATCH /v1/config
Reload the configuration and resync all pools.
All pools will be resynced according to the new resolvers
Resyncing with rpc pools when rescaling rpc services
If you have scaled your rpc services of if some resolvers are handling with dynamic configuration, your will only need to resync with the resolvers in order to take the changes into account.
- PATCH /vi/pools
Resync all pools with resolvers.