Skip to content
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 @@ -4,6 +4,7 @@
- Add v2alpha1 API for ArangoDeployment and ArangoDeploymentReplication
- Migrate CRD to apiextensions.k8s.io/v1
- Add customizable log levels per service
- Move Upgrade as InitContainer and fix Direct Image discovery mode

## [1.1.2](https://github.com/arangodb/kube-arangodb/tree/1.1.2) (2020-11-11)
- Fix Bootstrap phase and move it under Plan
Expand Down
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ set-deployment-api-version-v1: set-api-version/deployment set-api-version/replic
set-api-version/%:
@grep -rHn "github.com/arangodb/kube-arangodb/pkg/apis/$*/v[A-Za-z0-9]\+" \
"$(ROOT)/pkg/deployment/" \
"$(ROOT)/pkg/replication/" \
"$(ROOT)/pkg/operator/" \
"$(ROOT)/pkg/server/" \
"$(ROOT)/pkg/util/" \
Expand All @@ -627,10 +628,28 @@ set-api-version/%:
| 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"
@grep -rHn "DatabaseV[A-Za-z0-9]\+()" \
"$(ROOT)/pkg/deployment/" \
"$(ROOT)/pkg/replication/" \
"$(ROOT)/pkg/operator/" \
"$(ROOT)/pkg/server/" \
"$(ROOT)/pkg/util/" \
"$(ROOT)/pkg/backup/" \
"$(ROOT)/pkg/apis/backup/" \
| cut -d ':' -f 1 | sort | uniq \
| xargs -n 1 sed -i "s#DatabaseV[A-Za-z0-9]\+()\.#DatabaseV$(API_VERSION)().#g"
| xargs -n 1 sed -i "s#DatabaseV[A-Za-z0-9]\+()\.#DatabaseV$(API_VERSION)().#g"
@grep -rHn "ReplicationV[A-Za-z0-9]\+()" \
"$(ROOT)/pkg/deployment/" \
"$(ROOT)/pkg/replication/" \
"$(ROOT)/pkg/operator/" \
"$(ROOT)/pkg/server/" \
"$(ROOT)/pkg/util/" \
"$(ROOT)/pkg/backup/" \
"$(ROOT)/pkg/apis/backup/" \
| cut -d ':' -f 1 | sort | uniq \
| xargs -n 1 sed -i "s#ReplicationV[A-Za-z0-9]\+()\.#ReplicationV$(API_VERSION)().#g"

