Skip to content

Commit 87ea1ee

Browse files
authored
[Bugfix] Accept Initial Spec (#1125)
1 parent 5407033 commit 87ea1ee

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- (Feature) Define Actions PlaceHolder
55
- (Feature) Add Member Update helpers
66
- (Feature) Active Member condition
7+
- (Bugfix) Accept Initial Spec
78

89
## [1.2.17](https://github.com/arangodb/kube-arangodb/tree/1.2.17) (2022-09-22)
910
- (Feature) Add new field to DeploymentReplicationStatus with details on DC2DC sync status=

pkg/deployment/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ func (d *Deployment) acceptNewSpec(ctx context.Context, depl *api.ArangoDeployme
445445
return false, false, err
446446
}
447447

448-
if acceptedChecksum == checksum {
448+
if v := depl.Status.AcceptedSpecVersion; acceptedChecksum == checksum && (v != nil && *v == acceptedChecksum) {
449449
return true, false, nil
450450
}
451451

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 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 deployment
22+
23+
import (
24+
"context"
25+
"testing"
26+
27+
"github.com/stretchr/testify/require"
28+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
29+
30+
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
31+
)
32+
33+
func Test_SpecAccept_Initial(t *testing.T) {
34+
spec := api.DeploymentSpec{}
35+
36+
spec.SetDefaults(testDeploymentName)
37+
38+
depl := &api.ArangoDeployment{
39+
ObjectMeta: meta.ObjectMeta{
40+
Name: testDeploymentName,
41+
},
42+
Spec: spec,
43+
Status: api.DeploymentStatus{
44+
AcceptedSpec: spec.DeepCopy(),
45+
},
46+
}
47+
48+
d, _ := createTestDeployment(t, Config{}, depl)
49+
50+
if _, err := d.deps.Client.Arango().DatabaseV1().ArangoDeployments(testNamespace).Create(context.Background(), depl, meta.CreateOptions{}); err != nil {
51+
require.NoError(t, err)
52+
}
53+
54+
_, _, err := d.acceptNewSpec(context.Background(), depl)
55+
require.NoError(t, err)
56+
57+
depl, err = d.deps.Client.Arango().DatabaseV1().ArangoDeployments(testNamespace).Get(context.Background(), testDeploymentName, meta.GetOptions{})
58+
require.NoError(t, err)
59+
60+
checksum, err := spec.Checksum()
61+
require.NoError(t, err)
62+
63+
require.NotNil(t, depl.Status.AcceptedSpecVersion)
64+
require.Equal(t, checksum, *depl.Status.AcceptedSpecVersion)
65+
}

0 commit comments

Comments
 (0)