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 @@
- Update UBI Image to 8.4
- Fix ArangoSync Liveness Prove
- Allow runtime update of Sidecar images
- Allow Agent recreation with preserved IDs

## [1.2.2](https://github.com/arangodb/kube-arangodb/tree/1.2.2) (2021-09-09)
- Update 'github.com/arangodb/arangosync-client' dependency to v0.7.0
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/deployment/v1/deployment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ type DeploymentStatus struct {

// ForceStatusReload if set to true forces a reload of the status from the custom resource.
ForceStatusReload *bool `json:"force-status-reload,omitempty"`

// Agency keeps information about agency
Agency *DeploymentStatusAgencyInfo `json:"agency,omitempty"`
}

// Equal checks for equality
Expand All @@ -95,7 +98,8 @@ func (ds *DeploymentStatus) Equal(other DeploymentStatus) bool {
ds.Conditions.Equal(other.Conditions) &&
ds.Plan.Equal(other.Plan) &&
ds.AcceptedSpec.Equal(other.AcceptedSpec) &&
ds.SecretHashes.Equal(other.SecretHashes)
ds.SecretHashes.Equal(other.SecretHashes) &&
ds.Agency.Equal(other.Agency)
}

// IsForceReload returns true if ForceStatusReload is set to true
Expand Down
79 changes: 79 additions & 0 deletions pkg/apis/deployment/v1/deployment_status_agency_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// 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
//

package v1

import (
"sort"
"strings"
)

type DeploymentStatusAgencySize int

func (d *DeploymentStatusAgencySize) Equal(b *DeploymentStatusAgencySize) bool {
if d == nil && b == nil {
return true
}

if d == nil || b == nil {
return true
}

return *d == *b
}

type DeploymentStatusAgencyIDs []string

func (d DeploymentStatusAgencyIDs) Sort() {
sort.Slice(d, func(i, j int) bool {
return strings.Compare(d[i], d[j]) > 0
})
}

func (d DeploymentStatusAgencyIDs) Equal(b DeploymentStatusAgencyIDs) bool {
if len(d) != len(b) {
return false
}

for id := range d {
if d[id] != b[id] {
return false
}
}

return true
}

type DeploymentStatusAgencyInfo struct {
Size *DeploymentStatusAgencySize `json:"size,omitempty"`
IDs DeploymentStatusAgencyIDs `json:"ids,omitempty"`
}

func (d *DeploymentStatusAgencyInfo) Equal(b *DeploymentStatusAgencyInfo) bool {
if d == nil && b == nil {
return true
}

if d == nil || b == nil {
return true
}

return d.IDs.Equal(b.IDs) && d.Size.Equal(b.Size)
}
51 changes: 51 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.

6 changes: 5 additions & 1 deletion pkg/apis/deployment/v2alpha1/deployment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ type DeploymentStatus struct {

// ForceStatusReload if set to true forces a reload of the status from the custom resource.
ForceStatusReload *bool `json:"force-status-reload,omitempty"`

// Agency keeps information about agency
Agency *DeploymentStatusAgencyInfo `json:"agency,omitempty"`
}

// Equal checks for equality
Expand All @@ -95,7 +98,8 @@ func (ds *DeploymentStatus) Equal(other DeploymentStatus) bool {
ds.Conditions.Equal(other.Conditions) &&
ds.Plan.Equal(other.Plan) &&
ds.AcceptedSpec.Equal(other.AcceptedSpec) &&
ds.SecretHashes.Equal(other.SecretHashes)
ds.SecretHashes.Equal(other.SecretHashes) &&
ds.Agency.Equal(other.Agency)
}

// IsForceReload returns true if ForceStatusReload is set to true
Expand Down
79 changes: 79 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_status_agency_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// 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
//

package v2alpha1

import (
"sort"
"strings"
)

type DeploymentStatusAgencySize int

func (d *DeploymentStatusAgencySize) Equal(b *DeploymentStatusAgencySize) bool {
if d == nil && b == nil {
return true
}

if d == nil || b == nil {
return true
}

return *d == *b
}

type DeploymentStatusAgencyIDs []string

func (d DeploymentStatusAgencyIDs) Sort() {
sort.Slice(d, func(i, j int) bool {
return strings.Compare(d[i], d[j]) > 0
})
}

func (d DeploymentStatusAgencyIDs) Equal(b DeploymentStatusAgencyIDs) bool {
if len(d) != len(b) {
return false
}

for id := range d {
if d[id] != b[id] {
return false
}
}

return true
}

type DeploymentStatusAgencyInfo struct {
Size *DeploymentStatusAgencySize `json:"size,omitempty"`
IDs DeploymentStatusAgencyIDs `json:"ids,omitempty"`
}

func (d *DeploymentStatusAgencyInfo) Equal(b *DeploymentStatusAgencyInfo) bool {
if d == nil && b == nil {
return true
}

if d == nil || b == nil {
return true
}

return d.IDs.Equal(b.IDs) && d.Size.Equal(b.Size)
}
4 changes: 3 additions & 1 deletion pkg/apis/deployment/v2alpha1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (a ActionType) String() string {
// Priority returns plan priority
func (a ActionType) Priority() ActionPriority {
switch a {
case ActionTypeMemberPhaseUpdate, ActionTypeMemberRIDUpdate, ActionTypeSetMemberCondition:
case ActionTypeMemberPhaseUpdate, ActionTypeMemberRIDUpdate, ActionTypeSetMemberCondition, ActionTypeBootstrapSetAgencyInfo:
return ActionPriorityHigh
default:
return ActionPriorityNormal
Expand Down Expand Up @@ -165,6 +165,8 @@ const (
ActionTypeArangoMemberUpdatePodSpec ActionType = "ArangoMemberUpdatePodSpec"
// ActionTypeArangoMemberUpdatePodStatus updates pod spec
ActionTypeArangoMemberUpdatePodStatus ActionType = "ArangoMemberUpdatePodStatus"
// ActionTypeBootstrapSetAgencyInfo set agency info into state
ActionTypeBootstrapSetAgencyInfo ActionType = "BootstrapSetAgencyInfo"

// Runtime Updates
// ActionTypeRuntimeContainerImageUpdate updates container image in runtime
Expand Down
51 changes: 51 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.

5 changes: 5 additions & 0 deletions pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ func (d *Deployment) send(ev *deploymentEvent) {
func (d *Deployment) run() {
log := d.deps.Log

// Create agency mapping
if err := d.createAgencyMapping(context.TODO()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why context.TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change

d.CreateEvent(k8sutil.NewErrorEvent("Failed to create agency mapping members", err, d.GetAPIObject()))
}

if d.GetPhase() == api.DeploymentPhaseNone {
// Create service monitor
if d.haveServiceMonitorCRD {
Expand Down
Loading