Skip to content

Commit

Permalink
chore: modify handleRoleChange DAG update to patch (#4559)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5974078)
  • Loading branch information
Y-Rookie committed Aug 1, 2023
1 parent a7a40e9 commit 7d22af2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions controllers/apps/components/replication_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ func (r *replicationSet) HandleRoleChange(ctx context.Context, obj client.Object
needUpdate = handlePrimaryNotExistPod(pod)
default:
if len(primaryPods) != 1 {
return nil, errors.New(fmt.Sprintf("the number of primary pod is not equal to 1, primary pod: %v", primaryPods))
return nil, errors.New(fmt.Sprintf("the number of primary pod is not equal to 1, primary pods: %v, emptyRole pods: %v", primaryPods, emptyRolePods))
}
needUpdate = handlePrimaryExistPod(pod, primaryPods[0])
}
if needUpdate {
vertexes = append(vertexes, &ictrltypes.LifecycleVertex{
Obj: pod,
Action: ictrltypes.ActionUpdatePtr(),
Action: ictrltypes.ActionPatchPtr(),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/apps/components/replication_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ var _ = Describe("Replication Component", func() {
vertexes, err = replicationComponent.HandleRoleChange(ctx, replicationSetSts)
Expect(err).To(Succeed())
Expect(len(vertexes)).To(Equal(int(replicas)))
Expect(*vertexes[0].(*ictrltypes.LifecycleVertex).Action == ictrltypes.UPDATE).To(BeTrue())
Expect(*vertexes[0].(*ictrltypes.LifecycleVertex).Action == ictrltypes.PATCH).To(BeTrue())

By("Test handleRoleChange when statefulSet h-scale out a new Pod with no role label")
status.Replicas = 3
Expand All @@ -276,7 +276,7 @@ var _ = Describe("Replication Component", func() {
vertexes, err = replicationComponent.HandleRoleChange(ctx, replicationSetSts)
Expect(err).To(Succeed())
Expect(len(vertexes)).To(Equal(3))
Expect(*vertexes[0].(*ictrltypes.LifecycleVertex).Action == ictrltypes.UPDATE).To(BeTrue())
Expect(*vertexes[0].(*ictrltypes.LifecycleVertex).Action == ictrltypes.PATCH).To(BeTrue())
})
})
})

0 comments on commit 7d22af2

Please sign in to comment.