From 3e846a9dce8e6bec1ced864f5562cae93f057d34 Mon Sep 17 00:00:00 2001 From: Nikita Vaniasin Date: Thu, 19 Oct 2023 11:11:23 +0200 Subject: [PATCH] [Feature] Add spec.upgrade.debugLog option to configure upgrade container logging - GT-356 (#1442) --- CHANGELOG.md | 1 + docs/api/ArangoDeployment.V1.md | 15 +++++++-- .../deployment/v1/deployment_upgrade_spec.go | 9 ++++-- .../deployment/v2alpha1/deployment_spec.go | 2 +- .../v2alpha1/deployment_upgrade_spec.go | 9 ++++-- pkg/deployment/pod/upgrade.go | 31 ++++++++++++++++++- .../resources/pod_creator_arangod.go | 5 ++- 7 files changed, 63 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1a06d5a4..4468d104f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - (Maintenance) Update go-driver to v1.6.0, update IsNotFound() checks - (Improvement) Print assigned node name to log and condition message when pod is scheduled - (Maintenance) Remove obsolete docs, restructure for better UX, generate index files +- (Feature) Add `spec.upgrade.debugLog` option to configure upgrade container logging ## [1.2.34](https://github.com/arangodb/kube-arangodb/tree/1.2.34) (2023-10-16) - (Bugfix) Fix make manifests-crd-file command diff --git a/docs/api/ArangoDeployment.V1.md b/docs/api/ArangoDeployment.V1.md index 4bf44623d..44ff0a177 100644 --- a/docs/api/ArangoDeployment.V1.md +++ b/docs/api/ArangoDeployment.V1.md @@ -4074,7 +4074,18 @@ Must be in format accepted by "tzdata", e.g. `America/New_York` or `Europe/Londo ### .spec.upgrade.autoUpgrade: bool -Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck) +AutoUpgrade flag specifies if upgrade should be auto-injected, even if is not required (in case of stuck) -[Code Reference](/pkg/apis/deployment/v1/deployment_upgrade_spec.go#L25) +Default Value: false + +[Code Reference](/pkg/apis/deployment/v1/deployment_upgrade_spec.go#L26) + +### .spec.upgrade.debugLog: bool + +DebugLog flag specifies if containers running upgrade process should print more debugging information. +This applies only to init containers. + +Default Value: false + +[Code Reference](/pkg/apis/deployment/v1/deployment_upgrade_spec.go#L30) diff --git a/pkg/apis/deployment/v1/deployment_upgrade_spec.go b/pkg/apis/deployment/v1/deployment_upgrade_spec.go index 53d407667..65a511f25 100644 --- a/pkg/apis/deployment/v1/deployment_upgrade_spec.go +++ b/pkg/apis/deployment/v1/deployment_upgrade_spec.go @@ -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. @@ -21,8 +21,13 @@ package v1 type DeploymentUpgradeSpec struct { - // Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck) + // AutoUpgrade flag specifies if upgrade should be auto-injected, even if is not required (in case of stuck) + // +doc/default: false AutoUpgrade bool `json:"autoUpgrade"` + // DebugLog flag specifies if containers running upgrade process should print more debugging information. + // This applies only to init containers. + // +doc/default: false + DebugLog bool `json:"debugLog"` } func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec { diff --git a/pkg/apis/deployment/v2alpha1/deployment_spec.go b/pkg/apis/deployment/v2alpha1/deployment_spec.go index 8f6893195..2484cca47 100644 --- a/pkg/apis/deployment/v2alpha1/deployment_spec.go +++ b/pkg/apis/deployment/v2alpha1/deployment_spec.go @@ -252,7 +252,7 @@ type DeploymentSpec struct { // Architecture defines the list of supported architectures. // First element on the list is marked as default architecture. - // +doc/link: Architecture Change|/docs/design/arch_change.md + // +doc/link: Architecture Change|/docs/how-to/arch_change.md // +doc/type: []string // +doc/default: ['amd64'] Architecture ArangoDeploymentArchitecture `json:"architecture,omitempty"` diff --git a/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go b/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go index 85465986d..616275012 100644 --- a/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go +++ b/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go @@ -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. @@ -21,8 +21,13 @@ package v2alpha1 type DeploymentUpgradeSpec struct { - // Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck) + // AutoUpgrade flag specifies if upgrade should be auto-injected, even if is not required (in case of stuck) + // +doc/default: false AutoUpgrade bool `json:"autoUpgrade"` + // DebugLog flag specifies if containers running upgrade process should print more debugging information. + // This applies only to init containers. + // +doc/default: false + DebugLog bool `json:"debugLog"` } func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec { diff --git a/pkg/deployment/pod/upgrade.go b/pkg/deployment/pod/upgrade.go index 6ec08a808..d8359a996 100644 --- a/pkg/deployment/pod/upgrade.go +++ b/pkg/deployment/pod/upgrade.go @@ -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. @@ -57,3 +57,32 @@ func (u autoUpgrade) Args(i Input) k8sutil.OptionPairs { return k8sutil.NewOptionPair(k8sutil.OptionPair{Key: "--database.auto-upgrade", Value: "true"}) } + +func UpgradeDebug() Builder { + return upgradeDebug{} +} + +type upgradeDebug struct{} + +func (u upgradeDebug) Envs(i Input) []core.EnvVar { + return nil +} + +func (u upgradeDebug) Verify(i Input, cachedStatus interfaces.Inspector) error { + return nil +} + +func (u upgradeDebug) Volumes(i Input) ([]core.Volume, []core.VolumeMount) { + return nil, nil +} + +func (u upgradeDebug) Args(i Input) k8sutil.OptionPairs { + pairs := k8sutil.NewOptionPair() + if i.Deployment.Upgrade.Get().DebugLog { + pairs = append(pairs, k8sutil.OptionPair{ + Key: "--log.level", + Value: "all=debug", + }) + } + return pairs +} diff --git a/pkg/deployment/resources/pod_creator_arangod.go b/pkg/deployment/resources/pod_creator_arangod.go index 111ad1b32..b8d3cd604 100644 --- a/pkg/deployment/resources/pod_creator_arangod.go +++ b/pkg/deployment/resources/pod_creator_arangod.go @@ -662,7 +662,10 @@ func (a *ArangoUpgradeContainer) GetCommand() ([]string, error) { return nil, err } - upgradeArgs := pod.AutoUpgrade().Args(a.input).Sort().AsArgs() + upgradeArgs := append( + pod.AutoUpgrade().Args(a.input).Sort().AsArgs(), + pod.UpgradeDebug().Args(a.input).Sort().AsArgs()..., + ) return append(args, upgradeArgs...), nil }