Skip to content

Commit

Permalink
fix: cluster conversion NPE (#8308)
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf authored Oct 22, 2024
1 parent 7cc59d0 commit cdd2d01
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions apis/apps/v1alpha1/cluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,27 @@ func (c *clusterConverter) fromCluster(cluster *Cluster) {
Monitor: spec.Monitor,
}
}
for _, comp := range cluster.Spec.ComponentSpecs {
c.Spec.Components[comp.Name] = deletedComp(comp)
if len(cluster.Spec.ComponentSpecs) > 0 {
c.Spec.Components = make(map[string]clusterCompConverter)
for _, comp := range cluster.Spec.ComponentSpecs {
c.Spec.Components[comp.Name] = deletedComp(comp)
}
}
for _, sharding := range cluster.Spec.ShardingSpecs {
c.Spec.Shardings[sharding.Name] = deletedComp(sharding.Template)
if len(cluster.Spec.ShardingSpecs) > 0 {
c.Spec.Shardings = make(map[string]clusterCompConverter)
for _, sharding := range cluster.Spec.ShardingSpecs {
c.Spec.Shardings[sharding.Name] = deletedComp(sharding.Template)
}
}

for name, status := range cluster.Status.Components {
c.Status.Components[name] = clusterCompStatusConverter{
PodsReady: status.PodsReady,
PodsReadyTime: status.PodsReadyTime,
MembersStatus: status.MembersStatus,
if len(cluster.Status.Components) > 0 {
c.Status.Components = make(map[string]clusterCompStatusConverter)
for name, status := range cluster.Status.Components {
c.Status.Components[name] = clusterCompStatusConverter{
PodsReady: status.PodsReady,
PodsReadyTime: status.PodsReadyTime,
MembersStatus: status.MembersStatus,
}
}
}
}
Expand Down

0 comments on commit cdd2d01

Please sign in to comment.