mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Define ClusterID in ArangoMember and Member status (UUID of ArangoDeloyment) (TG-192) (#882)
This commit is contained in:
parent
01775ca5bf
commit
afcb5cc721
6 changed files with 20 additions and 10 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
||||
- Do not check License V2 on Community images
|
||||
- Add status.members.<group>.
|
||||
|
||||
## [1.2.7](https://github.com/arangodb/kube-arangodb/tree/1.2.7) (2022-01-17)
|
||||
- Add Plan BackOff functionality
|
||||
|
|
|
@ -44,6 +44,8 @@ type MemberStatus struct {
|
|||
// RID holds the ID of the member run.
|
||||
// Value is updated in Pending Phase.
|
||||
RID types.UID `json:"rid,omitempty"`
|
||||
// ClusterID holds the ID of the Arango deployment.
|
||||
ClusterID types.UID `json:"cid,omitempty"`
|
||||
// Phase holds the current lifetime phase of this member
|
||||
Phase MemberPhase `json:"phase"`
|
||||
// CreatedAt holds the creation timestamp of this member.
|
||||
|
@ -91,6 +93,7 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
|
|||
return s.ID == other.ID &&
|
||||
s.UID == other.UID &&
|
||||
s.RID == other.RID &&
|
||||
s.ClusterID == other.ClusterID &&
|
||||
s.Phase == other.Phase &&
|
||||
util.TimeCompareEqual(s.CreatedAt, other.CreatedAt) &&
|
||||
s.PersistentVolumeClaimName == other.PersistentVolumeClaimName &&
|
||||
|
|
|
@ -44,6 +44,8 @@ type MemberStatus struct {
|
|||
// RID holds the ID of the member run.
|
||||
// Value is updated in Pending Phase.
|
||||
RID types.UID `json:"rid,omitempty"`
|
||||
// ClusterID holds the ID of the Arango deployment.
|
||||
ClusterID types.UID `json:"cid,omitempty"`
|
||||
// Phase holds the current lifetime phase of this member
|
||||
Phase MemberPhase `json:"phase"`
|
||||
// CreatedAt holds the creation timestamp of this member.
|
||||
|
@ -91,6 +93,7 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
|
|||
return s.ID == other.ID &&
|
||||
s.UID == other.UID &&
|
||||
s.RID == other.RID &&
|
||||
s.ClusterID == other.ClusterID &&
|
||||
s.Phase == other.Phase &&
|
||||
util.TimeCompareEqual(s.CreatedAt, other.CreatedAt) &&
|
||||
s.PersistentVolumeClaimName == other.PersistentVolumeClaimName &&
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"time"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
)
|
||||
|
||||
|
@ -31,12 +32,12 @@ const (
|
|||
recentTerminationsKeepPeriod = time.Minute * 30
|
||||
)
|
||||
|
||||
type phaseMapFunc func(action api.Action, m *api.MemberStatus)
|
||||
type phaseMapFunc func(obj meta.Object, group api.ServerGroup, action api.Action, m *api.MemberStatus)
|
||||
type phaseMapTo map[api.MemberPhase]phaseMapFunc
|
||||
type phaseMap map[api.MemberPhase]phaseMapTo
|
||||
|
||||
type PhaseExecutor interface {
|
||||
Execute(m *api.MemberStatus, action api.Action, to api.MemberPhase) bool
|
||||
Execute(obj meta.Object, group api.ServerGroup, m *api.MemberStatus, action api.Action, to api.MemberPhase) bool
|
||||
}
|
||||
|
||||
func GetPhaseExecutor() PhaseExecutor {
|
||||
|
@ -45,20 +46,22 @@ func GetPhaseExecutor() PhaseExecutor {
|
|||
|
||||
var phase = phaseMap{
|
||||
api.MemberPhaseNone: {
|
||||
api.MemberPhasePending: func(action api.Action, m *api.MemberStatus) {
|
||||
api.MemberPhasePending: func(obj meta.Object, group api.ServerGroup, action api.Action, m *api.MemberStatus) {
|
||||
// Change member RID
|
||||
m.RID = uuid.NewUUID()
|
||||
|
||||
// Clean Pod details
|
||||
m.PodUID = ""
|
||||
|
||||
m.ClusterID = obj.GetUID()
|
||||
},
|
||||
},
|
||||
api.MemberPhasePending: {
|
||||
api.MemberPhaseCreated: func(action api.Action, m *api.MemberStatus) {
|
||||
api.MemberPhaseCreated: func(obj meta.Object, group api.ServerGroup, action api.Action, m *api.MemberStatus) {
|
||||
// Clean conditions
|
||||
removeMemberConditionsMapFunc(m)
|
||||
},
|
||||
api.MemberPhaseUpgrading: func(action api.Action, m *api.MemberStatus) {
|
||||
api.MemberPhaseUpgrading: func(obj meta.Object, group api.ServerGroup, action api.Action, m *api.MemberStatus) {
|
||||
removeMemberConditionsMapFunc(m)
|
||||
},
|
||||
},
|
||||
|
@ -88,7 +91,7 @@ func removeMemberConditionsMapFunc(m *api.MemberStatus) {
|
|||
m.Upgrade = false
|
||||
}
|
||||
|
||||
func (p phaseMap) empty(action api.Action, m *api.MemberStatus) {
|
||||
func (p phaseMap) empty(obj meta.Object, group api.ServerGroup, action api.Action, m *api.MemberStatus) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -102,7 +105,7 @@ func (p phaseMap) getFunc(from, to api.MemberPhase) phaseMapFunc {
|
|||
return p.empty
|
||||
}
|
||||
|
||||
func (p phaseMap) Execute(m *api.MemberStatus, action api.Action, to api.MemberPhase) bool {
|
||||
func (p phaseMap) Execute(obj meta.Object, group api.ServerGroup, m *api.MemberStatus, action api.Action, to api.MemberPhase) bool {
|
||||
from := m.Phase
|
||||
|
||||
if from == to {
|
||||
|
@ -113,7 +116,7 @@ func (p phaseMap) Execute(m *api.MemberStatus, action api.Action, to api.MemberP
|
|||
|
||||
m.Phase = to
|
||||
|
||||
f(action, m)
|
||||
f(obj, group, action, m)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func (a *memberPhaseUpdateAction) Start(ctx context.Context) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
if member.GetPhaseExecutor().Execute(&m, a.action, p) {
|
||||
if member.GetPhaseExecutor().Execute(a.actionCtx.GetAPIObject(), a.action.Group, &m, a.action, p) {
|
||||
if err := a.actionCtx.UpdateMember(ctx, m); err != nil {
|
||||
return false, errors.WithStack(err)
|
||||
}
|
||||
|
|
|
@ -547,7 +547,7 @@ func (r *Resources) createPodForMember(ctx context.Context, cachedStatus inspect
|
|||
m.PodSpecVersion = template.PodSpecChecksum
|
||||
}
|
||||
|
||||
member.GetPhaseExecutor().Execute(&m, api.Action{}, newPhase)
|
||||
member.GetPhaseExecutor().Execute(r.context.GetAPIObject(), group, &m, api.Action{}, newPhase)
|
||||
|
||||
if top := status.Topology; top.Enabled() {
|
||||
if m.Topology != nil && m.Topology.ID == top.ID {
|
||||
|
|
Loading…
Reference in a new issue