Skip to content

Commit 38dcb31

Browse files
authored
Merge pull request #307 from arangodb/feature/license-key
License Key
2 parents fb851e3 + ae3190b commit 38dcb31

29 files changed

+360
-107
lines changed

Jenkinsfile.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ def buildTestSteps(Map myParams, String kubeConfigRoot, String kubeconfig) {
8181
return {
8282
timestamps {
8383
timeout(time: myParams.LONG ? 180 : 30) {
84-
withCredentials([string(credentialsId: 'ENTERPRISEIMAGE', variable: 'DEFAULTENTERPRISEIMAGE')]) {
84+
withCredentials([
85+
string(credentialsId: 'ENTERPRISEIMAGE', variable: 'DEFAULTENTERPRISEIMAGE'),
86+
string(credentialsId: 'ENTERPRISELICENSE', variable: 'DEFAULTENTERPRISELICENSE'),
87+
]) {
8588
withEnv([
8689
"CLEANDEPLOYMENTS=1",
8790
"DEPLOYMENTNAMESPACE=${myParams.TESTNAMESPACE}-${env.GIT_COMMIT}",
8891
"DOCKERNAMESPACE=${myParams.DOCKERNAMESPACE}",
8992
"ENTERPRISEIMAGE=${myParams.ENTERPRISEIMAGE}",
93+
"ENTERPRISELICENSE=${myParams.ENTERPRISELICENSE}",
9094
"ARANGODIMAGE=${myParams.ARANGODIMAGE}",
9195
"IMAGETAG=jenkins-test",
9296
"KUBECONFIG=${kubeConfigRoot}/${kubeconfig}",
@@ -132,6 +136,7 @@ pipeline {
132136
string(name: 'TESTNAMESPACE', defaultValue: 'jenkins', description: 'TESTNAMESPACE sets the kubernetes namespace to ru tests in (this must be short!!)', )
133137
string(name: 'ENTERPRISEIMAGE', defaultValue: '', description: 'ENTERPRISEIMAGE sets the docker image used for enterprise tests', )
134138
string(name: 'ARANGODIMAGE', defaultValue: '', description: 'ARANGODIMAGE sets the docker image used for tests (except enterprise and update tests)', )
139+
string(name: 'ENTERPRISELICENSE', defaultValue: '', description: 'ENTERPRISELICENSE sets the enterprise license key for enterprise tests', )
135140
string(name: 'TESTOPTIONS', defaultValue: '', description: 'TESTOPTIONS is used to pass additional test options to the integration test', )
136141
}
137142
stages {

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ endif
7373
ifndef ENTERPRISEIMAGE
7474
ENTERPRISEIMAGE := $(DEFAULTENTERPRISEIMAGE)
7575
endif
76+
ifndef ENTERPRISELICENSE
77+
ENTERPRISELICENSE := $(DEFAULTENTERPRISELICENSE)
78+
endif
7679
DASHBOARDBUILDIMAGE := kube-arangodb-dashboard-builder
7780

7881
ifndef ALLOWCHAOS
@@ -307,7 +310,8 @@ endif
307310
kubectl apply -f $(MANIFESTPATHDEPLOYMENTREPLICATION)
308311
kubectl apply -f $(MANIFESTPATHTEST)
309312
$(ROOTDIR)/scripts/kube_create_storage.sh $(DEPLOYMENTNAMESPACE)
310-
$(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ARANGODIMAGE)" "$(ENTERPRISEIMAGE)" $(TESTTIMEOUT) $(TESTLENGTHOPTIONS)
313+
$(ROOTDIR)/scripts/kube_create_license_key_secret.sh "$(DEPLOYMENTNAMESPACE)" '$(ENTERPRISELICENSE)'
314+
$(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ARANGODIMAGE)" '$(ENTERPRISEIMAGE)' $(TESTTIMEOUT) $(TESTLENGTHOPTIONS)
311315

312316
$(DURATIONTESTBIN): $(GOBUILDDIR) $(SOURCES)
313317
@mkdir -p $(BINDIR)

dashboard/assets.go

Lines changed: 65 additions & 65 deletions
Large diffs are not rendered by default.

docs/Manual/Deployment/Kubernetes/DeploymentResource.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ The default is `false`.
332332

333333
This setting cannot be changed after the deployment has been created.
334334

335+
### `spec.license.secretName: string`
336+
337+
This setting specifies the name of a kubernetes `Secret` that contains
338+
the license key token used for enterprise images. This value is not used for
339+
the community edition.
340+
335341
### `spec.<group>.count: number`
336342

337343
This setting specifies the number of servers to start for the given group.

pkg/apis/deployment/v1alpha/deployment_spec.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type DeploymentSpec struct {
6060
Authentication AuthenticationSpec `json:"auth"`
6161
TLS TLSSpec `json:"tls"`
6262
Sync SyncSpec `json:"sync"`
63+
License LicenseSpec `json:"license"`
6364

6465
Single ServerGroupSpec `json:"single"`
6566
Agents ServerGroupSpec `json:"agents"`
@@ -204,6 +205,7 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
204205
if s.DisableIPv6 == nil {
205206
s.DisableIPv6 = util.NewBoolOrNil(source.DisableIPv6)
206207
}
208+
s.License.SetDefaultsFrom(source.License)
207209
s.ExternalAccess.SetDefaultsFrom(source.ExternalAccess)
208210
s.RocksDB.SetDefaultsFrom(source.RocksDB)
209211
s.Authentication.SetDefaultsFrom(source.Authentication)
@@ -272,6 +274,9 @@ func (s *DeploymentSpec) Validate() error {
272274
if err := s.Chaos.Validate(); err != nil {
273275
return maskAny(errors.Wrap(err, "spec.chaos"))
274276
}
277+
if err := s.License.Validate(); err != nil {
278+
return maskAny(errors.Wrap(err, "spec.licenseKey"))
279+
}
275280
return nil
276281
}
277282

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha
22+
23+
import (
24+
"github.com/arangodb/kube-arangodb/pkg/util"
25+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
26+
)
27+
28+
// LicenseSpec holds the license related information
29+
type LicenseSpec struct {
30+
SecretName *string `json:"secretName,omitempty"`
31+
}
32+
33+
// HasSecretName returns true if a license key secret name was set
34+
func (s LicenseSpec) HasSecretName() bool {
35+
return s.SecretName != nil
36+
}
37+
38+
// GetSecretName returns the license key if set. Empty string otherwise.
39+
func (s LicenseSpec) GetSecretName() string {
40+
if s.HasSecretName() {
41+
return *s.SecretName
42+
}
43+
44+
return ""
45+
}
46+
47+
// Validate validates the LicenseSpec
48+
func (s LicenseSpec) Validate() error {
49+
if s.HasSecretName() {
50+
if err := k8sutil.ValidateResourceName(s.GetSecretName()); err != nil {
51+
return err
52+
}
53+
}
54+
55+
return nil
56+
}
57+
58+
// SetDefaultsFrom fills all values not set in s with values from other
59+
func (s LicenseSpec) SetDefaultsFrom(other LicenseSpec) {
60+
if !s.HasSecretName() {
61+
s.SecretName = util.NewStringOrNil(other.SecretName)
62+
}
63+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package v1alpha
2+
3+
import (
4+
"testing"
5+
6+
"github.com/arangodb/kube-arangodb/pkg/util"
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func TestLicenseSpecValidation(t *testing.T) {
11+
assert.Nil(t, LicenseSpec{SecretName: nil}.Validate())
12+
assert.Nil(t, LicenseSpec{SecretName: util.NewString("some-name")}.Validate())
13+
14+
assert.Error(t, LicenseSpec{SecretName: util.NewString("@@")}.Validate())
15+
}

pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/context_impl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,6 @@ func (d *Deployment) DeleteSecret(secretName string) error {
377377

378378
// GetExpectedPodArguments creates command line arguments for a server in the given group with given ID.
379379
func (d *Deployment) GetExpectedPodArguments(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup,
380-
agents api.MemberStatusList, id string) []string {
381-
return d.resources.GetExpectedPodArguments(apiObject, deplSpec, group, agents, id)
380+
agents api.MemberStatusList, id string, version driver.Version) []string {
381+
return d.resources.GetExpectedPodArguments(apiObject, deplSpec, group, agents, id, version)
382382
}

pkg/deployment/deployment_inspector.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval
8080
d.CreateEvent(k8sutil.NewErrorEvent("Secret hash validation failed", err, d.apiObject))
8181
}
8282

83+
// Check for LicenseKeySecret
84+
if err := d.resources.ValidateLicenseKeySecret(); err != nil {
85+
hasError = true
86+
d.CreateEvent(k8sutil.NewErrorEvent("License Key Secret invalid", err, d.apiObject))
87+
}
88+
8389
// Is the deployment in a good state?
8490
status, _ := d.GetStatus()
8591
if status.Conditions.IsTrue(api.ConditionTypeSecretsChanged) {

0 commit comments

Comments
 (0)