Skip to content

Commit 47863a6

Browse files
authored
148 leader election fix (#162)
* Finally fix for #148 and deploy latest image from master
1 parent 6a9e8b2 commit 47863a6

File tree

4 files changed

+6
-75
lines changed

4 files changed

+6
-75
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
uses: docker/metadata-action@v4
2929
with:
3030
images: tarantool/tarantool-operator
31+
tags: |
32+
# set `latest` tag for master branch
33+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
34+
type=semver,pattern={{version}}
3135
3236
- name: Build and push Docker image
3337
uses: docker/build-push-action@v3

pkg/reconciliation/steps/role/join_instances.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (r *JoinInstancesStep[PhaseType, RoleType, CtxType, CtrlType]) Reconcile(ct
6262
continue
6363
}
6464

65-
if !utils.IsPodRunning(pod) || !utils.IsPodDefaultContainerReady(pod) {
65+
if !utils.IsPodRunning(pod) || utils.IsPodDeleting(pod) {
6666
allJoined = false
6767

6868
continue
@@ -79,7 +79,7 @@ func (r *JoinInstancesStep[PhaseType, RoleType, CtxType, CtrlType]) Reconcile(ct
7979
vshard := role.GetVShardConfig()
8080

8181
alias, err := role.GetReplicasetName(stsOrdinal)
82-
if uuidErr != nil {
82+
if err != nil {
8383
return Error(err)
8484
}
8585

pkg/utils/pods.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ func IsPodRunning(pod *v1.Pod) bool {
1010
return pod.Status.Phase == v1.PodRunning
1111
}
1212

13-
func IsPodDefaultContainerReady(pod *v1.Pod) bool {
14-
if !IsPodRunning(pod) {
15-
return false
16-
}
17-
18-
if pod.Status.ContainerStatuses == nil || len(pod.Status.ContainerStatuses) == 0 {
19-
return false
20-
}
21-
22-
return pod.Status.ContainerStatuses[0].Ready
23-
}
24-
2513
// IsPodReady returns true if a pod is ready; false otherwise.
2614
func IsPodReady(pod *v1.Pod) bool {
2715
return IsPodReadyConditionTrue(pod.Status)

test/resources/pod.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ func (r *FakeCartridge) WithStoragePodsCreated() *FakeCartridge {
5454
func (r *FakeCartridge) WithAllPodsRunning() *FakeCartridge {
5555
for _, pod := range r.Pods {
5656
r.setPodRunning(pod)
57-
r.setPodContainerReady(pod, PodContainerName)
58-
}
59-
60-
return r
61-
}
62-
63-
func (r *FakeCartridge) WithAllPodsReady() *FakeCartridge {
64-
for _, pod := range r.Pods {
65-
r.setPodReady(pod)
66-
r.setPodContainerReady(pod, PodContainerName)
6757
}
6858

6959
return r
@@ -79,25 +69,6 @@ func (r *FakeCartridge) WithPodsRunning(names ...string) *FakeCartridge {
7969
_, ok := namesMap[pod.GetName()]
8070
if ok {
8171
r.setPodRunning(pod)
82-
r.setPodContainerReady(pod, PodContainerName)
83-
}
84-
}
85-
86-
return r
87-
}
88-
89-
func (r *FakeCartridge) WithPodsReady(names ...string) *FakeCartridge {
90-
namesMap := make(map[string]bool, len(names))
91-
for _, name := range names {
92-
namesMap[name] = true
93-
}
94-
95-
for _, pod := range r.Pods {
96-
_, ok := namesMap[pod.GetName()]
97-
if ok {
98-
r.setPodRunning(pod)
99-
r.setPodReady(pod)
100-
r.setPodContainerReady(pod, PodContainerName)
10172
}
10273
}
10374

@@ -107,7 +78,6 @@ func (r *FakeCartridge) WithPodsReady(names ...string) *FakeCartridge {
10778
func (r *FakeCartridge) WithAllPodsDeleting() *FakeCartridge {
10879
for _, pod := range r.Pods {
10980
r.setPodDeleting(pod)
110-
r.setPodContainerReady(pod, PodContainerName)
11181
}
11282

11383
return r
@@ -117,38 +87,7 @@ func (r *FakeCartridge) setPodRunning(pod *v1.Pod) {
11787
pod.Status.Phase = v1.PodRunning
11888
}
11989

120-
func (r *FakeCartridge) setPodReady(pod *v1.Pod) {
121-
if pod.Status.Conditions == nil {
122-
pod.Status.Conditions = []v1.PodCondition{}
123-
}
124-
125-
pod.Status.Conditions = append(pod.Status.Conditions, v1.PodCondition{
126-
Type: v1.PodReady,
127-
Status: v1.ConditionTrue,
128-
Reason: "Ready",
129-
Message: "Ready",
130-
})
131-
}
132-
13390
func (r *FakeCartridge) setPodDeleting(pod *v1.Pod) {
13491
now := metav1.Now()
13592
pod.DeletionTimestamp = &now
13693
}
137-
138-
//nolint:unparam
139-
func (r *FakeCartridge) setPodContainerReady(pod *v1.Pod, containerName string) {
140-
if pod.Status.ContainerStatuses == nil {
141-
pod.Status.ContainerStatuses = []v1.ContainerStatus{}
142-
}
143-
144-
started := true
145-
146-
pod.Status.ContainerStatuses = append(
147-
pod.Status.ContainerStatuses,
148-
v1.ContainerStatus{
149-
Name: containerName,
150-
Ready: true,
151-
Started: &started,
152-
},
153-
)
154-
}

0 commit comments

Comments
 (0)