Skip to content

Commit 6f7c363

Browse files
authored
[Feature] Upgrade as InitContainer (#670)
1 parent 595b78f commit 6f7c363

24 files changed

+403
-83
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Add v2alpha1 API for ArangoDeployment and ArangoDeploymentReplication
55
- Migrate CRD to apiextensions.k8s.io/v1
66
- Add customizable log levels per service
7+
- Move Upgrade as InitContainer and fix Direct Image discovery mode
78

89
## [1.1.2](https://github.com/arangodb/kube-arangodb/tree/1.1.2) (2020-11-11)
910
- Fix Bootstrap phase and move it under Plan

Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ set-deployment-api-version-v1: set-api-version/deployment set-api-version/replic
618618
set-api-version/%:
619619
@grep -rHn "github.com/arangodb/kube-arangodb/pkg/apis/$*/v[A-Za-z0-9]\+" \
620620
"$(ROOT)/pkg/deployment/" \
621+
"$(ROOT)/pkg/replication/" \
621622
"$(ROOT)/pkg/operator/" \
622623
"$(ROOT)/pkg/server/" \
623624
"$(ROOT)/pkg/util/" \
@@ -627,10 +628,28 @@ set-api-version/%:
627628
| xargs -n 1 sed -i "s#github.com/arangodb/kube-arangodb/pkg/apis/$*/v[A-Za-z0-9]\+#github.com/arangodb/kube-arangodb/pkg/apis/$*/v$(API_VERSION)#g"
628629
@grep -rHn "DatabaseV[A-Za-z0-9]\+()" \
629630
"$(ROOT)/pkg/deployment/" \
631+
"$(ROOT)/pkg/replication/" \
630632
"$(ROOT)/pkg/operator/" \
631633
"$(ROOT)/pkg/server/" \
632634
"$(ROOT)/pkg/util/" \
633635
"$(ROOT)/pkg/backup/" \
634636
"$(ROOT)/pkg/apis/backup/" \
635637
| cut -d ':' -f 1 | sort | uniq \
636-
| xargs -n 1 sed -i "s#DatabaseV[A-Za-z0-9]\+()\.#DatabaseV$(API_VERSION)().#g"
638+
| xargs -n 1 sed -i "s#DatabaseV[A-Za-z0-9]\+()\.#DatabaseV$(API_VERSION)().#g"
639+
@grep -rHn "ReplicationV[A-Za-z0-9]\+()" \
640+
"$(ROOT)/pkg/deployment/" \
641+
"$(ROOT)/pkg/replication/" \
642+
"$(ROOT)/pkg/operator/" \
643+
"$(ROOT)/pkg/server/" \
644+
"$(ROOT)/pkg/util/" \
645+
"$(ROOT)/pkg/backup/" \
646+
"$(ROOT)/pkg/apis/backup/" \
647+
| cut -d ':' -f 1 | sort | uniq \
648+
| xargs -n 1 sed -i "s#ReplicationV[A-Za-z0-9]\+()\.#ReplicationV$(API_VERSION)().#g"
649+
650+
synchronize-v2alpha1-with-v1:
651+
@rm -f pkg/apis/deployment/v1/zz_generated.deepcopy.go pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go
652+
@for file in $$(find "$(ROOT)/pkg/apis/deployment/v1/" -type f -exec basename {} \;); do cat "$(ROOT)/pkg/apis/deployment/v1/$${file}" | sed "s#package v1#package v2alpha1#g" | sed 's#ArangoDeploymentVersion = "v1"#ArangoDeploymentVersion = "v2alpha1"#g' > "$(ROOT)/pkg/apis/deployment/v2alpha1/$${file}"; done
653+
@make update-generated
654+
@make set-deployment-api-version-v2alpha1 bin
655+
@make set-deployment-api-version-v1 bin

pkg/apis/deployment/v1/deployment_spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type DeploymentSpec struct {
6060
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
6161
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
6262

63+
Upgrade *DeploymentUpgradeSpec `json:"upgrade,omitempty"`
64+
6365
Features *DeploymentFeatures `json:"features,omitempty"`
6466

6567
NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2020 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+
// Author Adam Janikowski
21+
//
22+
23+
package v1
24+
25+
type DeploymentUpgradeSpec struct {
26+
// Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck)
27+
AutoUpgrade bool `json:"autoUpgrade"`
28+
}
29+
30+
func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {
31+
if d == nil {
32+
return DeploymentUpgradeSpec{}
33+
}
34+
35+
return *d
36+
}

pkg/apis/deployment/v1/image_info.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ type ImageInfo struct {
3535
// ImageInfoList is a list of image infos
3636
type ImageInfoList []ImageInfo
3737

38+
func (l ImageInfoList) Add(i ...ImageInfo) ImageInfoList {
39+
return append(l, i...)
40+
}
41+
3842
// GetByImage returns the info in the given list for the image with given name.
3943
// If not found, false is returned.
4044
func (l ImageInfoList) GetByImage(image string) (ImageInfo, bool) {

pkg/apis/deployment/v1/member_status.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ type MemberStatus struct {
6969
ImageID string `json:"image-id,omitempty"`
7070
// Image holds image details
7171
Image *ImageInfo `json:"image,omitempty"`
72+
// Upgrade define if upgrade should be enforced during next execution
73+
Upgrade bool `json:"upgrade,omitempty"`
7274
}
7375

7476
// Equal checks for equality
@@ -84,7 +86,8 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
8486
reflect.DeepEqual(s.SideCarSpecs, other.SideCarSpecs) &&
8587
s.ArangoVersion == other.ArangoVersion &&
8688
s.ImageID == other.ImageID &&
87-
s.Image.Equal(other.Image)
89+
s.Image.Equal(other.Image) &&
90+
s.Upgrade == other.Upgrade
8891
}
8992

9093
// Age returns the duration since the creation timestamp of this member.

pkg/apis/deployment/v1/server_group_init_containers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ import (
3232
const (
3333
ServerGroupReservedInitContainerNameLifecycle = "init-lifecycle"
3434
ServerGroupReservedInitContainerNameUUID = "uuid"
35+
ServerGroupReservedInitContainerNameUpgrade = "upgrade"
3536
)
3637

3738
func IsReservedServerGroupInitContainerName(name string) bool {
3839
switch name {
39-
case ServerGroupReservedInitContainerNameLifecycle, ServerGroupReservedInitContainerNameUUID:
40+
case ServerGroupReservedInitContainerNameLifecycle, ServerGroupReservedInitContainerNameUUID, ServerGroupReservedInitContainerNameUpgrade:
4041
return true
4142
default:
4243
return false

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

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

pkg/apis/deployment/v2alpha1/deployment_spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type DeploymentSpec struct {
6060
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
6161
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
6262

63+
Upgrade *DeploymentUpgradeSpec `json:"upgrade,omitempty"`
64+
6365
Features *DeploymentFeatures `json:"features,omitempty"`
6466

6567
NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2020 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+
// Author Adam Janikowski
21+
//
22+
23+
package v2alpha1
24+
25+
type DeploymentUpgradeSpec struct {
26+
// Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck)
27+
AutoUpgrade bool `json:"autoUpgrade"`
28+
}
29+
30+
func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {
31+
if d == nil {
32+
return DeploymentUpgradeSpec{}
33+
}
34+
35+
return *d
36+
}

0 commit comments

Comments
 (0)