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 @@ -7,6 +7,7 @@
- (Bugfix) (DP) Propagate Timeout Across Subcommands
- (Maintenance) Bump Dependencies
- (Feature) (Platform) EventsV1 Integration
- (Feature) (Platform) Allows to opt out in the Inventory Telemetry

## [1.3.1](https://github.com/arangodb/kube-arangodb/tree/1.3.1) (2025-10-07)
- (Documentation) Add ArangoPlatformStorage Docs & Examples
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/arangodb_operator_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Flags:
--arango.insecure Arango Endpoint Insecure
--arango.token string Arango JWT Token for Authentication
-h, --help help for inventory
--telemetry Enables Telemetry (default true)

Global Flags:
--kubeconfig string Kubernetes Config File
Expand Down Expand Up @@ -165,6 +166,7 @@ Flags:
--license.client.stage strings LicenseManager Stages (default [prd])
--license.endpoint string LicenseManager Endpoint (default "license.arango.ai")
--license.interval duration Interval of the license synchronization
--telemetry Enables Telemetry (default true)

Global Flags:
--kubeconfig string Kubernetes Config File
Expand Down
6 changes: 6 additions & 0 deletions pkg/platform/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ var (
},
}

flagTelemetry = cli.Flag[bool]{
Name: "telemetry",
Description: "Enables Telemetry",
Default: true,
}

