Skip to content

Commit

Permalink
style(v2alpha2): rename currentVersion to currentRevision
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory-Z committed Jun 26, 2023
1 parent 220fae2 commit bc79c26
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
10 changes: 5 additions & 5 deletions apis/apps/v2alpha2/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ type EMQXStatus struct {

type EMQXNodesStatus struct {
// EMQX nodes info
Nodes []EMQXNode `json:"nodes,omitempty"`
Replicas int32 `json:"replicas,omitempty"`
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
CurrentVersion string `json:"currentVersion,omitempty"`
CollisionCount *int32 `json:"collisionCount,omitempty"`
Nodes []EMQXNode `json:"nodes,omitempty"`
Replicas int32 `json:"replicas,omitempty"`
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
CurrentRevision string `json:"currentRevision,omitempty"`
CollisionCount *int32 `json:"collisionCount,omitempty"`
}

type EMQXNode struct {
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/apps.emqx.io_emqxes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12872,7 +12872,7 @@ spec:
collisionCount:
format: int32
type: integer
currentVersion:
currentRevision:
type: string
nodes:
items:
Expand Down Expand Up @@ -12906,7 +12906,7 @@ spec:
collisionCount:
format: int32
type: integer
currentVersion:
currentRevision:
type: string
nodes:
items:
Expand Down
6 changes: 3 additions & 3 deletions controllers/apps/v2alpha2/add_emqx_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (a *addCore) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _
}
}

if instance.Status.CoreNodesStatus.CurrentVersion != sts.Labels[appsv1.DefaultDeploymentUniqueLabelKey] {
instance.Status.CoreNodesStatus.CurrentVersion = sts.Labels[appsv1.DefaultDeploymentUniqueLabelKey]
if instance.Status.CoreNodesStatus.CurrentRevision != sts.Labels[appsv1.DefaultDeploymentUniqueLabelKey] {
instance.Status.CoreNodesStatus.CurrentRevision = sts.Labels[appsv1.DefaultDeploymentUniqueLabelKey]
_ = a.Client.Status().Update(ctx, instance)
}

Expand All @@ -63,7 +63,7 @@ func (a *addCore) getNewStatefulSet(ctx context.Context, instance *appsv2alpha2.
client.MatchingLabels(appsv2alpha2.CloneAndAddLabel(
instance.Spec.CoreTemplate.Labels,
appsv1.DefaultDeploymentUniqueLabelKey,
instance.Status.CoreNodesStatus.CurrentVersion,
instance.Status.CoreNodesStatus.CurrentRevision,
)),
)
if len(list.Items) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions controllers/apps/v2alpha2/add_emqx_core_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() {
)
return list.Items
}).Should(HaveLen(1))
instance.Status.CoreNodesStatus.CurrentVersion = list.Items[0].Labels[appsv1.DefaultDeploymentUniqueLabelKey]
instance.Status.CoreNodesStatus.CurrentRevision = list.Items[0].Labels[appsv1.DefaultDeploymentUniqueLabelKey]

instance.Spec.CoreTemplate.Spec.Replicas = pointer.Int32(4)
})
Expand Down Expand Up @@ -131,7 +131,7 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() {

//Sync the "change image" test case.
instance.Spec.Image = new.Spec.Template.Spec.Containers[0].Image
instance.Status.CoreNodesStatus.CurrentVersion = new.Labels[appsv1.DefaultDeploymentUniqueLabelKey]
instance.Status.CoreNodesStatus.CurrentRevision = new.Labels[appsv1.DefaultDeploymentUniqueLabelKey]
instance.Status.Conditions = []metav1.Condition{
{
Type: appsv2alpha2.Ready,
Expand Down
6 changes: 3 additions & 3 deletions controllers/apps/v2alpha2/add_emqx_repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (a *addRepl) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _
}
}

if instance.Status.ReplicantNodesStatus.CurrentVersion != rs.Labels[appsv1.DefaultDeploymentUniqueLabelKey] {
instance.Status.ReplicantNodesStatus.CurrentVersion = rs.Labels[appsv1.DefaultDeploymentUniqueLabelKey]
if instance.Status.ReplicantNodesStatus.CurrentRevision != rs.Labels[appsv1.DefaultDeploymentUniqueLabelKey] {
instance.Status.ReplicantNodesStatus.CurrentRevision = rs.Labels[appsv1.DefaultDeploymentUniqueLabelKey]
_ = a.Client.Status().Update(ctx, instance)
}

Expand All @@ -70,7 +70,7 @@ func (a *addRepl) getNewReplicaSet(ctx context.Context, instance *appsv2alpha2.E
client.MatchingLabels(appsv2alpha2.CloneAndAddLabel(
instance.Spec.ReplicantTemplate.Labels,
appsv1.DefaultDeploymentUniqueLabelKey,
instance.Status.ReplicantNodesStatus.CurrentVersion,
instance.Status.ReplicantNodesStatus.CurrentRevision,
)),
)
if len(list.Items) > 0 {
Expand Down
6 changes: 3 additions & 3 deletions controllers/apps/v2alpha2/add_emqx_repl_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() {
)
return list.Items
}).Should(HaveLen(1))
instance.Status.ReplicantNodesStatus.CurrentVersion = list.Items[0].Labels[appsv1.DefaultDeploymentUniqueLabelKey]
instance.Status.ReplicantNodesStatus.CurrentRevision = list.Items[0].Labels[appsv1.DefaultDeploymentUniqueLabelKey]

instance.Spec.ReplicantTemplate.Spec.Replicas = pointer.Int32(0)
})
Expand Down Expand Up @@ -156,7 +156,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() {
)
return list.Items
}).Should(HaveLen(1))
instance.Status.ReplicantNodesStatus.CurrentVersion = list.Items[0].Labels[appsv1.DefaultDeploymentUniqueLabelKey]
instance.Status.ReplicantNodesStatus.CurrentRevision = list.Items[0].Labels[appsv1.DefaultDeploymentUniqueLabelKey]