synchronize-v2alpha1-with-v1:
@rm -f pkg/apis/deployment/v1/zz_generated.deepcopy.go pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go
@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
@make update-generated
@make set-deployment-api-version-v2alpha1 bin
@make set-deployment-api-version-v1 bin
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type DeploymentSpec struct {
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
DisableIPv6 *bool `json:"disableIPv6,omitempty"`

Upgrade *DeploymentUpgradeSpec `json:"upgrade,omitempty"`

Features *DeploymentFeatures `json:"features,omitempty"`

NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
Expand Down
36 changes: 36 additions & 0 deletions pkg/apis/deployment/v1/deployment_upgrade_spec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// DISCLAIMER
//
// Copyright 2020 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v1

type DeploymentUpgradeSpec struct {
// Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck)
AutoUpgrade bool `json:"autoUpgrade"`
}

func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {
if d == nil {
return DeploymentUpgradeSpec{}
}

return *d
}
4 changes: 4 additions & 0 deletions pkg/apis/deployment/v1/image_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type ImageInfo struct {
// ImageInfoList is a list of image infos
type ImageInfoList []ImageInfo

func (l ImageInfoList) Add(i ...ImageInfo) ImageInfoList {
return append(l, i...)
}

// GetByImage returns the info in the given list for the image with given name.
// If not found, false is returned.
func (l ImageInfoList) GetByImage(image string) (ImageInfo, bool) {
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/deployment/v1/member_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type MemberStatus struct {
ImageID string `json:"image-id,omitempty"`
// Image holds image details
Image *ImageInfo `json:"image,omitempty"`
// Upgrade define if upgrade should be enforced during next execution
Upgrade bool `json:"upgrade,omitempty"`
}

// Equal checks for equality
Expand All @@ -84,7 +86,8 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
reflect.DeepEqual(s.SideCarSpecs, other.SideCarSpecs) &&
s.ArangoVersion == other.ArangoVersion &&
s.ImageID == other.ImageID &&
s.Image.Equal(other.Image)
s.Image.Equal(other.Image) &&
s.Upgrade == other.Upgrade
}

// Age returns the duration since the creation timestamp of this member.
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/deployment/v1/server_group_init_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import (
const (
ServerGroupReservedInitContainerNameLifecycle = "init-lifecycle"
ServerGroupReservedInitContainerNameUUID = "uuid"
ServerGroupReservedInitContainerNameUpgrade = "upgrade"
)

func IsReservedServerGroupInitContainerName(name string) bool {
switch name {
case ServerGroupReservedInitContainerNameLifecycle, ServerGroupReservedInitContainerNameUUID:
case ServerGroupReservedInitContainerNameLifecycle, ServerGroupReservedInitContainerNameUUID, ServerGroupReservedInitContainerNameUpgrade:
return true
default:
return false
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/deployment/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type DeploymentSpec struct {
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
DisableIPv6 *bool `json:"disableIPv6,omitempty"`

Upgrade *DeploymentUpgradeSpec `json:"upgrade,omitempty"`

Features *DeploymentFeatures `json:"features,omitempty"`

NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
Expand Down
36 changes: 36 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_upgrade_spec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// DISCLAIMER
//
// Copyright 2020 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v2alpha1

type DeploymentUpgradeSpec struct {
// Flag specify if upgrade should be auto-injected, even if is not required (in case of stuck)
AutoUpgrade bool `json:"autoUpgrade"`
}

func (d *DeploymentUpgradeSpec) Get() DeploymentUpgradeSpec {
if d == nil {
return DeploymentUpgradeSpec{}
}

return *d
}
4 changes: 4 additions & 0 deletions pkg/apis/deployment/v2alpha1/image_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type ImageInfo struct {
// ImageInfoList is a list of image infos
type ImageInfoList []ImageInfo

func (l ImageInfoList) Add(i ...ImageInfo) ImageInfoList {
return append(l, i...)
}

// GetByImage returns the info in the given list for the image with given name.
// If not found, false is returned.
func (l ImageInfoList) GetByImage(image string) (ImageInfo, bool) {
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/deployment/v2alpha1/member_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type MemberStatus struct {
ImageID string `json:"image-id,omitempty"`
// Image holds image details
Image *ImageInfo `json:"image,omitempty"`
// Upgrade define if upgrade should be enforced during next execution
Upgrade bool `json:"upgrade,omitempty"`
}

// Equal checks for equality
Expand All @@ -84,7 +86,8 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
reflect.DeepEqual(s.SideCarSpecs, other.SideCarSpecs) &&
s.ArangoVersion == other.ArangoVersion &&
s.ImageID == other.ImageID &&
s.Image.Equal(other.Image)
s.Image.Equal(other.Image) &&
s.Upgrade == other.Upgrade
}

// Age returns the duration since the creation timestamp of this member.
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/deployment/v2alpha1/server_group_init_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import (
const (
ServerGroupReservedInitContainerNameLifecycle = "init-lifecycle"
ServerGroupReservedInitContainerNameUUID = "uuid"
ServerGroupReservedInitContainerNameUpgrade = "upgrade"
)

func IsReservedServerGroupInitContainerName(name string) bool {
switch name {
case ServerGroupReservedInitContainerNameLifecycle, ServerGroupReservedInitContainerNameUUID:
case ServerGroupReservedInitContainerNameLifecycle, ServerGroupReservedInitContainerNameUUID, ServerGroupReservedInitContainerNameUpgrade:
return true
default:
return false
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions pkg/deployment/reconcile/action_upgrade_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,12 @@ func (a *actionUpgradeMember) CheckProgress(ctx context.Context) (bool, bool, er
log = log.With().
Str("pod-name", m.PodName).
Bool("is-upgrading", isUpgrading).Logger()
if !m.Conditions.IsTrue(api.ConditionTypeTerminated) {
if !m.Conditions.IsTrue(api.ConditionTypeReady) {
// Pod is not yet terminated
return false, false, nil
}
// Pod is terminated, we can now remove it
log.Debug().Msg("Deleting pod")
if err := a.actionCtx.DeletePod(m.PodName); err != nil {
return false, false, maskAny(err)
}
// Pod is now gone, update the member status
m.Phase = api.MemberPhaseNone
m.Phase = api.MemberPhaseCreated
m.RecentTerminations = nil // Since we're upgrading, we do not care about old terminations.
m.CleanoutJobID = ""
if err := a.actionCtx.UpdateMember(m); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/reconcile/plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type upgradeDecision struct {
UpgradeNeeded bool // If set, the image version has changed
UpgradeAllowed bool // If set, it is an allowed version change
AutoUpgradeNeeded bool // If set, the database must be started with `--database.auto-upgrade` once

Hold bool
}

// CreatePlan considers the current specification & status of the deployment creates a plan to
Expand Down
Loading