Skip to content
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 @@ -2,6 +2,7 @@

## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- (Bugfix) (Platform) Increase memory limit for Inventory
- (Feature) (LM) Inventory Generator

## [1.3.1](https://github.com/arangodb/kube-arangodb/tree/1.3.1) (2025-10-07)
- (Documentation) Add ArangoPlatformStorage Docs & Examples
Expand Down
68 changes: 68 additions & 0 deletions docs/cli/arangodb_operator_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ parent: Binaries
title: arangodb_operator_platform
---

# ArangoDB Operator Platform Command

[START_INJECT]: # (arangodb_operator_platform_cmd)
```
Usage:
arangodb_operator_platform [command]

Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
license License Package related operations
package Release Package related operations

Flags:
-h, --help help for arangodb_operator_platform
--kubeconfig string Kubernetes Config File
-n, --namespace string Kubernetes Namespace (default "default")

Use "arangodb_operator_platform [command] --help" for more information about a command.
```
[END_INJECT]: # (arangodb_operator_platform_cmd)

# ArangoDB Operator Platform Package Command

[START_INJECT]: # (arangodb_operator_platform_package_cmd)
Expand Down Expand Up @@ -70,3 +92,49 @@ Global Flags:
```
[END_INJECT]: # (arangodb_operator_platform_package_install_cmd)

# ArangoDB Operator Platform License Command

[START_INJECT]: # (arangodb_operator_platform_license_cmd)
```
License Package related operations

Usage:
arangodb_operator_platform license [command]

Available Commands:
inventory Inventory Generator

Flags:
-h, --help help for license

Global Flags:
--kubeconfig string Kubernetes Config File
-n, --namespace string Kubernetes Namespace (default "default")

Use "arangodb_operator_platform license [command] --help" for more information about a command.
```
[END_INJECT]: # (arangodb_operator_platform_license_cmd)

# ArangoDB Operator Platform License Inventory Command

[START_INJECT]: # (arangodb_operator_platform_license_inventory_cmd)
```
Inventory Generator

Usage:
arangodb_operator_platform license inventory [flags] output

Flags:
--arango.authentication string Arango Endpoint Auth Method. One of: Disabled, Basic, Token (default "Disabled")
--arango.basic.password string Arango Password for Basic Authentication
--arango.basic.username string Arango Username for Basic Authentication
--arango.endpoint strings Arango Endpoint
--arango.insecure Arango Endpoint Insecure
--arango.token string Arango JWT Token for Authentication
-h, --help help for inventory