instance.Spec.ReplicantTemplate.Spec.Replicas = pointer.Int32(4)
})
Expand Down Expand Up @@ -218,7 +218,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() {

//Sync the "change image" test case.
instance.Spec.Image = new.Spec.Template.Spec.Containers[0].Image
instance.Status.ReplicantNodesStatus.CurrentVersion = new.Labels[appsv1.DefaultDeploymentUniqueLabelKey]
instance.Status.ReplicantNodesStatus.CurrentRevision = new.Labels[appsv1.DefaultDeploymentUniqueLabelKey]

instance.Spec.UpdateStrategy.InitialDelaySeconds = int32(0)
instance.Spec.UpdateStrategy.EvacuationStrategy.WaitTakeover = int32(0)
Expand Down
4 changes: 2 additions & 2 deletions controllers/apps/v2alpha2/add_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func (a *addListener) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX
}

func (a *addListener) getPodList(ctx context.Context, instance *appsv2alpha2.EMQX) []corev1.Pod {
// labels := appsv2alpha2.AddLabel(instance.Spec.CoreTemplate.Labels, appsv1.ControllerRevisionHashLabelKey, instance.Status.CoreNodesStatus.CurrentVersion)
// labels := appsv2alpha2.AddLabel(instance.Spec.CoreTemplate.Labels, appsv1.ControllerRevisionHashLabelKey, instance.Status.CoreNodesStatus.CurrentRevision)
labels := instance.Spec.CoreTemplate.Labels
if isExistReplicant(instance) {
labels = appsv2alpha2.AddLabel(instance.Spec.ReplicantTemplate.Labels, appsv1.DefaultDeploymentUniqueLabelKey, instance.Status.ReplicantNodesStatus.CurrentVersion)
labels = appsv2alpha2.AddLabel(instance.Spec.ReplicantTemplate.Labels, appsv1.DefaultDeploymentUniqueLabelKey, instance.Status.ReplicantNodesStatus.CurrentRevision)
}

podList := &corev1.PodList{}
Expand Down
4 changes: 2 additions & 2 deletions controllers/apps/v2alpha2/update_emqx_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (u *updateStatus) reconcile(ctx context.Context, instance *appsv2alpha2.EMQ
client.MatchingLabels(appsv2alpha2.CloneAndAddLabel(
instance.Spec.CoreTemplate.Labels,
appsv1.DefaultDeploymentUniqueLabelKey,
instance.Status.CoreNodesStatus.CurrentVersion,
instance.Status.CoreNodesStatus.CurrentRevision,
)),
)
if len(stsList.Items) > 0 {
Expand All @@ -61,7 +61,7 @@ func (u *updateStatus) reconcile(ctx context.Context, instance *appsv2alpha2.EMQ
client.MatchingLabels(appsv2alpha2.CloneAndAddLabel(
instance.Spec.ReplicantTemplate.Labels,
appsv1.DefaultDeploymentUniqueLabelKey,
instance.Status.ReplicantNodesStatus.CurrentVersion,
instance.Status.ReplicantNodesStatus.CurrentRevision,
)),
)
if len(rsList.Items) > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12884,7 +12884,7 @@ spec:
collisionCount:
format: int32
type: integer
currentVersion:
currentRevision:
type: string
nodes:
items:
Expand Down Expand Up @@ -12918,7 +12918,7 @@ spec:
collisionCount:
format: int32
type: integer
currentVersion:
currentRevision:
type: string
nodes:
items:
Expand Down
2 changes: 1 addition & 1 deletion docs/en_US/reference/v2alpha2-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ _Appears in:_
| `nodes` _[EMQXNode](#emqxnode) array_ | EMQX nodes info |
| `replicas` _integer_ | |
| `readyReplicas` _integer_ | |
| `currentVersion` _string_ | |
| `currentRevision` _string_ | |
| `collisionCount` _integer_ | |


Expand Down
2 changes: 1 addition & 1 deletion docs/zh_CN/reference/v2alpha2-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ _Appears in:_
| `nodes` _[EMQXNode](#emqxnode) array_ | EMQX nodes info |
| `replicas` _integer_ | |
| `readyReplicas` _integer_ | |
| `currentVersion` _string_ | |
| `currentRevision` _string_ | |
| `collisionCount` _integer_ | |


Expand Down
2 changes: 1 addition & 1 deletion e2e/v2alpha2/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var _ = Describe("Base Test", func() {
client.MatchingLabels(appsv2alpha2.CloneAndAddLabel(
instance.Spec.CoreTemplate.Labels,
appsv1.DefaultDeploymentUniqueLabelKey,
instance.Status.CoreNodesStatus.CurrentVersion,
instance.Status.CoreNodesStatus.CurrentRevision,
)),
)
return list.Items
Expand Down

0 comments on commit bc79c26

Please sign in to comment.