From 1d274abdbd4128ab3140b7dddb2bae4e4b917dd1 Mon Sep 17 00:00:00 2001 From: Nikita Vaniasin Date: Mon, 16 Oct 2023 09:36:54 +0200 Subject: [PATCH 1/6] Add `spec.upgrade.debugLog` option to configure upgrade container logging --- CHANGELOG.md | 1 + .../deployment/v1/deployment_upgrade_spec.go | 7 +++-- pkg/deployment/pod/upgrade.go | 29 +++++++++++++++++++ .../resources/pod_creator_arangod.go | 5 +++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6532d0f2..79456d4e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - (Maintenance) Make scale_down_candidate annotation obsolete - (Bugfix) Fix ResignJob ID propagation - (Bugfix) Allow shards with RF1 in EnforcedResignLeadership action +- (Feature) Add `spec.upgrade.debugLog` option to configure upgrade container logging ## [1.2.33](https://github.com/arangodb/kube-arangodb/tree/1.2.33) (2023-09-27) - (Maintenance) Bump golang.org/x/net to v0.13.0 diff --git a/pkg/apis/deployment/v1/deployment_upgrade_spec.go b/pkg/apis/deployment/v1/deployment_upgrade_spec.go index 53d407667..fb3c20e7f 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,11 @@ 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) AutoUpgrade bool `json:"autoUpgrade"` + // DebugLog flag specifies if containers running upgrade process should print more debugging information. + // This applies only to init containers. + 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..bc3d10d15 100644 --- a/pkg/deployment/pod/upgrade.go +++ b/pkg/deployment/pod/upgrade.go @@ -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().AutoUpgrade { + 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 } From 02ddb6524cfd9ee181bc728d86b83d8342dd5399 Mon Sep 17 00:00:00 2001 From: Nikita Vaniasin Date: Mon, 16 Oct 2023 09:43:07 +0200 Subject: [PATCH 2/6] Sync v2 --- pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go b/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go index 85465986d..32400e152 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,11 @@ 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) AutoUpgrade bool `json:"autoUpgrade"` + // DebugLog flag specifies if containers running upgrade process should print more debugging information. + // This applies only to init containers. + DebugLog bool `json:"debugLog"` } func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec { From 22b53d9a4ede99b1273c1c15b387292c69c4ad52 Mon Sep 17 00:00:00 2001 From: Nikita Vaniasin Date: Mon, 16 Oct 2023 11:53:58 +0200 Subject: [PATCH 3/6] Fix --- pkg/deployment/pod/upgrade.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/deployment/pod/upgrade.go b/pkg/deployment/pod/upgrade.go index bc3d10d15..9bdeb49db 100644 --- a/pkg/deployment/pod/upgrade.go +++ b/pkg/deployment/pod/upgrade.go @@ -78,7 +78,7 @@ func (u upgradeDebug) Volumes(i Input) ([]core.Volume, []core.VolumeMount) { func (u upgradeDebug) Args(i Input) k8sutil.OptionPairs { pairs := k8sutil.NewOptionPair() - if i.Deployment.Upgrade.Get().AutoUpgrade { + if i.Deployment.Upgrade.Get().DebugLog { pairs = append(pairs, k8sutil.OptionPair{ Key: "--log.level", Value: "all=debug", From cad964825beb3744f9979e182ff8ee0164bba150 Mon Sep 17 00:00:00 2001 From: Nikita Vaniasin Date: Wed, 18 Oct 2023 08:42:19 +0200 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c63ec914a..e73741668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A) - (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 +- (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 @@ -18,7 +19,6 @@ - (Maintenance) Make scale_down_candidate annotation obsolete - (Bugfix) Fix ResignJob ID propagation - (Bugfix) Allow shards with RF1 in EnforcedResignLeadership action -- (Feature) Add `spec.upgrade.debugLog` option to configure upgrade container logging ## [1.2.33](https://github.com/arangodb/kube-arangodb/tree/1.2.33) (2023-09-27) - (Maintenance) Bump golang.org/x/net to v0.13.0 From ff35146333d4fa2642315330d010b412f6d5929b Mon Sep 17 00:00:00 2001 From: Nikita Vaniasin Date: Thu, 19 Oct 2023 10:34:24 +0200 Subject: [PATCH 5/6] Fix license header --- pkg/deployment/pod/upgrade.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/deployment/pod/upgrade.go b/pkg/deployment/pod/upgrade.go index 9bdeb49db..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. From a21a50cf55b2df88506883f4b3f5fc95c9b7468d Mon Sep 17 00:00:00 2001 From: Nikita Vaniasin Date: Thu, 19 Oct 2023 10:39:27 +0200 Subject: [PATCH 6/6] Update docs for new field --- docs/api/ArangoDeployment.V1.md | 15 +++++++++++++-- pkg/apis/deployment/v1/deployment_upgrade_spec.go | 2 ++ pkg/apis/deployment/v2alpha1/deployment_spec.go | 2 +- .../v2alpha1/deployment_upgrade_spec.go | 2 ++ 4 files changed, 18 insertions(+), 3 deletions(-) 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 fb3c20e7f..65a511f25 100644 --- a/pkg/apis/deployment/v1/deployment_upgrade_spec.go +++ b/pkg/apis/deployment/v1/deployment_upgrade_spec.go @@ -22,9 +22,11 @@ package v1 type DeploymentUpgradeSpec struct { // 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"` } 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 32400e152..616275012 100644 --- a/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go +++ b/pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go @@ -22,9 +22,11 @@ package v2alpha1 type DeploymentUpgradeSpec struct { // 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"` }