1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

(Documentation) Update ArangoBackup and ArangoBackupPolicy CR auto-generated docs (#1452)

* (Documentation) Update ArangoBackup and ArangoBackupPolicy CR auto-generated docs

* Sort keys before printing sections, do not use maps package
This commit is contained in:
Nikita Vaniasin 2023-10-20 12:25:30 +02:00 committed by GitHub
parent f28c6981dc
commit 66d6dca7b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 585 additions and 565 deletions

View file

@ -7,6 +7,7 @@
- (Feature) Add `spec.upgrade.debugLog` option to configure upgrade container logging
- (Documentation) Move documentation from ArangoDB into this repo, update and improve structure
- (Documentation) Update ArangoDeployment CR auto-generated docs
- (Documentation) Update ArangoBackup and ArangoBackupPolicy CR auto-generated docs
## [1.2.34](https://github.com/arangodb/kube-arangodb/tree/1.2.34) (2023-10-16)
- (Bugfix) Fix make manifests-crd-file command

239
docs/api/ArangoBackup.V1.md Normal file
View file

@ -0,0 +1,239 @@
# API Reference for ArangoBackup V1
## Spec
### .spec.backoff.iterations: int
Iterations defines number of iterations before reaching MaxDelay. Default to 5
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L31)
### .spec.backoff.max_delay: int
MaxDelay defines maximum delay in seconds. Default to 600
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L29)
### .spec.backoff.max_iterations: int
MaxIterations defines maximum number of iterations after backoff will be disabled. Default to nil (no limit)
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L33)
### .spec.backoff.min_delay: int
MinDelay defines minimum delay in seconds. Default to 30
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L27)
### .spec.deployment.name: string
Name of the ArangoDeployment Custom Resource within same namespace as ArangoBackup Custom Resource.
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L54)
### .spec.download.credentialsSecretName: string
CredentialsSecretName is the name of the secret used while accessing repository
Links:
* [Defining a secret for backup upload or download](/docs/backup-resource.md#defining-a-secret-for-backup-upload-or-download)
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L81)
### .spec.download.id: string
ID of the ArangoBackup to be downloaded
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L89)
### .spec.download.repositoryURL: string
RepositoryURL is the URL path for file storage
Same repositoryURL needs to be defined in `credentialsSecretName` if protocol is other than local.
Format: `<protocol>:/<path>`
Links:
* [rclone.org](https://rclone.org/docs/#syntax-of-remote-paths)
Example:
```yaml
s3://my-bucket/test
azure://test
```
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L77)
### .spec.lifetime: int64
Lifetime is the time after which the backup will be deleted. Format: "1.5h" or "2h45m".
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L47)
### .spec.options.allowInconsistent: bool
AllowInconsistent flag for Backup creation request.
If this value is set to true, backup is taken even if we are not able to acquire lock.
Default Value: false
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L66)
### .spec.options.timeout: float32
Timeout for Backup creation request in seconds.
Default Value: 30
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L61)
### .spec.policyName: string
PolicyName name of the ArangoBackupPolicy which created this Custom Resource
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L42)
### .spec.upload.credentialsSecretName: string
CredentialsSecretName is the name of the secret used while accessing repository
Links:
* [Defining a secret for backup upload or download](/docs/backup-resource.md#defining-a-secret-for-backup-upload-or-download)
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L81)
### .spec.upload.repositoryURL: string
RepositoryURL is the URL path for file storage
Same repositoryURL needs to be defined in `credentialsSecretName` if protocol is other than local.
Format: `<protocol>:/<path>`
Links:
* [rclone.org](https://rclone.org/docs/#syntax-of-remote-paths)
Example:
```yaml
s3://my-bucket/test
azure://test
```
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L77)
## Status
### .status.available: bool
Available Determines if we can restore from ArangoBackup
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L36)
### .status.backoff.iterations: int
[Code Reference](/pkg/apis/backup/v1/backup_status_backoff.go#L30)
### .status.backup.downloaded: bool
Downloaded Determines if ArangoBackup has been downloaded.
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L66)
### .status.backup.id: string
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L56)
### .status.backup.imported: bool
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L67)
### .status.backup.keys: []string
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L70)
### .status.backup.numberOfDBServers: uint
NumberOfDBServers Cluster size of the Backup in ArangoDB
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L62)
### .status.backup.potentiallyInconsistent: bool
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L58)
### .status.backup.sizeInBytes: uint64
SizeInBytes Size of the Backup in ArangoDB.
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L60)
### .status.backup.uploaded: bool
Uploaded Determines if ArangoBackup has been uploaded
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L64)
### .status.backup.version: string
[Code Reference](/pkg/apis/backup/v1/backup_status.go#L57)
### .status.message: string
Message for the state this object is in.
[Code Reference](/pkg/apis/backup/v1/backup_state.go#L86)
### .status.progress.jobID: string
JobID ArangoDB job ID for uploading or downloading
[Code Reference](/pkg/apis/backup/v1/backup_state.go#L109)
### .status.progress.progress: string
Progress ArangoDB job progress in percents
Example:
```yaml
90%
```
[Code Reference](/pkg/apis/backup/v1/backup_state.go#L112)
### .status.state: string
State holds the current high level state of the backup
Possible Values:
* Pending (default) - state in which Custom Resource is queued. If Backup is possible changed to "Scheduled"
* Scheduled - state which will start create/download process
* Download - state in which download request will be created on ArangoDB
* DownloadError - state when download failed
* Downloading - state for downloading progress
* Create - state for creation, field available set to true
* Upload - state in which upload request will be created on ArangoDB
* Uploading - state for uploading progress
* UploadError - state when uploading failed
* Ready - state when Backup is finished
* Deleted - state when Backup was once in ready, but has been deleted
* Failed - state for failure
* Unavailable - state when Backup is not available on the ArangoDB. It can happen in case of upgrades, node restarts etc.
[Code Reference](/pkg/apis/backup/v1/backup_state.go#L80)

View file

@ -0,0 +1,132 @@
# API Reference for ArangoBackupPolicy V1
## Spec
### .spec.allowConcurrent: bool
AllowConcurrent if false, ArangoBackup will not be created when previous Backups are not finished
Default Value: true
[Code Reference](/pkg/apis/backup/v1/backup_policy_spec.go#L35)
### .spec.maxBackups: int
MaxBackups defines how many backups should be kept in history (per deployment). Oldest healthy Backups will be deleted.
If not specified or 0 then no limit is applied
Default Value: 0
[Code Reference](/pkg/apis/backup/v1/backup_policy_spec.go#L43)
### .spec.schedule: string
Schedule is cron-compatible specification of backup schedule
Parsed by https://godoc.org/github.com/robfig/cron
[Code Reference](/pkg/apis/backup/v1/backup_policy_spec.go#L32)
### .spec.selector: meta.LabelSelector
DeploymentSelector Selector definition for selecting matching ArangoBackup Custom Resources.
Links:
* [Kubernetes Documentation](https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#LabelSelector)
[Code Reference](/pkg/apis/backup/v1/backup_policy_spec.go#L39)
### .spec.template.backoff.iterations: int
Iterations defines number of iterations before reaching MaxDelay. Default to 5
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L31)
### .spec.template.backoff.max_delay: int
MaxDelay defines maximum delay in seconds. Default to 600
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L29)
### .spec.template.backoff.max_iterations: int
MaxIterations defines maximum number of iterations after backoff will be disabled. Default to nil (no limit)
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L33)
### .spec.template.backoff.min_delay: int
MinDelay defines minimum delay in seconds. Default to 30
[Code Reference](/pkg/apis/backup/v1/backup_spec_backoff.go#L27)
### .spec.template.lifetime: int64
Lifetime is the time after which the backup will be deleted. Format: "1.5h" or "2h45m".
[Code Reference](/pkg/apis/backup/v1/backup_policy_spec.go#L61)
### .spec.template.options.allowInconsistent: bool
AllowInconsistent flag for Backup creation request.
If this value is set to true, backup is taken even if we are not able to acquire lock.
Default Value: false
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L66)
### .spec.template.options.timeout: float32
Timeout for Backup creation request in seconds.
Default Value: 30
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L61)
### .spec.template.upload.credentialsSecretName: string
CredentialsSecretName is the name of the secret used while accessing repository
Links:
* [Defining a secret for backup upload or download](/docs/backup-resource.md#defining-a-secret-for-backup-upload-or-download)
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L81)
### .spec.template.upload.repositoryURL: string
RepositoryURL is the URL path for file storage
Same repositoryURL needs to be defined in `credentialsSecretName` if protocol is other than local.
Format: `<protocol>:/<path>`
Links:
* [rclone.org](https://rclone.org/docs/#syntax-of-remote-paths)
Example:
```yaml
s3://my-bucket/test
azure://test
```
This field is **immutable**: can't be changed after backup creation
[Code Reference](/pkg/apis/backup/v1/backup_spec.go#L77)
## Status
### .status.message: string
Message from the operator in case of failures - schedule not valid, ArangoBackupPolicy not valid
[Code Reference](/pkg/apis/backup/v1/backup_policy_status.go#L33)
### .status.scheduled: meta.Time
Scheduled Next scheduled time in UTC
[Code Reference](/pkg/apis/backup/v1/backup_policy_status.go#L31)

View file

@ -3471,12 +3471,13 @@ Links:
### .spec.storageEngine: string
StorageEngine specifies the type of storage engine used for all servers in the cluster.
This setting cannot be changed after the cluster has been created.
Possible Values:
* RocksDB (default) - To use the RocksDB storage engine.
* MMFiles - To use the MMFiles storage engine. Deprecated.
This field is **immutable**: This setting cannot be changed after the cluster has been created.
[Code Reference](/pkg/apis/deployment/v1/deployment_spec.go#L72)
### .spec.sync.auth.clientCASecretName: string

View file

@ -1,5 +1,7 @@
# Custom Resources API Reference
- [ArangoBackup.V1](./ArangoBackup.V1.md)
- [ArangoBackupPolicy.V1](./ArangoBackupPolicy.V1.md)
- [ArangoDeployment.V1](./ArangoDeployment.V1.md)
- [ArangoMember.V1](./ArangoMember.V1.md)

View file

@ -1,221 +1,16 @@
# ArangoBackup Custom Resource
[Full CustomResourceDefinition reference ->](./api/ArangoBackup.V1.md)
The ArangoBackup Operator creates and maintains ArangoBackups
in a Kubernetes cluster, given a Backup specification.
This deployment specification is a `CustomResource` following
a `CustomResourceDefinition` created by the operator.
## Examples:
### Create simple Backup
## Defining a secret for backup upload or download
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackup"
metadata:
name: "example-arangodb-backup"
namespace: "arangodb"
spec:
deployment:
name: "my-deployment"
```
Action:
Create Backup on ArangoDeployment named `my-deployment`
### Create and upload Backup
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackup"
metadata:
name: "example-arangodb-backup"
namespace: "arangodb"
spec:
deployment:
name: "my-deployment"
upload:
repositoryURL: "S3://test/kube-test"
credentialsSecretName: "my-s3-rclone-credentials"
```
Action:
Create Backup on ArangoDeployment named `my-deployment` and upload it to `S3://test/kube-test`.
### Download Backup
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackup"
metadata:
name: "example-arangodb-backup"
namespace: "arangodb"
spec:
deployment:
name: "my-deployment"
download:
repositoryURL: "S3://test/kube-test"
credentialsSecretName: "my-s3-rclone-credentials"
id: "backup-id"
```
Download Backup with id `backup-id` from `S3://test/kube-test` on ArangoDeployment named `my-deployment`
### Restore
Information about restoring can be found in [ArangoDeployment](deployment-resource-reference.md).
## Advertised fields
List of custom columns in CRD specification for Kubectl:
- `.spec.policyName` - optional name of the policy
- `.spec.deployment.name` - name of the deployment
- `.status.state` - current ArangoBackup Custom Resource state
- `.status.message` - additional message for current state
## ArangoBackup Custom Resource Spec:
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackup"
metadata:
name: "example-arangodb-backup"
namespace: "arangodb"
spec:
policyName: "my-policy"
deployment:
name: "my-deployment"
options:
timeout: 3
force: true
download:
repositoryURL: "s3:/..."
credentialsSecretName: "secret-name"
id: "backup-id"
upload:
repositoryURL: "s3:/..."
credentialsSecretName: "secret-name"
status:
state: "Ready"
time: "time"
message: "Message details" -
progress:
jobID: "id"
progress: "10%"
backup:
id: "id"
version: "3.9.0-dev"
forced: true
uploaded: true
downloaded: true
createdAt: "time"
sizeInBytes: 1
numberOfDBServers: 3
available: true
```
## `spec: Object`
Spec of the ArangoBackup Custom Resource.
Required: true
Default: {}
### `spec.deployment: Object`
ArangoDeployment specification.
Field is immutable.
Required: true
Default: {}
#### `spec.deployment.name: String`
Name of the ArangoDeployment Custom Resource within same namespace as ArangoBackup Custom Resource.
Field is immutable.
Required: true
Default: ""
#### `spec.policyName: String`
Name of the ArangoBackupPolicy which created this Custom Resource
Field is immutable.
Required: false
Default: ""
### `spec.options: Object`
Backup options.
Field is immutable.
Required: false
Default: {}
#### `spec.options.timeout: float`
Timeout for Backup creation request in seconds.
Field is immutable.
Required: false
Default: 30
#### `spec.options.allowInconsistent: bool`
AllowInconsistent flag for Backup creation request.
If this value is set to true, backup is taken even if we are not able to acquire lock.
Field is immutable.
Required: false
Default: false
### `spec.download: Object`
Backup download settings.
Field is immutable.
Required: false
Default: {}
#### `spec.download.repositoryURL: string`
Field is immutable. Protocol needs to be defined in `spec.download.credentialsSecretName` if protocol is other than local.
Mode protocols can be found at [rclone.org](https://rclone.org/).
Format: `<protocol>:/<path>`
Examples:
- `s3://my-bucket/test`
- `azure://test`
Required: true
Default: ""
#### `spec.download.credentialsSecretName: string`
Field is immutable. Name of the secret used while accessing repository
Secret structure:
`credentialsSecretName` in `spec.download` and `spec.upload` expects the next structure for secret:
```yaml
apiVersion: v1
@ -259,10 +54,6 @@ AWS S3 example - based on [rclone S3](https://rclone.org/s3/) documentation and
and you can from now use `S3://bucket/path`.
Required: false
Default: ""
##### Use IAM with Amazon EKS
Instead of creating and distributing your AWS credentials to the containers or
@ -364,191 +155,65 @@ Kubernetes service account and configure pods to use the service account.
credentialsSecretName: arangodb-cluster-backup-credentials
```
#### `spec.download.id: string`
## Examples:
### Create simple Backup
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackup"
metadata:
name: "example-arangodb-backup"
namespace: "arangodb"
spec:
deployment:
name: "my-deployment"
```
Action:
Create Backup on ArangoDeployment named `my-deployment`
### Create and upload Backup
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackup"
metadata:
name: "example-arangodb-backup"
namespace: "arangodb"
spec:
deployment:
name: "my-deployment"
upload:
repositoryURL: "S3://test/kube-test"
credentialsSecretName: "my-s3-rclone-credentials"
```
Action:
Create Backup on ArangoDeployment named `my-deployment` and upload it to `S3://test/kube-test`.
### Download Backup
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackup"
metadata:
name: "example-arangodb-backup"
namespace: "arangodb"
spec:
deployment:
name: "my-deployment"
download:
repositoryURL: "S3://test/kube-test"
credentialsSecretName: "my-s3-rclone-credentials"
id: "backup-id"
```
Download Backup with id `backup-id` from `S3://test/kube-test` on ArangoDeployment named `my-deployment`
## Restore
To restore a data for deployment for specific backup, use `spec.restoreFrom` field of [ArangoDeployment](api/ArangoDeployment.V1.md#specrestorefrom-string).
ID of the ArangoBackup to be downloaded.
Field is immutable.
Required: true
Default: ""
### `spec.upload: Object`
Backup upload settings.
This field can be removed and created again with different values. This operation will trigger upload again.
Fields in Custom Resource Spec Upload are immutable.
Required: false
Default: {}
#### `spec.upload.repositoryURL: string`
Same structure as `spec.download.repositoryURL`.
Required: true
Default: ""
#### `spec.upload.credentialsSecretName: string`
Same structure as `spec.download.credentialsSecretName`.
Required: false
Default: ""
## `status: Object`
Status of the ArangoBackup Custom Resource. This field is managed by subresource and only by operator
Required: true
Default: {}
### `status.state: enum`
State of the ArangoBackup object.
Required: true
Default: ""
Possible states:
- "" - default state, changed to "Pending"
- "Pending" - state in which Custom Resource is queued. If Backup is possible changed to "Scheduled"
- "Scheduled" - state which will start create/download process
- "Download" - state in which download request will be created on ArangoDB
- "DownloadError" - state when download failed
- "Downloading" - state for downloading progress
- "Create" - state for creation, field available set to true
- "Upload" - state in which upload request will be created on ArangoDB
- "Uploading" - state for uploading progress
- "UploadError" - state when uploading failed
- "Ready" - state when Backup is finished
- "Deleted" - state when Backup was once in ready, but has been deleted
- "Failed" - state for failure
- "Unavailable" - state when Backup is not available on the ArangoDB. It can happen in case of upgrades, node restarts etc.
### `status.time: timestamp`
Time in UTC when state of the ArangoBackup Custom Resource changed.
Required: true
Default: ""
### `status.message: string`
State message of the ArangoBackup Custom Resource.
Required: false
Default: ""
### `status.progress: object`
Progress info of the uploading and downloading process.
Required: false
Default: {}
#### `status.progress.jobID: string`
ArangoDB job ID for uploading or downloading.
Required: true
Default: ""
#### `status.progress.progress: string`
ArangoDeployment job progress.
Required: true
Default: "0%"
### `status.backup: object`
ArangoBackup details.
Required: true
Default: {}
#### `status.backup.id: string`
ArangoBackup ID.
Required: true
Default: ""
#### `status.backup.version: string`
ArangoBackup version.
Required: true
Default: ""
#### `status.backup.potentiallyInconsistent: bool`
ArangoBackup potentially inconsistent flag.
Required: false
Default: false
#### `status.backup.uploaded: bool`
Determines if ArangoBackup has been uploaded.
Required: false
Default: false
#### `status.backup.downloaded: bool`
Determines if ArangoBackup has been downloaded.
Required: false
Default: false
#### `status.backup.createdAt: TimeStamp`
ArangoBackup Custom Resource creation time in UTC.
Required: true
Default: now()
#### `status.backup.sizeInBytes: uint64`
Size of the Backup in ArangoDB.
Required: true
Default: 0
#### `status.backup.numberOfDBServers: uint`
Cluster size of the Backup in ArangoDB.
Required: true
Default: 0
### `status.available: bool`
Determines if we can restore from ArangoBackup.
Required: true
Default: false

View file

@ -1,5 +1,7 @@
# ArangoBackupPolicy Custom Resource
[Full CustomResourceDefinition reference ->](./api/ArangoBackupPolicy.V1.md)
The ArangoBackupPolicy represents schedule definition for creating ArangoBackup Custom Resources by operator.
This deployment specification is a `CustomResource` following a `CustomResourceDefinition` created by the operator.
@ -68,118 +70,3 @@ spec:
maxBackups: 10
allowConcurrent: False
```
## ArangoBackup Custom Resource Spec
```yaml
apiVersion: "backup.arangodb.com/v1"
kind: "ArangoBackupPolicy"
metadata:
name: "example-arangodb-backup-policy"
spec:
schedule: "*/15 * * * * "
selector:
matchLabels:
labelName: "labelValue"
matchExpressions: []
template:
options:
timeout: 3
force: true
upload:
repositoryURL: "s3:/..."
credentialsSecretName: "secret-name"
status:
scheduled: "time"
message: "message"
```
## `spec: Object`
Spec of the ArangoBackupPolicy Custom Resource
Required: true
Default: {}
### `spec.schedule: String`
Schedule definition. Parser from https://godoc.org/github.com/robfig/cron
Required: true
Default: ""
### `spec.allowConcurrent: String`
If false, ArangoBackup will not be created when previous backups are not finished.
`ScheduleSkipped` event will be published in that case.
Required: false
Default: True
### `spec.maxBackups: Integer`
If > 0, then old healthy backups of that policy will be removed to ensure that only `maxBackups` are present at same time.
`CleanedUpOldBackups` event will be published on automatic removal of old backups.
Required: false
Default: 0
### `spec.selector: Object`
Selector definition for selecting matching ArangoBackup Custom Resources. Parser from https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#LabelSelector
Required: false
Default: {}
### `spec.template: ArangoBackupTemplate`
Template for the ArangoBackup Custom Resource
Required: false
Default: {}
### `spec.template.options: ArangoBackup - spec.options`
ArangoBackup options
Required: false
Default: {}
### `spec.template.upload: ArangoBackup - spec.upload`
ArangoBackup upload configuration
Required: false
Default: {}
## `status: Object`
Status of the ArangoBackupPolicy Custom Resource managed by operator
Required: true
Default: {}
### `status.scheduled: TimeStamp`
Next scheduled time in UTC
Required: true
Default: ""
### `status.message: String`
Message from the operator in case of failure - schedule not valid, ArangoBackupPolicy not valid
Required: false
Default: ""

View file

@ -38,7 +38,8 @@ import (
"github.com/stretchr/testify/require"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
deploymentApi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util"
)
@ -147,24 +148,39 @@ func Test_GenerateAPIDocs(t *testing.T) {
root := os.Getenv("ROOT")
require.NotEmpty(t, root)
docs := map[string]map[string]interface{}{
"ArangoDeployment.V1": {
"Spec": api.ArangoDeployment{}.Spec,
input := map[string]map[string]map[string]interface{}{
fmt.Sprintf("%s/pkg/apis/deployment/v1", root): {
"ArangoDeployment.V1": {
"Spec": deploymentApi.ArangoDeployment{}.Spec,
},
"ArangoMember.V1": {
"Spec": deploymentApi.ArangoMember{}.Spec,
},
},
"ArangoMember.V1": {
"Spec": api.ArangoMember{}.Spec,
fmt.Sprintf("%s/pkg/apis/backup/v1", root): {
"ArangoBackup.V1": {
"Spec": backupApi.ArangoBackup{}.Spec,
"Status": backupApi.ArangoBackup{}.Status,
},
"ArangoBackupPolicy.V1": {
"Spec": backupApi.ArangoBackupPolicy{}.Spec,
"Status": backupApi.ArangoBackupPolicy{}.Status,
},
},
}
resultPaths := generateDocs(t, docs, fmt.Sprintf("%s/pkg/apis/deployment/v1", root))
resultPaths := make(map[string]string)
for apiDir, docs := range input {
astFields, fileSets := parseSourceFiles(t, apiDir)
util.CopyMap(resultPaths, generateDocs(t, docs, astFields, fileSets))
}
generateIndex(t, resultPaths)
}
func generateDocs(t *testing.T, objects map[string]map[string]interface{}, paths ...string) map[string]string {
func generateDocs(t *testing.T, objects map[string]map[string]interface{}, docs map[string]*ast.Field, fs *token.FileSet) map[string]string {
root := os.Getenv("ROOT")
require.NotEmpty(t, root)
docs, fs := getDocs(t, paths...)
outPaths := make(map[string]string)
for object, sections := range objects {
@ -258,12 +274,12 @@ func generateDocs(t *testing.T, objects map[string]map[string]interface{}, paths
write(t, out, "# API Reference for %s\n\n", strings.ReplaceAll(object, ".", " "))
for name, section := range renderSections {
util.IterateSorted(renderSections, func(name string, section []byte) {
write(t, out, "## %s\n\n", name)
_, err = out.Write(section)
require.NoError(t, err)
}
})
})
}
return outPaths
@ -282,9 +298,9 @@ func generateIndex(t *testing.T, apiDocs map[string]string) {
write(t, out, "# Custom Resources API Reference\n\n")
for name, filePath := range apiDocs {
util.IterateSorted(apiDocs, func(name string, filePath string) {
write(t, out, " - [%s](./%s)\n", name, filePath)
}
})
write(t, out, "\n")
}
@ -359,7 +375,7 @@ func iterateOverObjectDirect(t *testing.T, docs map[string]*ast.Field, name stri
doc, ok := docs[docName]
if !ok && !f.Anonymous {
require.True(t, ok, docName, f.Name)
require.True(t, ok, "field %s was not parsed from source", docName)
}
if !f.Anonymous {
@ -391,7 +407,7 @@ func iterateOverObjectDirect(t *testing.T, docs map[string]*ast.Field, name stri
r[k] = v
}
default:
require.Fail(t, object.String())
require.Failf(t, "unsupported type", "%s for %s at %s", object.String(), name, path)
}
return r
@ -437,7 +453,11 @@ func extractNotTags(n *ast.Field) ([]string, bool) {
func isSimpleType(obj reflect.Type) (string, bool) {
switch obj.Kind() {
case reflect.String, reflect.Int64, reflect.Bool, reflect.Int, reflect.Uint16, reflect.Int32:
case reflect.String,
reflect.Bool,
reflect.Int, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint16, reflect.Uint64,
reflect.Float32:
return obj.Kind().String(), true
}
@ -458,7 +478,7 @@ func extractTag(tag string) (string, bool) {
return parts[0], false
}
func getDocs(t *testing.T, paths ...string) (map[string]*ast.Field, *token.FileSet) {
func parseSourceFiles(t *testing.T, paths ...string) (map[string]*ast.Field, *token.FileSet) {
d, fs := parseMultipleDirs(t, parser.ParseComments, paths...)
r := map[string]*ast.Field{}
@ -513,8 +533,7 @@ func parseMultipleDirs(t *testing.T, mode parser.Mode, dirs ...string) (map[stri
require.NoError(t, err)
for k, v := range d {
_, ok := r[k]
require.False(t, ok)
require.NotContains(t, r, k)
r[k] = v
}
}

View file

@ -28,13 +28,18 @@ import (
type ArangoBackupPolicySpec struct {
// Schedule is cron-compatible specification of backup schedule
// Parsed by https://godoc.org/github.com/robfig/cron
Schedule string `json:"schedule"`
// AllowConcurrent if false, ArangoBackup will not be created when previous Backups are not finished. Defaults to true
// AllowConcurrent if false, ArangoBackup will not be created when previous Backups are not finished
// +doc/default: true
AllowConcurrent *bool `json:"allowConcurrent,omitempty"`
// DeploymentSelector specifies which deployments should get a backup
// DeploymentSelector Selector definition for selecting matching ArangoBackup Custom Resources.
// +doc/type: meta.LabelSelector
// +doc/link: Kubernetes Documentation|https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#LabelSelector
DeploymentSelector *meta.LabelSelector `json:"selector,omitempty"`
// MaxBackups defines how many backups should be kept in history (per deployment). Oldest Backups will be deleted.
// MaxBackups defines how many backups should be kept in history (per deployment). Oldest healthy Backups will be deleted.
// If not specified or 0 then no limit is applied
// +doc/default: 0
MaxBackups int `json:"maxBackups,omitempty"`
// ArangoBackupTemplate specifies additional options for newly created ArangoBackup
BackupTemplate ArangoBackupTemplate `json:"template"`

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -24,7 +24,11 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ArangoBackupPolicyStatus Status of the ArangoBackupPolicy Custom Resource managed by operator
type ArangoBackupPolicyStatus struct {
// Scheduled Next scheduled time in UTC
// +doc/type: meta.Time
Scheduled meta.Time `json:"scheduled,omitempty"`
Message string `json:"message,omitempty"`
// Message from the operator in case of failures - schedule not valid, ArangoBackupPolicy not valid
Message string `json:"message,omitempty"`
}

View file

@ -22,18 +22,23 @@ package v1
import meta "k8s.io/apimachinery/pkg/apis/meta/v1"
// ArangoBackupSpec Spec of the ArangoBackup Custom Resource
type ArangoBackupSpec struct {
// Deployment
// Deployment describes the deployment which should have a backup
Deployment ArangoBackupSpecDeployment `json:"deployment,omitempty"`
// Options specifies backup options
Options *ArangoBackupSpecOptions `json:"options,omitempty"`
// Download
// Download Backup download settings
Download *ArangoBackupSpecDownload `json:"download,omitempty"`
// Upload
// Upload Backup upload settings.
// This field can be removed and created again with different values. This operation will trigger upload again.
Upload *ArangoBackupSpecOperation `json:"upload,omitempty"`
// PolicyName name of the ArangoBackupPolicy which created this Custom Resource
// +doc/immutable: can't be changed after backup creation
PolicyName *string `json:"policyName,omitempty"`
Backoff *ArangoBackupSpecBackOff `json:"backoff,omitempty"`
@ -42,22 +47,44 @@ type ArangoBackupSpec struct {
Lifetime *meta.Duration `json:"lifetime,omitempty"`
}
// ArangoBackupSpecDeployment describes the deployment which should have a backup
type ArangoBackupSpecDeployment struct {
// Name of the ArangoDeployment Custom Resource within same namespace as ArangoBackup Custom Resource.
// +doc/immutable: can't be changed after backup creation
Name string `json:"name,omitempty"`
}
type ArangoBackupSpecOptions struct {
Timeout *float32 `json:"timeout,omitempty"`
AllowInconsistent *bool `json:"allowInconsistent,omitempty"`
// Timeout for Backup creation request in seconds.
// +doc/immutable: can't be changed after backup creation
// +doc/default: 30
Timeout *float32 `json:"timeout,omitempty"`
// AllowInconsistent flag for Backup creation request.
// If this value is set to true, backup is taken even if we are not able to acquire lock.
// +doc/immutable: can't be changed after backup creation
// +doc/default: false
AllowInconsistent *bool `json:"allowInconsistent,omitempty"`
}
type ArangoBackupSpecOperation struct {
RepositoryURL string `json:"repositoryURL"`
// RepositoryURL is the URL path for file storage
// Same repositoryURL needs to be defined in `credentialsSecretName` if protocol is other than local.
// Format: `<protocol>:/<path>`
// +doc/example: s3://my-bucket/test
// +doc/example: azure://test
// +doc/immutable: can't be changed after backup creation
// +doc/link: rclone.org|https://rclone.org/docs/#syntax-of-remote-paths
RepositoryURL string `json:"repositoryURL"`
// CredentialsSecretName is the name of the secret used while accessing repository
// +doc/immutable: can't be changed after backup creation
// +doc/link: Defining a secret for backup upload or download|/docs/backup-resource.md#defining-a-secret-for-backup-upload-or-download
CredentialsSecretName string `json:"credentialsSecretName,omitempty"`
}
type ArangoBackupSpecDownload struct {
ArangoBackupSpecOperation `json:",inline"`
// ID of the ArangoBackup to be downloaded
// +doc/immutable: can't be changed after backup creation
ID string `json:"id"`
}

View file

@ -64,14 +64,28 @@ var ArangoBackupStateMap = state.Map{
type ArangoBackupState struct {
// State holds the current high level state of the backup
// +doc/enum: Pending|state in which Custom Resource is queued. If Backup is possible changed to "Scheduled"
// +doc/enum: Scheduled|state which will start create/download process
// +doc/enum: Download|state in which download request will be created on ArangoDB
// +doc/enum: DownloadError|state when download failed
// +doc/enum: Downloading|state for downloading progress
// +doc/enum: Create|state for creation, field available set to true
// +doc/enum: Upload|state in which upload request will be created on ArangoDB
// +doc/enum: Uploading|state for uploading progress
// +doc/enum: UploadError|state when uploading failed
// +doc/enum: Ready|state when Backup is finished
// +doc/enum: Deleted|state when Backup was once in ready, but has been deleted
// +doc/enum: Failed|state for failure
// +doc/enum: Unavailable|state when Backup is not available on the ArangoDB. It can happen in case of upgrades, node restarts etc.
State state.State `json:"state"`
// Time is the time in UTC when state of the ArangoBackup Custom Resource changed.
Time meta.Time `json:"time"`
// Message for the state this object is in.
Message string `json:"message,omitempty"`
// Progress for the operation
// Progress info of the uploading and downloading process
Progress *ArangoBackupProgress `json:"progress,omitempty"`
}
@ -91,7 +105,10 @@ func (a *ArangoBackupState) Equal(b *ArangoBackupState) bool {
}
type ArangoBackupProgress struct {
JobID string `json:"jobID"`
// JobID ArangoDB job ID for uploading or downloading
JobID string `json:"jobID"`
// Progress ArangoDB job progress in percents
// +doc/example: 90%
Progress string `json:"progress"`
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -30,9 +30,12 @@ import (
// an ArangoBackup.
type ArangoBackupStatus struct {
ArangoBackupState `json:",inline"`
Backup *ArangoBackupDetails `json:"backup,omitempty"`
Available bool `json:"available"`
Backoff *ArangoBackupStatusBackOff `json:"backoff,omitempty"`
// Backup ArangoBackup details
Backup *ArangoBackupDetails `json:"backup,omitempty"`
// Available Determines if we can restore from ArangoBackup
Available bool `json:"available"`
// Backoff shows current backoff status
Backoff *ArangoBackupStatusBackOff `json:"backoff,omitempty"`
}
func (a *ArangoBackupStatus) Equal(b *ArangoBackupStatus) bool {
@ -50,16 +53,21 @@ func (a *ArangoBackupStatus) Equal(b *ArangoBackupStatus) bool {
}
type ArangoBackupDetails struct {
ID string `json:"id"`
Version string `json:"version"`
PotentiallyInconsistent *bool `json:"potentiallyInconsistent,omitempty"`
SizeInBytes uint64 `json:"sizeInBytes,omitempty"`
NumberOfDBServers uint `json:"numberOfDBServers,omitempty"`
Uploaded *bool `json:"uploaded,omitempty"`
Downloaded *bool `json:"downloaded,omitempty"`
Imported *bool `json:"imported,omitempty"`
CreationTimestamp meta.Time `json:"createdAt"`
Keys shared.HashList `json:"keys,omitempty"`
ID string `json:"id"`
Version string `json:"version"`
PotentiallyInconsistent *bool `json:"potentiallyInconsistent,omitempty"`
// SizeInBytes Size of the Backup in ArangoDB.
SizeInBytes uint64 `json:"sizeInBytes,omitempty"`
// NumberOfDBServers Cluster size of the Backup in ArangoDB
NumberOfDBServers uint `json:"numberOfDBServers,omitempty"`
// Uploaded Determines if ArangoBackup has been uploaded
Uploaded *bool `json:"uploaded,omitempty"`
// Downloaded Determines if ArangoBackup has been downloaded.
Downloaded *bool `json:"downloaded,omitempty"`
Imported *bool `json:"imported,omitempty"`
// CreationTimestamp ArangoBackup Custom Resource creation time in UTC
CreationTimestamp meta.Time `json:"createdAt"`
Keys shared.HashList `json:"keys,omitempty"`
}
func (a *ArangoBackupDetails) Equal(b *ArangoBackupDetails) bool {

View file

@ -67,7 +67,7 @@ type DeploymentSpec struct {
// StorageEngine specifies the type of storage engine used for all servers in the cluster.
// +doc/enum: RocksDB|To use the RocksDB storage engine.
// +doc/enum: MMFiles|To use the MMFiles storage engine. Deprecated.
// This setting cannot be changed after the cluster has been created.
// +doc/immutable: This setting cannot be changed after the cluster has been created.
// +doc/default: RocksDB
StorageEngine *StorageEngine `json:"storageEngine,omitempty"`

View file

@ -67,7 +67,7 @@ type DeploymentSpec struct {
// StorageEngine specifies the type of storage engine used for all servers in the cluster.
// +doc/enum: RocksDB|To use the RocksDB storage engine.
// +doc/enum: MMFiles|To use the MMFiles storage engine. Deprecated.
// This setting cannot be changed after the cluster has been created.
// +doc/immutable: This setting cannot be changed after the cluster has been created.
// +doc/default: RocksDB
StorageEngine *StorageEngine `json:"storageEngine,omitempty"`

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -42,3 +42,16 @@ func SortKeys(m interface{}) []string {
return r
}
func CopyMap[K comparable, V any](dst, src map[K]V) {
// TODO: replace with maps.Copy when switching to go1.21
for k, v := range src {
dst[k] = v
}
}
func IterateSorted[V any](m map[string]V, cb func(string, V)) {
for _, k := range SortKeys(m) {
cb(k, m[k])
}
}