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 @@ -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
nikita-vanyasin marked this conversation as resolved.
Show resolved Hide resolved

## [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
Expand Down
7 changes: 5 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,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"`
nikita-vanyasin marked this conversation as resolved.
Show resolved Hide resolved
}

func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {
Expand Down
7 changes: 5 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,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 {
Expand Down
29 changes: 29 additions & 0 deletions pkg/deployment/pod/upgrade.go
Original file line number Diff line number Diff line change
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