-
Notifications
You must be signed in to change notification settings - Fork 0
WKBCH-25: Complete CRR support #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
503b311
705326d
316d4b2
f9a33d1
d098b2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,9 @@ type EnvironmentConfig struct { | |
| Clickhouse ClickhouseConfig `yaml:"clickhouse"` | ||
| Fluentbit FluentbitConfig `yaml:"fluentbit"` | ||
| Nginx NginxConfig `yaml:"nginx"` | ||
|
|
||
| HostUID int `yaml:"-"` | ||
| HostGID int `yaml:"-"` | ||
| } | ||
|
|
||
| type GlobalConfig struct { | ||
|
|
@@ -319,6 +322,8 @@ func DefaultEnvironmentConfig() EnvironmentConfig { | |
|
|
||
| func LoadEnvironmentConfig(path string) (EnvironmentConfig, error) { | ||
| cfg := DefaultEnvironmentConfig() | ||
| cfg.HostUID = os.Getuid() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember messing around with this but it was for the logs/volumes with the host, anything related to CRR in this case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to CRR, just a side-fix for an issue I noticed (705326d). It is about file permissions in volumes on the host. |
||
| cfg.HostGID = os.Getgid() | ||
|
|
||
| if path == "" { | ||
| return cfg, nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/usr/bin/env bash | ||
| # enable-crr.sh — create source + destination buckets and configure replication. | ||
| # | ||
| # Usage: | ||
| # scripts/enable-crr.sh --source <bucket> --destination <bucket> \ | ||
| # [--prefix <pfx>] [--endpoint <url>] | ||
| # | ||
| # Defaults: | ||
| # --endpoint http://127.0.0.1:8000 | ||
| # --prefix "" (replicate everything) | ||
| # | ||
| # Idempotent: re-running is a no-op once resources exist. | ||
|
|
||
| set -eu | ||
|
|
||
| # Pinned to match templates/vault/create-management-account.sh and the | ||
| # replication-role accountSeed in templates/vault/config.json. | ||
| ROLE_ARN="arn:aws:iam::123456789012:role/scality-internal/replication-role" | ||
|
|
||
| SOURCE="" | ||
| DESTINATION="" | ||
| PREFIX="" | ||
| ENDPOINT="http://127.0.0.1:8000" | ||
|
|
||
| while [ $# -gt 0 ]; do | ||
| case "$1" in | ||
| --source) SOURCE="$2"; shift 2 ;; | ||
| --destination) DESTINATION="$2"; shift 2 ;; | ||
| --prefix) PREFIX="$2"; shift 2 ;; | ||
| --endpoint) ENDPOINT="$2"; shift 2 ;; | ||
| -h|--help) | ||
| sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//' | ||
| exit 0 | ||
| ;; | ||
| *) echo "unknown flag: $1" >&2; exit 2 ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ -z "$SOURCE" ] || [ -z "$DESTINATION" ]; then | ||
| echo "error: --source and --destination are required" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| # testaccount credentials are fixed in templates/vault/create-management-account.sh | ||
| export AWS_ACCESS_KEY_ID="WBTKACCESSI9O3YKIRQ0" | ||
| export AWS_SECRET_ACCESS_KEY="ICxmNTBbOqijy4rMq/MOP1EPlTMqfsEBLjROcAbN" | ||
| export AWS_DEFAULT_REGION="us-east-1" | ||
|
|
||
| AWS="aws --endpoint-url $ENDPOINT" | ||
|
|
||
| create_bucket() { | ||
| local bucket="$1" | ||
| if $AWS s3api create-bucket --bucket "$bucket" >/dev/null 2>&1; then | ||
| echo "[crr] created bucket $bucket" | ||
| else | ||
| # swallow "already exists and owned by you" — treat anything else as fatal | ||
| if $AWS s3api head-bucket --bucket "$bucket" >/dev/null 2>&1; then | ||
| echo "[crr] bucket $bucket already exists" | ||
| else | ||
| echo "error: failed to create bucket $bucket" >&2 | ||
| $AWS s3api create-bucket --bucket "$bucket" | ||
| exit 1 | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| enable_versioning() { | ||
| local bucket="$1" | ||
| $AWS s3api put-bucket-versioning \ | ||
| --bucket "$bucket" \ | ||
| --versioning-configuration Status=Enabled | ||
| echo "[crr] versioning enabled on $bucket" | ||
| } | ||
|
|
||
| create_bucket "$SOURCE" | ||
| create_bucket "$DESTINATION" | ||
| enable_versioning "$SOURCE" | ||
| enable_versioning "$DESTINATION" | ||
|
|
||
| REPLICATION_CONFIG=$(cat <<EOF | ||
| { | ||
| "Role": "${ROLE_ARN},${ROLE_ARN}", | ||
| "Rules": [ | ||
| { | ||
| "ID": "workbench-crr", | ||
| "Status": "Enabled", | ||
| "Prefix": "${PREFIX}", | ||
| "Destination": { | ||
| "Bucket": "arn:aws:s3:::${DESTINATION}", | ||
| "StorageClass": "sf" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| EOF | ||
| ) | ||
|
|
||
| $AWS s3api put-bucket-replication \ | ||
| --bucket "$SOURCE" \ | ||
| --replication-configuration "$REPLICATION_CONFIG" | ||
|
|
||
| echo "[crr] replication configured: $SOURCE -> $DESTINATION (prefix='$PREFIX')" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"D4IT2AWSB588GO5J9T00":"UEEu8tYlsOGGrgf4DAiSZD6apVNPUWqRiPG0nTB6"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,10 @@ | |
| "host": "127.0.0.1", | ||
| "port": 8500 | ||
| }, | ||
| "redis": { | ||
| "host": "127.0.0.1", | ||
| "port": 6379 | ||
| }, | ||
| "replicationGroupId": "RG001 ", | ||
| "queuePopulator": { | ||
| "cronRule": "*/5 * * * * *", | ||
|
|
@@ -59,7 +63,7 @@ | |
| "host": "127.0.0.1", | ||
| "port": 8500, | ||
| "adminPort": 8600, | ||
| "adminCredentialsFile": "/home/scality/backbeat/node_modules/vaultclient/tests/utils/admincredentials.json" | ||
| "adminCredentialsFile": "/conf/admin-backbeat.json" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the diff between the two? or was there some permissions issue?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same content, I just thought it's a bit better for future readers to have the file here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alrighty |
||
| } | ||
| } | ||
| }, | ||
|
|
@@ -74,7 +78,7 @@ | |
| "host": "127.0.0.1", | ||
| "port": 8500, | ||
| "adminPort": 8600, | ||
| "adminCredentialsFile": "/home/scality/backbeat/node_modules/vaultclient/tests/utils/admincredentials.json" | ||
| "adminCredentialsFile": "/conf/admin-backbeat.json" | ||
| } | ||
| } | ||
| }, | ||
|
|
@@ -176,7 +180,7 @@ | |
| "port": 8500 | ||
| } | ||
| }, | ||
| "backlogControl": { "enabled": true }, | ||
| "backlogControl": { "enabled": false }, | ||
| "cronRule": "*/5 * * * * *", | ||
| "concurrency": 10, | ||
| "bucketSource": "bucketd", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.