Global Flags:
--kubeconfig string Kubernetes Config File
-n, --namespace string Kubernetes Namespace (default "default")
```
[END_INJECT]: # (arangodb_operator_platform_license_inventory_cmd)
12 changes: 12 additions & 0 deletions internal/readme_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ func GenerateCLIArangoDBOperatorPlatformReadme(root string) error {
readmeSections["arangodb_operator_platform_package_install_cmd"] = section
}

if section, err := GenerateHelpQuoted(cmd, "license"); err != nil {
return err
} else {
readmeSections["arangodb_operator_platform_license_cmd"] = section
}

if section, err := GenerateHelpQuoted(cmd, "license", "inventory"); err != nil {
return err
} else {
readmeSections["arangodb_operator_platform_license_inventory_cmd"] = section
}

if err := pretty.ReplaceSectionsInFile(path.Join(root, "docs", "cli", "arangodb_operator_platform.md"), readmeSections); err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/shared/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ func ValidateRequiredNotEmptyPath[T any](path string, in *T) error {
return PrefixResourceError(path, ValidateRequiredNotEmpty(in))
}

// ValidatePath Validates object
func ValidatePath[T any](path string, in T, validator func(T) error) error {
return PrefixResourceErrors(path, validator(in))
}

// ValidateRequiredPath Validates object and required not nil value
func ValidateRequiredPath[T any](path string, in *T, validator func(T) error) error {
return PrefixResourceErrors(path, ValidateRequired(in, validator))
Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type Client interface {
Compact(ctx context.Context, request *CompactRequest) error

Inventory(ctx context.Context) (*Inventory, error)

DeploymentID(ctx context.Context) (DeploymentID, error)
}

type client struct {
Expand Down
35 changes: 35 additions & 0 deletions pkg/deployment/client/id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// 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"

"github.com/arangodb/kube-arangodb/pkg/util/arangod"
)

type DeploymentID struct {
Id string `json:"id"`
}

func (c *client) DeploymentID(ctx context.Context) (DeploymentID, error) {
return arangod.GetRequest[DeploymentID](ctx, c.c, "_admin", "deployment", "id").AcceptCode(200).Response()
}
2 changes: 2 additions & 0 deletions pkg/platform/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ var (
},
}

flagDeployment = cli.NewDeployment("arango")

flagValues = cli.Flag[[]string]{
Name: "values",
Short: "f",
Expand Down
1 change: 1 addition & 0 deletions pkg/platform/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func installer() (*cobra.Command, error) {

if err := withRegisterCommand(&cmd,
pkg,
license,
); err != nil {
return nil, err
}
Expand Down
103 changes: 103 additions & 0 deletions pkg/platform/inventory/aql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// 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 inventory

import (
"context"
"time"

"github.com/arangodb/go-driver"
"github.com/arangodb/go-driver/util/connection/wrappers/async"

"github.com/arangodb/kube-arangodb/pkg/logging"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/executor"
ugrpc "github.com/arangodb/kube-arangodb/pkg/util/grpc"
)

func ExecuteAQL(db string, aql string, bind map[string]any) Executor {
return func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
c, err := driver.NewClient(driver.ClientConfig{Connection: async.NewConnectionAsyncWrapper(conn)})
if err != nil {
return err
}

d, err := c.Database(ctx, db)
if err != nil {
return err
}

nctx := driver.WithAsync(ctx)

_, err = d.Query(nctx, aql, bind)
if err == nil {
return errors.Errorf("Async execution of the query should be prepared")
}

jobId, ok := async.IsAsyncJobInProgress(err)
if !ok {
return errors.Wrapf(err, "Async execution of the query should be prepared")
}

var cursor driver.Cursor

for {
zctx := driver.WithAsyncID(ctx, jobId)

query, err := d.Query(zctx, aql, bind)
if err != nil {
_, ok := async.IsAsyncJobInProgress(err)
if !ok {
return errors.Wrapf(err, "Async execution of the query should be prepared")
}

t.Wait(125 * time.Millisecond)

continue
}

cursor = query
break
}

for {
var ret ugrpc.Object[*Item]

if _, err := cursor.ReadDocument(ctx, &ret); err != nil {
if driver.IsNoMoreDocuments(err) {
break
}

return err
}

if err := ret.Object.Validate(); err != nil {
return err
}

out <- ret.Object
}

return nil
}
}
}
30 changes: 30 additions & 0 deletions pkg/platform/inventory/fetcher.aql.timestamp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// 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 inventory

import _ "embed"

//go:embed queries/timestamp.aql
var queryTimestampAQL string

func init() {
global.MustRegister("aql.timestamp", ExecuteAQL("_system", queryTimestampAQL, nil))
}
65 changes: 65 additions & 0 deletions pkg/platform/inventory/fetcher.deployment.id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// 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 inventory

import (
"context"
goHttp "net/http"

"github.com/arangodb/go-driver"

"github.com/arangodb/kube-arangodb/pkg/deployment/client"
"github.com/arangodb/kube-arangodb/pkg/logging"
"github.com/arangodb/kube-arangodb/pkg/util/arangod"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/executor"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
)

func init() {
global.MustRegister("deployment.id", func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
if handler := arangod.GetRequestWithTimeout[client.DeploymentID](ctx, globals.GetGlobals().Timeouts().ArangoD().Get(), conn, "_admin", "deployment", "id"); handler.Code() == goHttp.StatusOK {
resp, err := handler.Response()
if err != nil {
return err
}

return errors.Errors(
Produce(out, "ARANGO_DEPLOYMENT", map[string]string{
"detail": "id",
}, resp.Id),
)
}

log.Warn("Fallback to the ClusterHealth Endpoint")

health, err := arangod.GetRequestWithTimeout[driver.ClusterHealth](ctx, globals.GetGlobals().Timeouts().ArangoD().Get(), conn, "_admin", "cluster", "health").AcceptCode(goHttp.StatusOK).Response()
if err != nil {
return err
}

return errors.Errors(
Produce(out, "ARANGO_DEPLOYMENT_ID", nil, health.ID),
)
}
})
}
Loading