Skip to content

Commit 3e846a9

Browse files
[Feature] Add spec.upgrade.debugLog option to configure upgrade container logging - GT-356 (#1442)
1 parent 6f6fcb8 commit 3e846a9

File tree

7 files changed

+63
-9
lines changed

7 files changed

+63
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- (Maintenance) Update go-driver to v1.6.0, update IsNotFound() checks
55
- (Improvement) Print assigned node name to log and condition message when pod is scheduled
66
- (Maintenance) Remove obsolete docs, restructure for better UX, generate index files
7+
- (Feature) Add `spec.upgrade.debugLog` option to configure upgrade container logging
78

89
## [1.2.34](https://github.com/arangodb/kube-arangodb/tree/1.2.34) (2023-10-16)
910
- (Bugfix) Fix make manifests-crd-file command

docs/api/ArangoDeployment.V1.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4074,7 +4074,18 @@ Must be in format accepted by "tzdata", e.g. `America/New_York` or `Europe/Londo
40744074

40754075
### .spec.upgrade.autoUpgrade: bool
40764076

4077-
Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck)
4077+
AutoUpgrade flag specifies if upgrade should be auto-injected, even if is not required (in case of stuck)
40784078

4079-
[Code Reference](/pkg/apis/deployment/v1/deployment_upgrade_spec.go#L25)
4079+
Default Value: false
4080+
4081+
[Code Reference](/pkg/apis/deployment/v1/deployment_upgrade_spec.go#L26)
4082+
4083+
### .spec.upgrade.debugLog: bool
4084+
4085+
DebugLog flag specifies if containers running upgrade process should print more debugging information.
4086+
This applies only to init containers.
4087+
4088+
Default Value: false
4089+
4090+
[Code Reference](/pkg/apis/deployment/v1/deployment_upgrade_spec.go#L30)
40804091

pkg/apis/deployment/v1/deployment_upgrade_spec.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,8 +21,13 @@
2121
package v1
2222

2323
type DeploymentUpgradeSpec struct {
24-
// Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck)
24+
// AutoUpgrade flag specifies if upgrade should be auto-injected, even if is not required (in case of stuck)
25+
// +doc/default: false
2526
AutoUpgrade bool `json:"autoUpgrade"`
27+
// DebugLog flag specifies if containers running upgrade process should print more debugging information.
28+
// This applies only to init containers.
29+
// +doc/default: false
30+
DebugLog bool `json:"debugLog"`
2631
}
2732

2833
func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {

pkg/apis/deployment/v2alpha1/deployment_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ type DeploymentSpec struct {
252252

253253
// Architecture defines the list of supported architectures.
254254
// First element on the list is marked as default architecture.
255-
// +doc/link: Architecture Change|/docs/design/arch_change.md
255+
// +doc/link: Architecture Change|/docs/how-to/arch_change.md
256256
// +doc/type: []string
257257
// +doc/default: ['amd64']
258258
Architecture ArangoDeploymentArchitecture `json:"architecture,omitempty"`

pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,8 +21,13 @@
2121
package v2alpha1
2222

2323
type DeploymentUpgradeSpec struct {
24-
// Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck)
24+
// AutoUpgrade flag specifies if upgrade should be auto-injected, even if is not required (in case of stuck)
25+
// +doc/default: false
2526
AutoUpgrade bool `json:"autoUpgrade"`
27+
// DebugLog flag specifies if containers running upgrade process should print more debugging information.
28+
// This applies only to init containers.
29+
// +doc/default: false
30+
DebugLog bool `json:"debugLog"`
2631
}
2732

2833
func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {

pkg/deployment/pod/upgrade.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -57,3 +57,32 @@ func (u autoUpgrade) Args(i Input) k8sutil.OptionPairs {
5757

5858
return k8sutil.NewOptionPair(k8sutil.OptionPair{Key: "--database.auto-upgrade", Value: "true"})
5959
}
60+
61+
func UpgradeDebug() Builder {
62+
return upgradeDebug{}
63+
}
64+
65+
type upgradeDebug struct{}
66+
67+
func (u upgradeDebug) Envs(i Input) []core.EnvVar {
68+
return nil
69+
}
70+
71+
func (u upgradeDebug) Verify(i Input, cachedStatus interfaces.Inspector) error {
72+
return nil
73+
}
74+
75+
func (u upgradeDebug) Volumes(i Input) ([]core.Volume, []core.VolumeMount) {
76+
return nil, nil
77+
}
78+
79+
func (u upgradeDebug) Args(i Input) k8sutil.OptionPairs {
80+
pairs := k8sutil.NewOptionPair()
81+
if i.Deployment.Upgrade.Get().DebugLog {
82+
pairs = append(pairs, k8sutil.OptionPair{
83+
Key: "--log.level",
84+
Value: "all=debug",
85+
})
86+
}
87+
return pairs
88+
}

pkg/deployment/resources/pod_creator_arangod.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,10 @@ func (a *ArangoUpgradeContainer) GetCommand() ([]string, error) {
662662
return nil, err
663663
}
664664

665-
upgradeArgs := pod.AutoUpgrade().Args(a.input).Sort().AsArgs()
665+
upgradeArgs := append(
666+
pod.AutoUpgrade().Args(a.input).Sort().AsArgs(),
667+
pod.UpgradeDebug().Args(a.input).Sort().AsArgs()...,
668+
)
666669

667670
return append(args, upgradeArgs...), nil
668671
}

0 commit comments

Comments
 (0)