Skip to content

[Bugfix] Allow missing token key in License secret #1021

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

Merged
merged 1 commit into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- (Refactor) Optimize go.mod entries
- (Feature) Add `ArangoLocalStorage` CRD auto-installer
- (Feature) Add `ArangoDeploymentReplication` CRD auto-installer
- (Bugfix) Allow missing `token` key in License secret

## [1.2.13](https://github.com/arangodb/kube-arangodb/tree/1.2.13) (2022-06-07)
- (Bugfix) Fix arangosync members state inspection
Expand Down
20 changes: 16 additions & 4 deletions pkg/deployment/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/deployment/resources"
"github.com/arangodb/kube-arangodb/pkg/handlers/utils"
"github.com/arangodb/kube-arangodb/pkg/logging"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/arangod"
"github.com/arangodb/kube-arangodb/pkg/util/constants"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
Expand Down Expand Up @@ -66,7 +67,7 @@ type ContainerIdentity struct {
// ArangoDIdentity helps to resolve the ArangoD identity, e.g.: image ID, version of the entrypoint.
type ArangoDIdentity struct {
interfaces.ContainerCreator
License api.LicenseSpec
License *string
ipAddress string
}

Expand Down Expand Up @@ -214,6 +215,16 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
return false, nil
}

// Find license
var license *string
if s := ib.Spec.License; s.HasSecretName() {
if secret, ok := cachedStatus.Secret().V1().GetSimple(s.GetSecretName()); ok {
if _, ok := secret.Data[constants.SecretKeyToken]; ok {
license = util.NewString(s.GetSecretName())
}
}
}

imagePod := ImageUpdatePod{
spec: ib.Spec,
apiObject: ib.APIObject,
Expand All @@ -223,7 +234,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
image: image,
imagePullPolicy: ib.Spec.GetImagePullPolicy(),
},
License: ib.Spec.License,
License: license,
ipAddress: ib.Spec.GetListenAddr(),
},
}
Expand Down Expand Up @@ -443,9 +454,10 @@ func (a *ArangoDIdentity) GetArgs() ([]string, error) {
func (a *ArangoDIdentity) GetEnvs() []core.EnvVar {
env := make([]core.EnvVar, 0)

if a.License.HasSecretName() {
// Add advanced check for license
if l := a.License; l != nil {
env = append(env, k8sutil.CreateEnvSecretKeySelector(constants.EnvArangoLicenseKey,
a.License.GetSecretName(), constants.SecretKeyToken))
*l, constants.SecretKeyToken))
}

if len(env) > 0 {
Expand Down
Loading