Skip to content

Commit

Permalink
api calls for CRDR management
Browse files Browse the repository at this point in the history
  • Loading branch information
wojcik-dorota committed Dec 11, 2024
1 parent cde02cd commit 24bdd54
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 2 deletions.
56 changes: 56 additions & 0 deletions docs/products/postgresql/crdr/crdr-failover-to-recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,62 @@ avn service update PRIMARY_SERVICE_NAME \

Replace `PRIMARY_SERVICE_NAME` with the name of the primary service, for example, `pg-demo`.

</TabItem>
<TabItem value="api" label="Aiven API">

Call the [ServiceUpdte endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate)
to change `disaster_recovery_role` of the primary service to `failed`:

```bash {5}
curl --request PUT \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/PRIMARY_SERVICE_NAME \
-H 'Authorization: Bearer BEARER_TOKEN' \
-H 'content-type: application/json' \
--data '{"disaster_recovery_role": "failed"}'
```

Replace the following placeholders with meaningful data:

- `PROJECT_NAME`, for example `crdr-test`
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`
- `BEARER_TOKEN`

After sending the request, you can check the CRDR status on each of the CRDR peer services:

- Primary service status

```bash
avn service get pg-primary
--project $PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "POWEROFF",
"disaster_recovery_role": "failed"
}
```

- Recovery service status

```bash
avn service get pg-primary-dr
--project $PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "RUNNING",
"disaster_recovery_role": "active"
}
```

</TabItem>
</Tabs>

Expand Down
111 changes: 111 additions & 0 deletions docs/products/postgresql/crdr/crdr-revert-to-primary.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,117 @@ using a tool of your choice:

Replace `PRIMARY_SERVICE_NAME` with the name of the primary service, for example, `pg-demo`.

</TabItem>
<TabItem value="api" label="Aiven API">

1. Trigger the recreation of the primary service by calling the
[ServiceUpdte endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate)
to change `disaster_recovery_role` of the primary service to `passive`:

```bash {5}
curl --request PUT \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/PRIMARY_SERVICE_NAME \
-H 'Authorization: Bearer BEARER_TOKEN' \
-H 'content-type: application/json' \
--data '{"disaster_recovery_role": "passive"}'
```

Replace the following placeholders with meaningful data:

- `PROJECT_NAME`, for example `crdr-test`
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`
- `BEARER_TOKEN`

After sending the request, you can check the CRDR status on each of the CRDR peer services:

- Primary service status

```bash
avn service get pg-primary
--project $PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "REBUILDING",
"disaster_recovery_role": "passive"
}
```

- Recovery service status

```bash
avn service get pg-primary-dr
--project $PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "RUNNING",
"disaster_recovery_role": "active"
}
```

1. Promote the primary service as active by calling the
[ServiceUpdte endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate)
to change `disaster_recovery_role` of the primary service to `active`:

```bash {5}
curl --request PUT \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/PRIMARY_SERVICE_NAME \
-H 'Authorization: Bearer BEARER_TOKEN' \
-H 'content-type: application/json' \
--data '{"disaster_recovery_role": "active"}'
```

Replace the following placeholders with meaningful data:

- `PROJECT_NAME`, for example `crdr-test`
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`
- `BEARER_TOKEN`

After sending the request, you can check the CRDR status on each of the CRDR peer services:

- Primary service status

```bash
avn service get pg-primary
--project $PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "RUNNING",
"disaster_recovery_role": "active"
}
```

- Recovery service status

```bash
avn service get pg-primary-dr
--project $PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "RUNNING",
"disaster_recovery_role": "passive"
}
```

</TabItem>
</Tabs>

Expand Down
83 changes: 81 additions & 2 deletions docs/products/postgresql/crdr/enable-crdr.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ Enable the [cross-region disaster recovery (CRDR)](/docs/products/postgresql/crd
plan.
:::

- Access to the [Aiven Console](https://console.aiven.io/) or
the [Aiven CLI client installed](/docs/tools/cli)
- One of the following tool for operating CRDR:
- [Aiven Console](https://console.aiven.io/)
- [Aiven CLI](/docs/tools/cli)
- [Aiven API](/docs/tools/api)

## Set up a recovery service

Expand Down Expand Up @@ -66,6 +68,83 @@ Replace the following:
`google-europe-west-4`
- `PRIMARY_SERVICE_NAME` with the name of the primary service, for example, `pg-demo`

</TabItem>
<TabItem value="api" label="Aiven API">

Call the
[ServiceCreate endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceCreate) to
create a recovery service and enable the `disaster_recovery` service integration between
the recovery service and the primary service, for example:

```bash {14}
curl --request POST \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service \
-H 'accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer BEARER_TOKEN' \
-H 'content-type: application/json' \
--data-raw '{
"service_name": "RECOVERY_SERCICE_NAME",
"cloud": "CLOUD_PROVIDER_REGION",
"plan": "SERVICE_PLAN",
"service_type": "SERVICE_TYPE",
"disk_space_mb": DISK_SIZE,
"service_integrations": [
{
"integration_type": "disaster_recovery",
"source_service": "PRIMARY_SERVICE_NAME",
"user_config": {}
}
]
}'
```

Replace the following placeholders with meaningful data:

- `PROJECT_NAME`, for example `crdr-test`
- `BEARER_TOKEN`
- `RECOVERY_SERCICE_NAME`, for example `pg-dr-test`
- `CLOUD_PROVIDER_REGION`, for example `google-europe-west10`
- `SERVICE_PLAN`, for example `startup-4`
- `SERVICE_TYPE`, for example `pg`
- `DISK_SIZE` in MiB, for example `81920`
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`

After sending the request, you can check the CRDR status on each of the CRDR peer services:

- Primary service status

```bash
avn service get PRIMARY_SERVICE_NAME
--project PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "RUNNING",
"disaster_recovery_role": "active"
}
```

- Recovery service status

```bash
avn service get RECOVERY_SERVICE_NAME
--project PROJECT_NAME
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
```

Expect the following output:

```json
{
"state": "REBUILDING",
"disaster_recovery_role": "passive"
}
```

</TabItem>
</Tabs>

Expand Down

0 comments on commit 24bdd54

Please sign in to comment.