Skip to content

Commit

Permalink
Merge 05a3fcb into b11f1c4
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored Aug 10, 2022
2 parents b11f1c4 + 05a3fcb commit df59272
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions pkg/cluster/task/update_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
deleted := set.NewStringSet(u.deletedNodeIDs...)
topo := u.metadata.Topology

newMeta := &spec.ClusterMeta{}
*newMeta = *u.metadata
newMeta.Topology = &spec.Specification{
GlobalOptions: u.metadata.Topology.GlobalOptions,
MonitoredOptions: u.metadata.Topology.MonitoredOptions,
ServerConfigs: u.metadata.Topology.ServerConfigs,
}

tidbServers := make([]*spec.TiDBSpec, 0)
for i, instance := range (&spec.TiDBComponent{Topology: topo}).Instances() {
if deleted.Exist(instance.ID()) {
continue
}
tidbServers = append(tidbServers, topo.TiDBServers[i])
}
topo.TiDBServers = tidbServers
newMeta.Topology.TiDBServers = tidbServers

tikvServers := make([]*spec.TiKVSpec, 0)
for i, instance := range (&spec.TiKVComponent{Topology: topo}).Instances() {
Expand All @@ -53,7 +61,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
tikvServers = append(tikvServers, topo.TiKVServers[i])
}
topo.TiKVServers = tikvServers
newMeta.Topology.TiKVServers = tikvServers

pdServers := make([]*spec.PDSpec, 0)
for i, instance := range (&spec.PDComponent{Topology: topo}).Instances() {
Expand All @@ -62,7 +70,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
pdServers = append(pdServers, topo.PDServers[i])
}
topo.PDServers = pdServers
newMeta.Topology.PDServers = pdServers

tiflashServers := make([]*spec.TiFlashSpec, 0)
for i, instance := range (&spec.TiFlashComponent{Topology: topo}).Instances() {
Expand All @@ -71,7 +79,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
tiflashServers = append(tiflashServers, topo.TiFlashServers[i])
}
topo.TiFlashServers = tiflashServers
newMeta.Topology.TiFlashServers = tiflashServers

pumpServers := make([]*spec.PumpSpec, 0)
for i, instance := range (&spec.PumpComponent{Topology: topo}).Instances() {
Expand All @@ -80,7 +88,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
pumpServers = append(pumpServers, topo.PumpServers[i])
}
topo.PumpServers = pumpServers
newMeta.Topology.PumpServers = pumpServers

drainerServers := make([]*spec.DrainerSpec, 0)
for i, instance := range (&spec.DrainerComponent{Topology: topo}).Instances() {
Expand All @@ -89,7 +97,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
drainerServers = append(drainerServers, topo.Drainers[i])
}
topo.Drainers = drainerServers
newMeta.Topology.Drainers = drainerServers

cdcServers := make([]*spec.CDCSpec, 0)
for i, instance := range (&spec.CDCComponent{Topology: topo}).Instances() {
Expand All @@ -98,7 +106,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
cdcServers = append(cdcServers, topo.CDCServers[i])
}
topo.CDCServers = cdcServers
newMeta.Topology.CDCServers = cdcServers

tisparkWorkers := make([]*spec.TiSparkWorkerSpec, 0)
for i, instance := range (&spec.TiSparkWorkerComponent{Topology: topo}).Instances() {
Expand All @@ -107,7 +115,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
tisparkWorkers = append(tisparkWorkers, topo.TiSparkWorkers[i])
}
topo.TiSparkWorkers = tisparkWorkers
newMeta.Topology.TiSparkWorkers = tisparkWorkers

tisparkMasters := make([]*spec.TiSparkMasterSpec, 0)
for i, instance := range (&spec.TiSparkMasterComponent{Topology: topo}).Instances() {
Expand All @@ -116,7 +124,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
tisparkMasters = append(tisparkMasters, topo.TiSparkMasters[i])
}
topo.TiSparkMasters = tisparkMasters
newMeta.Topology.TiSparkMasters = tisparkMasters

monitors := make([]*spec.PrometheusSpec, 0)
for i, instance := range (&spec.MonitorComponent{Topology: topo}).Instances() {
Expand All @@ -125,7 +133,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
monitors = append(monitors, topo.Monitors[i])
}
topo.Monitors = monitors
newMeta.Topology.Monitors = monitors

grafanas := make([]*spec.GrafanaSpec, 0)
for i, instance := range (&spec.GrafanaComponent{Topology: topo}).Instances() {
Expand All @@ -134,7 +142,7 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
grafanas = append(grafanas, topo.Grafanas[i])
}
topo.Grafanas = grafanas
newMeta.Topology.Grafanas = grafanas

alertmanagers := make([]*spec.AlertmanagerSpec, 0)
for i, instance := range (&spec.AlertManagerComponent{Topology: topo}).Instances() {
Expand All @@ -143,9 +151,9 @@ func (u *UpdateMeta) Execute(ctx context.Context) error {
}
alertmanagers = append(alertmanagers, topo.Alertmanagers[i])
}
topo.Alertmanagers = alertmanagers
newMeta.Topology.Alertmanagers = alertmanagers

return spec.SaveClusterMeta(u.cluster, u.metadata)
return spec.SaveClusterMeta(u.cluster, newMeta)
}

// Rollback implements the Task interface
Expand Down

0 comments on commit df59272

Please sign in to comment.