Skip to content

Commit

Permalink
Issue 620: Fix for pravega image upgrade failure (#621)
Browse files Browse the repository at this point in the history
* Issue 620: Fix for pravega image upgrade failure

Signed-off-by: anishakj <[email protected]>

* Changing cluster location to da11

Signed-off-by: anishakj <[email protected]>

* Updated zookeeper CRD for tests

Signed-off-by: anishakj <[email protected]>

* Keeping the cluster for debugging

Signed-off-by: anishakj <[email protected]>

* Deleting cluster at the end of tests

Signed-off-by: anishakj <[email protected]>
  • Loading branch information
anishakj authored May 11, 2022
1 parent b7921a0 commit 39afe04
Show file tree
Hide file tree
Showing 4 changed files with 835 additions and 208 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ jobs:
- name: Creating nodes
run: |
cd .. && tar -czvf pravega-operator.tar.gz pravega-operator
packet-cli device create -H $CLUSTER_NAME"-master" -o "ubuntu_20_04" -P c1.small.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f ams1
packet-cli device create -H $CLUSTER_NAME"-master" -o "ubuntu_20_04" -P c3.small.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11
packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $2}'
CLUSTER_ID=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $2}' | tr -d ' ')
echo "cluster id is $CLUSTER_ID"
packet-cli device create -H $CLUSTER_NAME"-worker1" -o "ubuntu_20_04" -P c1.small.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f ams1
packet-cli device create -H $CLUSTER_NAME"-worker2" -o "ubuntu_20_04" -P c1.small.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f ams1
packet-cli device create -H $CLUSTER_NAME"-worker1" -o "ubuntu_20_04" -P c3.small.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11
packet-cli device create -H $CLUSTER_NAME"-worker2" -o "ubuntu_20_04" -P c3.small.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11
MASTER_STATE=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $10}' | tr -d ' ')
while [ "$MASTER_STATE" != "active" ]; do MASTER_STATE=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $10}' | tr -d ' '`;sleep 30;done
CLUSTER_IP=$(packet-cli device get -i $CLUSTER_ID -y | grep "\- address:" | head -1 |awk '{print $3}' | tr -d ' ')
Expand Down
7 changes: 4 additions & 3 deletions controllers/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ func (r *PravegaClusterReconciler) syncSegmentStoreVersion(p *pravegav1beta1.Pra
}

if ready {
pod, err := r.getOneOutdatedPod(sts, p.Status.TargetVersion)
labels := p.LabelsForPravegaCluster()
pod, err := r.getOneOutdatedPod(sts, p.Status.TargetVersion, labels)
if err != nil {
return false, err
}
Expand Down Expand Up @@ -652,9 +653,9 @@ func (r *PravegaClusterReconciler) checkUpdatedPods(pods []*corev1.Pod, version
return true, nil
}

func (r *PravegaClusterReconciler) getOneOutdatedPod(sts *appsv1.StatefulSet, version string) (*corev1.Pod, error) {
func (r *PravegaClusterReconciler) getOneOutdatedPod(sts *appsv1.StatefulSet, version string, labels map[string]string) (*corev1.Pod, error) {
selector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
MatchLabels: sts.Spec.Template.Labels,
MatchLabels: labels,
})
if err != nil {
return nil, fmt.Errorf("failed to convert label selector: %v", err)
Expand Down
4 changes: 3 additions & 1 deletion controllers/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,9 @@ var _ = Describe("Pravega Cluster Version Sync", func() {
BeforeEach(func() {
sts = &appsv1.StatefulSet{}
r.Client.Get(context.TODO(), types.NamespacedName{Name: p.StatefulSetNameForSegmentstore(), Namespace: p.Namespace}, sts)
_, err = r.getOneOutdatedPod(sts, "0.6.1")
labels := make(map[string]string)
labels["component"] = "pravega"
_, err = r.getOneOutdatedPod(sts, "0.6.1", labels)
})
It("Error should be nil", func() {
Ω(err).Should(BeNil())
Expand Down
Loading

0 comments on commit 39afe04

Please sign in to comment.