Skip to content

Commit 95112f0

Browse files
authored
[Feature] PVC Member Status info (#1145)
1 parent 537e054 commit 95112f0

23 files changed

+306
-86
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- (Bugfix) Prevent Member Maintenance Error log
88
- (Feature) ID ServerGroup
99
- (Bugfix) Propagate Lifecycle Mount
10+
- (Feature) PVC Member Status info
1011

1112
## [1.2.19](https://github.com/arangodb/kube-arangodb/tree/1.2.19) (2022-10-05)
1213
- (Bugfix) Prevent changes when UID is wrong
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 v1
22+
23+
type MemberPersistentVolumeClaimStatus struct {
24+
Name string `json:"name"`
25+
}
26+
27+
func (m *MemberPersistentVolumeClaimStatus) Equal(other *MemberPersistentVolumeClaimStatus) bool {
28+
if m == nil && other == nil {
29+
return true
30+
}
31+
if m == nil || other == nil {
32+
return false
33+
}
34+
return m.Name == other.Name
35+
}
36+
37+
func (m *MemberPersistentVolumeClaimStatus) GetName() string {
38+
if m == nil {
39+
return ""
40+
}
41+
42+
return m.Name
43+
}
44+
45+
func (m *MemberPersistentVolumeClaimStatus) Propagate(s *MemberStatus) {
46+
if s == nil {
47+
return
48+
}
49+
50+
if m == nil {
51+
s.PersistentVolumeClaimName = ""
52+
} else {
53+
s.PersistentVolumeClaimName = m.Name
54+
}
55+
}

pkg/apis/deployment/v1/member_status.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ type MemberStatus struct {
5050
Phase MemberPhase `json:"phase"`
5151
// CreatedAt holds the creation timestamp of this member.
5252
CreatedAt meta.Time `json:"created-at"`
53-
// PersistentVolumeClaimName holds the name of the persistent volume claim used for this member (if any).
54-
PersistentVolumeClaimName string `json:"persistentVolumeClaimName,omitempty"`
5553
// Conditions specific to this member
5654
Conditions ConditionList `json:"conditions,omitempty"`
5755
// RecentTerminatons holds the times when this member was recently terminated.
@@ -81,6 +79,12 @@ type MemberStatus struct {
8179
Pod *MemberPodStatus `json:"pod,omitempty"`
8280
SecondaryPod *MemberPodStatus `json:"secondaryPod,omitempty"`
8381

82+
// PersistentVolumeClaim keeps information about PVC for Primary Pod
83+
PersistentVolumeClaim *MemberPersistentVolumeClaimStatus `json:"persistentVolumeClaim,omitempty"`
84+
85+
// SecondaryPersistentVolumeClaim keeps information about PVC for SecondaryPod
86+
SecondaryPersistentVolumeClaim *MemberPersistentVolumeClaimStatus `json:"secondaryPersistentVolumeClaim,omitempty"`
87+
8488
// deprecated
8589
// SideCarSpecs contains list of specifications specified for side cars
8690
SideCarSpecs map[string]core.Container `json:"sidecars-specs,omitempty"`
@@ -93,6 +97,9 @@ type MemberStatus struct {
9397
// deprecated
9498
// PodSpecVersion holds the checksum of Pod spec that currently runs this member. Used to rotate pods
9599
PodSpecVersion string `json:"podSpecVersion,omitempty"`
100+
// deprecated
101+
// PersistentVolumeClaimName holds the name of the persistent volume claim used for this member (if any).
102+
PersistentVolumeClaimName string `json:"persistentVolumeClaimName,omitempty"`
96103
}
97104

98105
// Equal checks for equality
@@ -103,7 +110,8 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
103110
s.ClusterID == other.ClusterID &&
104111
s.Phase == other.Phase &&
105112
util.TimeCompareEqual(s.CreatedAt, other.CreatedAt) &&
106-
s.PersistentVolumeClaimName == other.PersistentVolumeClaimName &&
113+
s.PersistentVolumeClaim.Equal(other.PersistentVolumeClaim) &&
114+
s.SecondaryPersistentVolumeClaim.Equal(other.SecondaryPersistentVolumeClaim) &&
107115
s.Pod.Equal(other.Pod) &&
108116
s.SecondaryPod.Equal(other.SecondaryPod) &&
109117
s.Conditions.Equal(other.Conditions) &&

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

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 v2alpha1
22+
23+
type MemberPersistentVolumeClaimStatus struct {
24+
Name string `json:"name"`
25+
}
26+
27+
func (m *MemberPersistentVolumeClaimStatus) Equal(other *MemberPersistentVolumeClaimStatus) bool {
28+
if m == nil && other == nil {
29+
return true
30+
}
31+
if m == nil || other == nil {
32+
return false
33+
}
34+
return m.Name == other.Name
35+
}
36+
37+
func (m *MemberPersistentVolumeClaimStatus) GetName() string {
38+
if m == nil {
39+
return ""
40+
}
41+
42+
return m.Name
43+
}
44+
45+
func (m *MemberPersistentVolumeClaimStatus) Propagate(s *MemberStatus) {
46+
if s == nil {
47+
return
48+
}
49+
50+
if m == nil {
51+
s.PersistentVolumeClaimName = ""
52+
} else {
53+
s.PersistentVolumeClaimName = m.Name
54+
}
55+
}

pkg/apis/deployment/v2alpha1/member_status.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ type MemberStatus struct {
5050
Phase MemberPhase `json:"phase"`
5151
// CreatedAt holds the creation timestamp of this member.
5252
CreatedAt meta.Time `json:"created-at"`
53-
// PersistentVolumeClaimName holds the name of the persistent volume claim used for this member (if any).
54-
PersistentVolumeClaimName string `json:"persistentVolumeClaimName,omitempty"`
5553
// Conditions specific to this member
5654
Conditions ConditionList `json:"conditions,omitempty"`
5755
// RecentTerminatons holds the times when this member was recently terminated.
@@ -81,6 +79,12 @@ type MemberStatus struct {
8179
Pod *MemberPodStatus `json:"pod,omitempty"`
8280
SecondaryPod *MemberPodStatus `json:"secondaryPod,omitempty"`
8381

82+
// PersistentVolumeClaim keeps information about PVC for Primary Pod
83+
PersistentVolumeClaim *MemberPersistentVolumeClaimStatus `json:"persistentVolumeClaim,omitempty"`
84+
85+
// SecondaryPersistentVolumeClaim keeps information about PVC for SecondaryPod
86+
SecondaryPersistentVolumeClaim *MemberPersistentVolumeClaimStatus `json:"secondaryPersistentVolumeClaim,omitempty"`
87+
8488
// deprecated
8589
// SideCarSpecs contains list of specifications specified for side cars
8690
SideCarSpecs map[string]core.Container `json:"sidecars-specs,omitempty"`
@@ -93,6 +97,9 @@ type MemberStatus struct {
9397
// deprecated
9498
// PodSpecVersion holds the checksum of Pod spec that currently runs this member. Used to rotate pods
9599
PodSpecVersion string `json:"podSpecVersion,omitempty"`
100+
// deprecated
101+
// PersistentVolumeClaimName holds the name of the persistent volume claim used for this member (if any).
102+
PersistentVolumeClaimName string `json:"persistentVolumeClaimName,omitempty"`
96103
}
97104

98105
// Equal checks for equality
@@ -103,7 +110,8 @@ func (s MemberStatus) Equal(other MemberStatus) bool {
103110
s.ClusterID == other.ClusterID &&
104111
s.Phase == other.Phase &&
105112
util.TimeCompareEqual(s.CreatedAt, other.CreatedAt) &&
106-
s.PersistentVolumeClaimName == other.PersistentVolumeClaimName &&
113+
s.PersistentVolumeClaim.Equal(other.PersistentVolumeClaim) &&
114+
s.SecondaryPersistentVolumeClaim.Equal(other.SecondaryPersistentVolumeClaim) &&
107115
s.Pod.Equal(other.Pod) &&
108116
s.SecondaryPod.Equal(other.SecondaryPod) &&
109117
s.Conditions.Equal(other.Conditions) &&

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

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

pkg/deployment/deployment_core_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
457457
Images: createTestImages(false),
458458
}
459459

460-
deployment.currentObjectStatus.Members.DBServers[0].PersistentVolumeClaimName = testPersistentVolumeClaimName
460+
deployment.currentObjectStatus.Members.DBServers[0].PersistentVolumeClaim = &api.MemberPersistentVolumeClaimStatus{
461+
Name: testPersistentVolumeClaimName,
462+
}
461463
testCase.createTestPodData(deployment, api.ServerGroupDBServers, firstDBServerStatus)
462464
},
463465
ExpectedEvent: "member dbserver is created",
@@ -614,7 +616,9 @@ func TestEnsurePod_ArangoDB_Core(t *testing.T) {
614616
},
615617
Helper: func(t *testing.T, deployment *Deployment, testCase *testCaseStruct) {
616618
agentWithPersistentVolumeClaim := firstAgentStatus
617-
agentWithPersistentVolumeClaim.PersistentVolumeClaimName = testPersistentVolumeClaimName
619+
agentWithPersistentVolumeClaim.PersistentVolumeClaim = &api.MemberPersistentVolumeClaimStatus{
620+
Name: testPersistentVolumeClaimName,
621+
}
618622

619623
deployment.currentObjectStatus = &api.DeploymentStatus{
620624
Members: api.DeploymentStatusMembers{

pkg/deployment/deployment_status_pod_details_recovery.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ func RecoverPodDetails(in *api.DeploymentStatus) (changed bool, _ error) {
4040
changed = true
4141
}
4242
}
43+
44+
if p := m.Member.PersistentVolumeClaim; p == nil {
45+
// Recovery is nil, recovery might be needed
46+
if m.Member.PersistentVolumeClaimName != "" {
47+
m.Member.PersistentVolumeClaim = &api.MemberPersistentVolumeClaimStatus{
48+
Name: m.Member.PersistentVolumeClaimName,
49+
}
50+
51+
if err := in.Members.Update(m.Member, m.Group); err != nil {
52+
return false, err
53+
}
54+
changed = true
55+
}
56+
}
4357
}
4458
return
4559
}

0 commit comments

Comments
 (0)