Skip to content

Commit

Permalink
Revert "feat: redis-cluster add TopologySpreadConstraints"
Browse files Browse the repository at this point in the history
This reverts commit de22a21.
  • Loading branch information
xiaozhuang committed Dec 18, 2024
1 parent de22a21 commit 82df9bc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 52 deletions.
34 changes: 16 additions & 18 deletions api/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,27 @@ type Sidecar struct {
// RedisLeader interface will have the redis leader configuration
// +k8s:deepcopy-gen=true
type RedisLeader struct {
Replicas *int32 `json:"replicas,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
PodDisruptionBudget *RedisPodDisruptionBudget `json:"pdb,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty" protobuf:"bytes,12,opt,name=livenessProbe"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
PodDisruptionBudget *RedisPodDisruptionBudget `json:"pdb,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty" protobuf:"bytes,12,opt,name=livenessProbe"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// RedisFollower interface will have the redis follower configuration
// +k8s:deepcopy-gen=true
type RedisFollower struct {
Replicas *int32 `json:"replicas,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
PodDisruptionBudget *RedisPodDisruptionBudget `json:"pdb,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty" protobuf:"bytes,12,opt,name=livenessProbe"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
RedisConfig *RedisConfig `json:"redisConfig,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
PodDisruptionBudget *RedisPodDisruptionBudget `json:"pdb,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty" protobuf:"bytes,12,opt,name=livenessProbe"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// RedisPodDisruptionBudget configure a PodDisruptionBudget on the resource (leader/follower)
Expand Down
12 changes: 0 additions & 12 deletions api/v1beta1/rediscluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ func (src *RedisCluster) ConvertTo(dstRaw conversion.Hub) error {
if src.Spec.RedisLeader.NodeSelector != nil {
dst.Spec.RedisLeader.NodeSelector = src.Spec.RedisLeader.NodeSelector
}
if src.Spec.RedisLeader.TopologySpreadConstraints != nil {
dst.Spec.RedisLeader.TopologySpreadConstraints = src.Spec.RedisLeader.TopologySpreadConstraints
}

// RedisFollower
dst.Spec.RedisFollower = redisv1beta2.RedisFollower{}
Expand Down Expand Up @@ -78,9 +75,6 @@ func (src *RedisCluster) ConvertTo(dstRaw conversion.Hub) error {
if src.Spec.RedisFollower.NodeSelector != nil {
dst.Spec.RedisFollower.NodeSelector = src.Spec.RedisFollower.NodeSelector
}
if src.Spec.RedisFollower.TopologySpreadConstraints != nil {
dst.Spec.RedisFollower.TopologySpreadConstraints = src.Spec.RedisFollower.TopologySpreadConstraints
}
// RedisExporter
if src.Spec.RedisExporter != nil {
dst.Spec.RedisExporter = &redisv1beta2.RedisExporter{}
Expand Down Expand Up @@ -174,9 +168,6 @@ func (dst *RedisCluster) ConvertFrom(srcRaw conversion.Hub) error {
if src.Spec.RedisLeader.NodeSelector != nil {
dst.Spec.RedisLeader.NodeSelector = src.Spec.RedisLeader.NodeSelector
}
if src.Spec.RedisLeader.TopologySpreadConstraints != nil {
dst.Spec.RedisLeader.TopologySpreadConstraints = src.Spec.RedisLeader.TopologySpreadConstraints
}

// RedisFollower
dst.Spec.RedisFollower = RedisFollower{}
Expand Down Expand Up @@ -204,9 +195,6 @@ func (dst *RedisCluster) ConvertFrom(srcRaw conversion.Hub) error {
if src.Spec.RedisFollower.NodeSelector != nil {
dst.Spec.RedisFollower.NodeSelector = src.Spec.RedisFollower.NodeSelector
}
if src.Spec.RedisFollower.TopologySpreadConstraints != nil {
dst.Spec.RedisFollower.TopologySpreadConstraints = src.Spec.RedisFollower.TopologySpreadConstraints
}
// RedisExporter
if src.Spec.RedisExporter != nil {
dst.Spec.RedisExporter = &RedisExporter{}
Expand Down
14 changes: 0 additions & 14 deletions api/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions pkg/k8sutils/redis-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type RedisClusterSTS struct {
ReadinessProbe *corev1.Probe
LivenessProbe *corev1.Probe
NodeSelector map[string]string
TopologySpreadConstraints []corev1.TopologySpreadConstraint
Tolerations *[]corev1.Toleration
}

Expand Down Expand Up @@ -220,11 +219,9 @@ func CreateRedisLeader(ctx context.Context, cr *redisv1beta2.RedisCluster, cl ku
Affinity: cr.Spec.RedisLeader.Affinity,
TerminationGracePeriodSeconds: cr.Spec.RedisLeader.TerminationGracePeriodSeconds,
NodeSelector: cr.Spec.RedisLeader.NodeSelector,
TopologySpreadConstraints: cr.Spec.RedisLeader.TopologySpreadConstraints,

Tolerations: cr.Spec.RedisLeader.Tolerations,
ReadinessProbe: cr.Spec.RedisLeader.ReadinessProbe,
LivenessProbe: cr.Spec.RedisLeader.LivenessProbe,
Tolerations: cr.Spec.RedisLeader.Tolerations,
ReadinessProbe: cr.Spec.RedisLeader.ReadinessProbe,
LivenessProbe: cr.Spec.RedisLeader.LivenessProbe,
}
if cr.Spec.RedisLeader.RedisConfig != nil {
prop.ExternalConfig = cr.Spec.RedisLeader.RedisConfig.AdditionalRedisConfig
Expand Down
2 changes: 0 additions & 2 deletions pkg/k8sutils/redis-cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ func Test_generateRedisClusterParams(t *testing.T) {
ReadinessProbe: input.Spec.RedisLeader.ReadinessProbe,
LivenessProbe: input.Spec.RedisLeader.LivenessProbe,
NodeSelector: input.Spec.RedisLeader.NodeSelector,
TopologySpreadConstraints: input.Spec.RedisLeader.TopologySpreadConstraints,
Tolerations: input.Spec.RedisLeader.Tolerations,
})
assert.EqualValues(t, expectedLeaderSTS, actualLeaderSTS, "Expected %+v, got %+v", expectedLeaderSTS, actualLeaderSTS)
Expand All @@ -188,7 +187,6 @@ func Test_generateRedisClusterParams(t *testing.T) {
ReadinessProbe: input.Spec.RedisFollower.ReadinessProbe,
LivenessProbe: input.Spec.RedisFollower.LivenessProbe,
NodeSelector: input.Spec.RedisFollower.NodeSelector,
TopologySpreadConstraints: input.Spec.RedisFollower.TopologySpreadConstraints,
Tolerations: input.Spec.RedisFollower.Tolerations,
})
assert.EqualValues(t, expectedFollowerSTS, actualFollowerSTS, "Expected %+v, got %+v", expectedFollowerSTS, actualFollowerSTS)
Expand Down

0 comments on commit 82df9bc

Please sign in to comment.