flagRegistryUseCredentials = cli.Flag[bool]{
Name: "registry.docker.credentials",
Description: "Use Docker Credentials",
Expand Down
20 changes: 18 additions & 2 deletions pkg/platform/inventory/aql.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,25 @@ import (
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 {
func ExecuteTelemetryAQL(db string, aql string, bind map[string]any) Executor {
return ExecuteAQL(db, aql, bind, true)
}

func ExecuteBasicAQL(db string, aql string, bind map[string]any) Executor {
return ExecuteAQL(db, aql, bind, false)
}

func ExecuteAQL(db string, aql string, bind map[string]any, telemetry bool) Executor {
return func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
if telemetry {
if !cfg.WithTelemetry() {
log.Info("Telemetry disabled")
return nil
}
log.Info("Collecting Telemetry details")
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message 'Collecting Telemetry details' is misleading because it's shown for all AQL queries, not just telemetry-related ones. When telemetry=false (for basic AQL queries), this message still appears. Consider moving the logging inside the conditional branches or making the message more accurate, e.g., 'Executing AQL query' for non-telemetry queries.

Suggested change
log.Info("Collecting Telemetry details")
if telemetry {
log.Info("Collecting Telemetry details")
} else {
log.Info("Executing AQL query")
}

Copilot uses AI. Check for mistakes.
}

c, err := driver.NewClient(driver.ClientConfig{Connection: async.NewConnectionAsyncWrapper(conn)})
if err != nil {
return err
Expand Down
32 changes: 32 additions & 0 deletions pkg/platform/inventory/configuration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// 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

type Configuration struct {
Telemetry *bool
}

func (c *Configuration) WithTelemetry() bool {
if c == nil || c.Telemetry == nil {
return true
}
return *c.Telemetry
}
Comment on lines +27 to +32
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WithTelemetry method lacks a docstring explaining that it returns true by default when configuration is nil or telemetry is unset. This default behavior is important for understanding the opt-out nature of the feature and should be documented.

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion pkg/platform/inventory/fetcher.aql.timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ import _ "embed"
var queryTimestampAQL string

func init() {
global.MustRegister("aql.timestamp", ExecuteAQL("_system", queryTimestampAQL, nil))
global.MustRegister("aql.timestamp", ExecuteBasicAQL("_system", queryTimestampAQL, nil))
}
2 changes: 1 addition & 1 deletion pkg/platform/inventory/fetcher.deployment.id.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
)

func init() {
global.MustRegister("deployment.id", func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
global.MustRegister("deployment.id", func(conn driver.Connection, cfg *Configuration, 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()
Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/inventory/fetcher.server.mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

func init() {
global.MustRegister("server.mode", func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
global.MustRegister("server.mode", func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
resp := arangod.GetRequestWithTimeout[driver.ClusterHealth](ctx, globals.GetGlobals().Timeouts().ArangoD().Get(), conn, "_admin", "cluster", "health")

Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/inventory/fetcher.server.version.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

func init() {
global.MustRegister("server.info", func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
global.MustRegister("server.info", func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
resp, err := arangod.GetRequestWithTimeout[driver.VersionInfo](ctx, globals.GetGlobals().Timeouts().ArangoD().Get(), conn, "_api", "version").
AcceptCode(goHttp.StatusOK).
Expand Down
10 changes: 5 additions & 5 deletions pkg/platform/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

type Items []*Item

func FetchInventory(ctx context.Context, logger logging.Logger, threads int, conn driver.Connection) (Items, error) {
func FetchInventory(ctx context.Context, logger logging.Logger, threads int, conn driver.Connection, cfg *Configuration) (Items, error) {
var out []*Item
done := make(chan struct{})
in := make(chan *Item)
Expand All @@ -50,7 +50,7 @@ func FetchInventory(ctx context.Context, logger logging.Logger, threads int, con
}
}()

if err := executor.Run(ctx, logger, threads, runExecution(conn, in)); err != nil {
if err := executor.Run(ctx, logger, threads, runExecution(conn, cfg, in)); err != nil {
return nil, err
}

Expand All @@ -61,11 +61,11 @@ func FetchInventory(ctx context.Context, logger logging.Logger, threads int, con
return out, nil
}

func runExecution(conn driver.Connection, out chan<- *Item) executor.RunFunc {
func runExecution(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
for _, executor := range global.Items() {
log.Str("name", executor.K).Info("Starting executor")
q := executor.V(conn, out)
q := executor.V(conn, cfg, out)

h.RunAsync(ctx, q)
}
Expand All @@ -76,7 +76,7 @@ func runExecution(conn driver.Connection, out chan<- *Item) executor.RunFunc {
}
}

type Executor func(conn driver.Connection, out chan<- *Item) executor.RunFunc
type Executor func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc

func (i *Item) Validate() error {
if i == nil {
Expand Down
8 changes: 7 additions & 1 deletion pkg/platform/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ func buildInventory(cmd *cobra.Command) (*inventory.Spec, error) {
return nil, err
}

var cfg inventory.Configuration

if v, err := flagTelemetry.Get(cmd); err != nil || !v {
cfg.Telemetry = util.NewType(false)
}
Comment on lines +78 to +80
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for setting cfg.Telemetry is inverted and unclear. When telemetry is enabled (v == true), the field remains nil, but when disabled (!v) or on error, it's explicitly set to false. This makes the nil state ambiguous. Consider always setting the value explicitly: cfg.Telemetry = util.NewType(v) when no error occurs, or handle the error case separately.

Suggested change
if v, err := flagTelemetry.Get(cmd); err != nil || !v {
cfg.Telemetry = util.NewType(false)
}
v, err := flagTelemetry.Get(cmd)
if err != nil {
return nil, err
}
cfg.Telemetry = util.NewType(v)

Copilot uses AI. Check for mistakes.

logger.Info("Discovered Arango %s (%s)", resp.Version, resp.License)

obj, err := inventory.FetchInventory(cmd.Context(), logger, 8, conn)
obj, err := inventory.FetchInventory(cmd.Context(), logger, 8, conn, &cfg)

if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/license_activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func licenseActivate() (*cobra.Command, error) {
cmd.Use = "activate"
cmd.Short = "Activates the License on ArangoDB Endpoint"

if err := cli.RegisterFlags(&cmd, flagLicenseManager, flagActivateInterval, flagDeployment); err != nil {
if err := cli.RegisterFlags(&cmd, flagLicenseManager, flagActivateInterval, flagDeployment, flagTelemetry); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/license_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func licenseInventory() (*cobra.Command, error) {
cmd.Use = "inventory [flags] output"
cmd.Short = "Inventory Generator"

if err := cli.RegisterFlags(&cmd, flagDeployment); err != nil {
if err := cli.RegisterFlags(&cmd, flagDeployment, flagTelemetry); err != nil {
return nil, err
}

Expand Down
Loading