mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
chore(redash): improve upgrade steps
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -295,6 +295,7 @@
|
||||
"radeon",
|
||||
"radicale",
|
||||
"rdsadmin",
|
||||
"redash",
|
||||
"reflog",
|
||||
"rego",
|
||||
"replicatedctl",
|
||||
@@ -340,6 +341,7 @@
|
||||
"sysrc",
|
||||
"systool",
|
||||
"tablespace",
|
||||
"tailorable",
|
||||
"taskfile",
|
||||
"taskfiles",
|
||||
"tclsh",
|
||||
|
||||
@@ -33,31 +33,100 @@ Reference available variables from [Environment Variables Settings].
|
||||
</details>
|
||||
-->
|
||||
|
||||
<!-- Uncomment if used
|
||||
<details>
|
||||
<summary>Usage</summary>
|
||||
|
||||
```sh
|
||||
# Migrate the DB.
|
||||
docker compose run --rm 'server' manage db upgrade
|
||||
docker run --rm --name 'redash-db-migrations' \
|
||||
--env 'REDASH_COOKIE_SECRET' --env 'REDASH_DATABASE_URL' --env 'REDASH_REDIS_URL' \
|
||||
'redash/redash' -- manage db upgrade
|
||||
```
|
||||
|
||||
</details>
|
||||
-->
|
||||
|
||||
<!-- Uncomment if used
|
||||
<details>
|
||||
<summary>Real world use cases</summary>
|
||||
|
||||
```sh
|
||||
# Migrate the DB from the ECS service when running in AWS.
|
||||
# Requires command execution to be enabled and working.
|
||||
aws ecs list-tasks --cluster 'someCluster' --service-name 'redash' --query 'taskArns[0]' --output 'text' \
|
||||
| xargs -oI '%%' aws ecs execute-command --cluster 'someCluster' --container 'redash' --task '%%' --interactive \
|
||||
--command 'manage db upgrade'
|
||||
|
||||
# Migrate the DB from localhost when running in AWS.
|
||||
REDASH_IMAGE="$(\
|
||||
aws ecs list-tasks --cluster 'someCluster' --service-name 'redash' --query 'taskArns[0]' --output 'text' \
|
||||
| xargs -oI '%%' aws ecs describe-tasks --cluster 'someCluster' --task '%%' --output 'text' \
|
||||
--query 'tasks[].containers[?name==`server`].image' \
|
||||
)"
|
||||
REDASH_DATABASE_URL="$(\
|
||||
aws rds describe-db-instances --db-instance-identifier 'redash' --output 'text' \
|
||||
--query '
|
||||
DBInstances[0]
|
||||
| join(``, [
|
||||
`postgresql://`,MasterUsername,`:`,`PASSWORD`,`@`,Endpoint.Address,`:`,to_string(Endpoint.Port),`/`,
|
||||
DBName || `postgres`
|
||||
])
|
||||
' \
|
||||
)"
|
||||
REDASH_REDIS_URL="$(\
|
||||
aws elasticache describe-replication-groups --replication-group-id 'redash' --output 'text' \
|
||||
--query '
|
||||
ReplicationGroups[].NodeGroups[].PrimaryEndpoint[]
|
||||
.join(``,[`redis://`,Address,`:`,to_string(Port),`/0`])
|
||||
' \
|
||||
)"
|
||||
REDASH_COOKIE_SECRET="aa…Wd"
|
||||
docker run --rm --name 'redash-db-migrations' --platform 'linux/amd64' --dns '172.31.0.2' \
|
||||
--env 'REDASH_COOKIE_SECRET' --env 'REDASH_DATABASE_URL' --env 'REDASH_REDIS_URL' \
|
||||
"$REDASH_IMAGE" manage db upgrade
|
||||
```
|
||||
|
||||
</details>
|
||||
-->
|
||||
|
||||
Refer [How to Upgrade] when upgrading a self-hosted instance.
|
||||
|
||||
Updating dependencies (DB, redis cache) versions directly seems to work, but mind that they do require downtime.<br/>
|
||||
Redash will temporarily lose connection to them during the update's downtime period, then properly connect back to them
|
||||
without issues once they are up again.
|
||||
When updating Redash or its dependencies (i.e., DB and redis cache):
|
||||
|
||||
1. Stop Redash's components.
|
||||
|
||||
<details>
|
||||
|
||||
```sh
|
||||
docker compose stop 'server' 'scheduler' 'scheduled_worker' 'adhoc_worker'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
The scheduler will exit should it suddenly be unable to write to the cache.<br/>
|
||||
This usually happens when upgrading the cache's cluster when Redash is still active.
|
||||
|
||||
1. Make a backup of the data (DB).
|
||||
1. \[if needed] Update Redash's dependencies.
|
||||
1. Make sure the DB has enough storage space for the migrations to run.
|
||||
1. Update Redash.
|
||||
1. \[if needed] Run the migration scripts.
|
||||
|
||||
<details>
|
||||
|
||||
```sh
|
||||
docker compose run --rm 'server' manage db upgrade
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
1. Restart Redash's components.
|
||||
|
||||
<details>
|
||||
|
||||
```sh
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Authentication
|
||||
|
||||
@@ -148,7 +217,9 @@ POST /api/data_sources
|
||||
```sh
|
||||
curl --request 'GET' --url 'https://redash.example.org/api/data_sources' --header 'Authorization: Key AA…99'
|
||||
|
||||
curl --request 'POST' --url 'https://redash.example.org/api/data_sources' --header 'Authorization: Key AA…99' \
|
||||
curl --request 'POST' --url 'https://redash.example.org/api/data_sources' \
|
||||
--header 'Authorization: Key AA…99' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"name": "some data source",
|
||||
"type": "pg",
|
||||
@@ -181,6 +252,27 @@ response: Response = redash.create_data_source(data_source_name, data_source_typ
|
||||
|
||||
</details>
|
||||
|
||||
<details style='padding: 0 0 1rem 1rem'>
|
||||
<summary>Settings</summary>
|
||||
|
||||
```plaintext
|
||||
POST /api/settings/organization
|
||||
{
|
||||
"auth_password_login_enabled": true,
|
||||
"hide_plotly_mode_bar": true,
|
||||
…
|
||||
}
|
||||
```
|
||||
|
||||
```sh
|
||||
curl --request 'POST' --url 'https://redash.example.org/api/settings/organization' \
|
||||
--header 'Authorization: Key AA…99' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{"auth_password_login_enabled": true}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Further readings
|
||||
|
||||
- [Website]
|
||||
@@ -189,6 +281,7 @@ response: Response = redash.create_data_source(data_source_name, data_source_typ
|
||||
### Sources
|
||||
|
||||
- [Documentation]
|
||||
- [Ask Devin]
|
||||
- [Setting up a Redash Instance]
|
||||
- [API]
|
||||
|
||||
@@ -215,3 +308,4 @@ response: Response = redash.create_data_source(data_source_name, data_source_typ
|
||||
[Website]: https://redash.io/
|
||||
|
||||
<!-- Others -->
|
||||
[Ask Devin]: https://deepwiki.com/getredash/redash
|
||||
|
||||
@@ -37,6 +37,9 @@ aws ecs wait services-stable --cluster 'stg' --services 'grafana'
|
||||
# Update services' attributes
|
||||
aws ecs update-service --cluster 'stg' --service 'grafana' --enable-execute-command --force-new-deployment
|
||||
|
||||
# Scale services
|
||||
aws ecs update-service --cluster 'stg' --service 'grafana' --desired-count '3'
|
||||
|
||||
# Check tasks' attributes
|
||||
aws ecs describe-tasks --cluster 'staging' --tasks 'ef6260ed8aab49cf926667ab0c52c313' --output 'yaml' \
|
||||
--query 'tasks[0] | {
|
||||
@@ -87,3 +90,8 @@ aws ecs stop-service-deployment --stop-type 'ROLLBACK' \
|
||||
aws ecs list-service-deployments --cluster 'staging' --service 'mimir' \
|
||||
--query "serviceDeployments[?@.status=='IN_PROGRESS'].serviceDeploymentArn" --output 'text' \
|
||||
| xargs -pn 1 aws ecs stop-service-deployment --service-deployment-arn
|
||||
|
||||
# Get the image of specific containers.
|
||||
aws ecs list-tasks --cluster 'someCluster' --service-name 'someService' --query 'taskArns[0]' --output 'text' \
|
||||
| xargs -oI '%%' aws ecs describe-tasks --cluster 'someCluster' --task '%%' \
|
||||
--query 'tasks[].containers[?name==`someContainer`].image' --output 'text'
|
||||
|
||||
@@ -192,11 +192,34 @@ aws eks describe-addon-configuration --addon-name 'aws-ebs-csi-driver' --addon-v
|
||||
# ------------------
|
||||
###
|
||||
|
||||
# Describe replication groups
|
||||
aws elasticache describe-replication-groups
|
||||
aws elasticache describe-replication-groups --query 'ReplicationGroups[].ReplicationGroupId'
|
||||
aws elasticache describe-replication-groups --replication-group-id 'some-app' --output 'text' \
|
||||
--query "ReplicationGroups[].NodeGroups[].PrimaryEndpoint[].join(':', [Address, to_string(Port)])"
|
||||
aws elasticache describe-replication-groups --replication-group-id 'some-app' --output 'text' \
|
||||
--query "ReplicationGroups[].NodeGroups[].PrimaryEndpoint[].join('', [`redis://`,Address,`:`,to_string(Port),`/0`])"
|
||||
|
||||
# List pending changes to replication groups
|
||||
aws elasticache describe-replication-groups --query 'ReplicationGroups[].PendingModifiedValues'
|
||||
aws elasticache describe-replication-groups --replication-group-id 'some-app' --query 'ReplicationGroups[].PendingModifiedValues'
|
||||
|
||||
# Upgrade replication groups' engine
|
||||
aws elasticache modify-replication-group --replication-group-id 'some-app' --engine-version '6.2' --apply-immediately
|
||||
|
||||
# Describe clusters
|
||||
aws elasticache describe-cache-clusters
|
||||
aws elasticache describe-cache-clusters --query 'CacheClusters[].CacheClusterId'
|
||||
|
||||
aws elasticache describe-replication-groups
|
||||
aws elasticache describe-replication-groups --query 'ReplicationGroups[].ReplicationGroupId'
|
||||
# List pending changes to clusters
|
||||
aws elasticache describe-cache-clusters --query 'CacheClusters[].PendingModifiedValues'
|
||||
aws elasticache describe-cache-clusters \
|
||||
--query 'CacheClusters[?length(PendingModifiedValues)>`0`].{"CacheClusterId":CacheClusterId,"PendingModifiedValues":PendingModifiedValues}'
|
||||
aws elasticache describe-cache-clusters --cache-cluster-id 'some-cluster' --query 'CacheClusters[].PendingModifiedValues'
|
||||
|
||||
# Apply pending changes to clusters
|
||||
aws elasticache modify-cache-cluster --cache-cluster-id 'some-cluster' --num-cache-nodes 'current-number-of-nodes' \
|
||||
--apply-immediately
|
||||
|
||||
|
||||
###
|
||||
@@ -418,6 +441,28 @@ aws rds describe-db-parameters --db-parameter-group-name 'default.postgres15' \
|
||||
|
||||
aws rds create-db-snapshot --db-instance-identifier 'some-db-instance' --db-snapshot-identifier 'some-db-snapshot'
|
||||
|
||||
aws rds describe-db-instances --db-instance-identifier 'some-instance' \
|
||||
--query 'DBInstances[0].InstanceCreateTime' --output 'text'
|
||||
|
||||
aws rds describe-db-instances --db-instance-identifier 'some-db-instance' --output 'text' \
|
||||
--query 'DBInstances[0].Endpoint|join(`:`,[Address,to_string(Port)])'
|
||||
aws rds describe-db-instances --db-instance-identifier 'some-db-instance' --output 'text' \
|
||||
--query '
|
||||
DBInstances[0]
|
||||
| join(``, [
|
||||
`postgresql://`,
|
||||
MasterUsername,
|
||||
`:`,
|
||||
`PASSWORD_PLACEHOLDER`,
|
||||
`@`,
|
||||
Endpoint.Address,
|
||||
`:`,
|
||||
to_string(Endpoint.Port),
|
||||
`/`,
|
||||
DBName || `postgres`
|
||||
])
|
||||
'
|
||||
|
||||
|
||||
###
|
||||
# Route53
|
||||
|
||||
@@ -12,6 +12,9 @@ docker volume inspect -f '{{ .Mountpoint }}' 'website'
|
||||
sudo vim '/var/lib/docker/volumes/website/_data/index.html'
|
||||
|
||||
docker run -d --name 'some-nginx' -v '/some/content:/usr/share/nginx/html:ro' 'nginx'
|
||||
docker run --rm --name 'redash-db-migrations' --platform 'linux/amd64' --dns '172.31.0.2' \
|
||||
--env 'REDASH_COOKIE_SECRET' --env 'REDASH_DATABASE_URL' --env 'REDASH_REDIS_URL' \
|
||||
"$REDASH_IMAGE" manage db upgrade
|
||||
docker run --rm --name 'pulumi' \
|
||||
--env 'AWS_DEFAULT_REGION' --env 'AWS_ACCESS_KEY_ID' --env 'AWS_SECRET_ACCESS_KEY' --env 'AWS_PROFILE' \
|
||||
--env-file '.env' --env-file '.env.local' \
|
||||
|
||||
Reference in New Issue
Block a user