Skip to content
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

Add backup estimates endpoint #195

Merged
merged 23 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions cmd/backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ func run() int {
slog.Info("Aerospike Backup Service", "commit", commit, "buildTime", buildTime)
// schedule all configured backups
backends := service.NewBackupBackends(config)
scheduler, err := service.ScheduleBackup(ctx, config, backends)
handlers := service.MakeHandlers(config, backends)
scheduler, err := service.ScheduleBackup(ctx, config, handlers)
if err != nil {
return err
}
// run HTTP server
err = runHTTPServer(ctx, backends, config, scheduler)
err = runHTTPServer(ctx, backends, config, scheduler, handlers)
// shutdown shared resources
shared.Shutdown()
// stop the scheduler
Expand Down Expand Up @@ -119,9 +120,13 @@ func readConfiguration() (*model.Config, error) {
return config, nil
}

func runHTTPServer(ctx context.Context, backends service.BackendsHolder,
config *model.Config, scheduler quartz.Scheduler) error {
httpServer := server.NewHTTPServer(backends, config, scheduler)
func runHTTPServer(ctx context.Context,
backends service.BackendsHolder,
config *model.Config,
scheduler quartz.Scheduler,
handlerHolder service.BackupHandlerHolder,
) error {
httpServer := server.NewHTTPServer(backends, config, scheduler, handlerHolder)
go func() {
httpServer.Start()
}()
Expand Down
30 changes: 23 additions & 7 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ backup-policies:
remove-files: KeepAll
bandwidth: 120000
sealed: true
encryptedCompressedPolicy:
encryptedCompressedPolicy128:
parallel: 8
remove-files: RemoveAll
sealed: true
Expand All @@ -54,6 +54,16 @@ backup-policies:
compression:
level: 20
mode: ZSTD
encryptedCompressedPolicy256:
parallel: 8
remove-files: RemoveAll
sealed: true
encryption:
key-file: encryptionKey
mode: AES256
compression:
level: 20
mode: ZSTD
notSealed:
parallel: 8
remove-files: KeepAll
Expand Down Expand Up @@ -194,12 +204,18 @@ backup-routines:
storage: local
namespaces: ["source-ns13"]
backup-policy: keepFilesPolicySlow
fullBackupEncrypedCompressed:
interval-cron: "@yearly"
source-cluster: absDefaultCluster
storage: local
namespaces: ["source-ns18"]
backup-policy: encryptedCompressedPolicy
fullBackupEncrypedCompressed128:
interval-cron: "@yearly"
source-cluster: absDefaultCluster
storage: local
namespaces: ["source-ns18"]
backup-policy: encryptedCompressedPolicy128
fullBackupEncrypedCompressed256:
interval-cron: "@yearly"
source-cluster: absDefaultCluster
storage: local
namespaces: ["source-ns21"]
backup-policy: encryptedCompressedPolicy256
noIndexesUdfsRecords:
interval-cron: "@yearly"
source-cluster: absDefaultCluster
Expand Down
68 changes: 67 additions & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,41 @@ const docTemplate = `{
}
}
},
"/v1/backups/currentBackup/{name}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Backup"
],
"summary": "Get current backup statistics.",
"operationId": "getCurrentBackup",
"parameters": [
{
"type": "string",
"description": "Backup routine name",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Current backup statistics",
"schema": {
"$ref": "#/definitions/model.CurrentBackups"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "string"
}
}
}
}
},
"/v1/backups/full": {
"get": {
"produces": [
Expand Down Expand Up @@ -1741,6 +1776,37 @@ const docTemplate = `{
}
}
},
"model.CurrentBackup": {
"type": "object",
"properties": {
"done_records": {
"type": "integer"
},
"estimated_end_time": {
"type": "string"
},
"percentage_done": {
"type": "integer"
},
"start_time": {
"type": "string"
},
"total_records": {
"type": "integer"
}
}
},
"model.CurrentBackups": {
"type": "object",
"properties": {
"full": {
"$ref": "#/definitions/model.CurrentBackup"
},
"incremental": {
"$ref": "#/definitions/model.CurrentBackup"
}
}
},
"model.EncryptionPolicy": {
"description": "EncryptionPolicy contains backup encryption information.",
"type": "object",
Expand Down Expand Up @@ -2290,7 +2356,7 @@ const docTemplate = `{
"example": "eu-central-1"
},
"type": {
"description": "The type of the storage provider (0 - Local, 1 - AWS S3).",
"description": "The type of the storage provider",
"enum": [
"local",
"aws-s3"
Expand Down
71 changes: 70 additions & 1 deletion docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,44 @@
"tags" : [ "System" ]
}
},
"/v1/backups/currentBackup/{name}" : {
"get" : {
"operationId" : "getCurrentBackup",
"parameters" : [ {
"description" : "Backup routine name",
"in" : "path",
"name" : "name",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/model.CurrentBackups"
}
}
},
"description" : "Current backup statistics"
},
"404" : {
"content" : {
"application/json" : {
"schema" : {
"type" : "string"
}
}
},
"description" : "Not Found"
}
},
"summary" : "Get current backup statistics.",
"tags" : [ "Backup" ]
}
},
"/v1/backups/full" : {
"get" : {
"operationId" : "getFullBackups",
Expand Down Expand Up @@ -1842,6 +1880,37 @@
},
"type" : "object"
},
"model.CurrentBackup" : {
"properties" : {
"done_records" : {
"type" : "integer"
},
"estimated_end_time" : {
"type" : "string"
},
"percentage_done" : {
"type" : "integer"
},
"start_time" : {
"type" : "string"
},
"total_records" : {
"type" : "integer"
}
},
"type" : "object"
},
"model.CurrentBackups" : {
"properties" : {
"full" : {
"$ref" : "#/components/schemas/model.CurrentBackup"
},
"incremental" : {
"$ref" : "#/components/schemas/model.CurrentBackup"
}
},
"type" : "object"
},
"model.EncryptionPolicy" : {
"description" : "EncryptionPolicy contains backup encryption information.",
"properties" : {
Expand Down Expand Up @@ -2318,7 +2387,7 @@
"allOf" : [ {
"$ref" : "#/components/schemas/model.StorageType"
} ],
"description" : "The type of the storage provider (0 - Local, 1 - AWS S3).",
"description" : "The type of the storage provider",
"type" : "object"
}
},
Expand Down
67 changes: 66 additions & 1 deletion docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,32 @@ paths:
summary: Readiness endpoint.
tags:
- System
/v1/backups/currentBackup/{name}:
get:
operationId: getCurrentBackup
parameters:
- description: Backup routine name
in: path
name: name
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/model.CurrentBackups'
description: Current backup statistics
"404":
content:
application/json:
schema:
type: string
description: Not Found
summary: Get current backup statistics.
tags:
- Backup
/v1/backups/full:
get:
operationId: getFullBackups
Expand Down Expand Up @@ -1477,6 +1503,45 @@ components:
example: testUser
type: string
type: object
model.CurrentBackup:
example:
start_time: start_time
estimated_end_time: estimated_end_time
done_records: 0
total_records: 1
percentage_done: 6
properties:
done_records:
type: integer
estimated_end_time:
type: string
percentage_done:
type: integer
start_time:
type: string
total_records:
type: integer
type: object
model.CurrentBackups:
example:
incremental:
start_time: start_time
estimated_end_time: estimated_end_time
done_records: 0
total_records: 1
percentage_done: 6
full:
start_time: start_time
estimated_end_time: estimated_end_time
done_records: 0
total_records: 1
percentage_done: 6
properties:
full:
$ref: '#/components/schemas/model.CurrentBackup'
incremental:
$ref: '#/components/schemas/model.CurrentBackup'
type: object
model.EncryptionPolicy:
description: EncryptionPolicy contains backup encryption information.
properties:
Expand Down Expand Up @@ -1951,7 +2016,7 @@ components:
type:
allOf:
- $ref: '#/components/schemas/model.StorageType'
description: "The type of the storage provider (0 - Local, 1 - AWS S3)."
description: The type of the storage provider
type: object
required:
- path
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
require (
github.com/aerospike/aerospike-client-go/v7 v7.6.0
github.com/aerospike/aerospike-management-lib v1.4.0
github.com/aerospike/backup-go v0.0.0-20240723084926-1ebd1eeb6271
github.com/aerospike/backup-go v0.0.0-20240725064655-47f776116683
github.com/aws/aws-sdk-go-v2 v1.30.3
github.com/aws/aws-sdk-go-v2/config v1.27.27
github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ github.com/aerospike/backup-go v0.0.0-20240723065039-ba1dcdae8a73 h1:Yi9rYp369Ol
github.com/aerospike/backup-go v0.0.0-20240723065039-ba1dcdae8a73/go.mod h1:WfFo03sY4w5qu3IALjqNQaPZVe+0p7GqYPG+qifkm+8=
github.com/aerospike/backup-go v0.0.0-20240723084926-1ebd1eeb6271 h1:wLmVSBoSUJGc2+tWn4hLuI/MLTz8OaVXEUq+1opnQSM=
github.com/aerospike/backup-go v0.0.0-20240723084926-1ebd1eeb6271/go.mod h1:WfFo03sY4w5qu3IALjqNQaPZVe+0p7GqYPG+qifkm+8=
github.com/aerospike/backup-go v0.0.0-20240725064337-443a87106769 h1:ogbW0yY0dAqTW+JI+Yk4KGDLHOdEUQTcRz7kS5BCsnY=
github.com/aerospike/backup-go v0.0.0-20240725064337-443a87106769/go.mod h1:WfFo03sY4w5qu3IALjqNQaPZVe+0p7GqYPG+qifkm+8=
github.com/aerospike/backup-go v0.0.0-20240725064655-47f776116683 h1:hSzvcVnw7oMPeQQ7lIjxJRiCVcQGD0WBNULID9wpJ9c=
github.com/aerospike/backup-go v0.0.0-20240725064655-47f776116683/go.mod h1:WfFo03sY4w5qu3IALjqNQaPZVe+0p7GqYPG+qifkm+8=
github.com/aws/aws-sdk-go-v2 v1.26.1 h1:5554eUqIYVWpU0YmeeYZ0wU64H2VLBs8TlhRB2L+EkA=
github.com/aws/aws-sdk-go-v2 v1.26.1/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM=
github.com/aws/aws-sdk-go-v2 v1.27.0 h1:7bZWKoXhzI+mMR/HjdMx8ZCC5+6fY0lS5tr0bbgiLlo=
Expand Down
Loading
Loading