Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add spec.upgrade.debugLog option to configure upgrade container logging - GT-356 #1442

Merged
merged 8 commits into from
Oct 19, 2023
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions docs/api/ArangoDeployment.V1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

9 changes: 7 additions & 2 deletions pkg/apis/deployment/v1/deployment_upgrade_spec.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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"`
nikita-vanyasin marked this conversation as resolved.
Show resolved Hide resolved
}

func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/deployment/v2alpha1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
9 changes: 7 additions & 2 deletions pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 {
Expand Down
31 changes: 30 additions & 1 deletion pkg/deployment/pod/upgrade.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
}
5 changes: 4 additions & 1 deletion pkg/deployment/resources/pod_creator_arangod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down