Skip to content

[Feature] Compact Action #1936

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

Merged
merged 2 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- (Feature) (Platform) ECS Storage
- (Bugfix) (Platform) Prevent NPE in case of missing Helm Release
- (Bugfix) Align JWT Discovery
- (Feature) Compact Action

## [1.2.50](https://github.com/arangodb/kube-arangodb/tree/1.2.50) (2025-07-04)
- (Feature) (Platform) MetaV1 Integration Service
Expand Down
2 changes: 2 additions & 0 deletions docs/generated/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ nav_order: 11
| CleanTLSCACertificate | no | 30m0s | no | Enterprise Only | Remove Certificate from CA TrustStore |
| CleanTLSKeyfileCertificate | no | 30m0s | no | Enterprise Only | Remove old TLS certificate from server |
| ClusterMemberCleanup | no | 10m0s | no | Community & Enterprise | Remove member from Cluster if it is gone already (Coordinators) |
| CompactMember | no | 8h0m0s | no | Community & Enterprise | Runs the Compact API on the Member |
| Delay | no | 10m0s | yes | Community & Enterprise | Define delay operation |
| ~~DisableClusterScaling~~ | no | 10m0s | no | Community & Enterprise | Disable Cluster Scaling integration |
| DisableMaintenance | no | 10m0s | no | Community & Enterprise | Disable ArangoDB maintenance mode |
Expand Down Expand Up @@ -123,6 +124,7 @@ spec:
CleanTLSCACertificate: 30m0s
CleanTLSKeyfileCertificate: 30m0s
ClusterMemberCleanup: 10m0s
CompactMember: 8h0m0s
Delay: 10m0s
DisableClusterScaling: 10m0s
DisableMaintenance: 10m0s
Expand Down
5 changes: 5 additions & 0 deletions internal/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ actions:
RecreateMember:
description: Recreate member with same ID and Data
timeout: 15m
CompactMember:
description: Runs the Compact API on the Member
timeout: 8h
scopes:
- Normal
CleanOutMember:
description: Run the CleanOut job on member
timeout: 48h
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/deployment/v1/actions.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/apis/deployment/v2alpha1/actions.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/deployment/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type Client interface {
RefreshJWT(ctx context.Context) (JWTDetails, error)

DeleteExpiredJobs(ctx context.Context, timeout time.Duration) error

Compact(ctx context.Context, request *CompactRequest) error
}

type client struct {
Expand Down
60 changes: 60 additions & 0 deletions pkg/deployment/client/compact.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// DISCLAIMER
//
// Copyright 2025 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package client

import (
"context"
goHttp "net/http"
)

type CompactRequest struct {
CompactBottomMostLevel *bool `json:"compactBottomMostLevel,omitempty"`
ChangeLevel *bool `json:"changeLevel,omitempty"`
}

const CompactUrl = "/_admin/compact"

func (c *client) Compact(ctx context.Context, request *CompactRequest) error {
req, err := c.c.NewRequest(goHttp.MethodPut, CompactUrl)
if err != nil {
return err
}

if request == nil {
request = new(CompactRequest)
}

req, err = req.SetBody(request)
if err != nil {
return err
}

resp, err := c.c.Do(ctx, req)
if err != nil {
return err
}

if err := resp.CheckStatus(goHttp.StatusOK); err != nil {
return err
}

return nil
}
4 changes: 3 additions & 1 deletion pkg/deployment/reconcile/action.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2025 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.
Expand Down Expand Up @@ -34,6 +34,8 @@ import (

const (
DefaultStartFailureGracePeriod = 10 * time.Second

LocalJobID api.PlanLocalKey = "jobID"
)

func GetAllActions() []api.ActionType {
Expand Down
17 changes: 17 additions & 0 deletions pkg/deployment/reconcile/action.register.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/deployment/reconcile/action.register.generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ func Test_Actions(t *testing.T) {
})
})

t.Run("CompactMember", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeCompactMember)
t.Run("Internal", func(t *testing.T) {
require.False(t, api.ActionTypeCompactMember.Internal())
})
t.Run("Optional", func(t *testing.T) {
require.False(t, api.ActionTypeCompactMember.Optional())
})
})

t.Run("Delay", func(t *testing.T) {
ActionsExistence(t, api.ActionTypeDelay)
t.Run("Internal", func(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions pkg/deployment/reconcile/action_backup_restore.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2025 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.
Expand Down Expand Up @@ -34,7 +34,6 @@ import (
)

const (
actionBackupRestoreLocalJobID api.PlanLocalKey = "jobID"
actionBackupRestoreLocalBackupName api.PlanLocalKey = "backupName"
)

Expand Down Expand Up @@ -114,7 +113,7 @@ func (a actionBackupRestore) restoreAsync(ctx context.Context, backup *backupApi

if err := dbc.Backup().Restore(ctxChild, driver.BackupID(backup.Status.Backup.ID), nil); err != nil {
if id, ok := conn.IsAsyncJobInProgress(err); ok {
a.actionCtx.Add(actionBackupRestoreLocalJobID, id, true)
a.actionCtx.Add(LocalJobID, id, true)
a.actionCtx.Add(actionBackupRestoreLocalBackupName, backup.GetName(), true)

// Async request has been sent
Expand Down Expand Up @@ -169,9 +168,9 @@ func (a actionBackupRestore) CheckProgress(ctx context.Context) (bool, bool, err
return false, false, errors.Errorf("Local Key is missing in action: %s", actionBackupRestoreLocalBackupName)
}

job, ok := a.actionCtx.Get(a.action, actionBackupRestoreLocalJobID)
job, ok := a.actionCtx.Get(a.action, LocalJobID)
if !ok {
return false, false, errors.Errorf("Local Key is missing in action: %s", actionBackupRestoreLocalJobID)
return false, false, errors.Errorf("Local Key is missing in action: %s", LocalJobID)
}

ctxChild, cancel := globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)
Expand Down
Loading