From e79894348a35015e527daaafb01e5cc0a3345e7c Mon Sep 17 00:00:00 2001 From: djshow832 Date: Tue, 13 Aug 2024 15:40:40 +0800 Subject: [PATCH 1/7] fix component_versions --- pkg/cluster/manager/builder.go | 15 ++++++++++++++- pkg/cluster/manager/deploy.go | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/manager/builder.go b/pkg/cluster/manager/builder.go index 94b63027c5..a928ada5ae 100644 --- a/pkg/cluster/manager/builder.go +++ b/pkg/cluster/manager/builder.go @@ -97,6 +97,11 @@ func buildScaleOutTask( base := metadata.GetBaseMeta() specManager := m.specManager + m.logger.Infof("topo component versions %v, mergedTopo component versions %v, newPart component versions %v", + topo.(*spec.Specification).ComponentVersions, + mergedTopo.(*spec.Specification).ComponentVersions, + newPart.(*spec.Specification).ComponentVersions) + tlsCfg, err := topo.TLSConfig(m.specManager.Path(name, spec.TLSCertKeyDir)) if err != nil { return nil, err @@ -117,6 +122,14 @@ func buildScaleOutTask( }) // uninitializedHosts are hosts which haven't been initialized yet uninitializedHosts := make(map[string]hostInfo) // host -> ssh-port, os, arch + + // When iterating over the newPart, the original component_versions is not passed in. + // Copy the merged component_versions to newPart. + if newSpec, ok := newPart.(*spec.Specification); ok { + if mergedSpec, ok := mergedTopo.(*spec.Specification); ok { + newSpec.ComponentVersions = mergedSpec.ComponentVersions + } + } newPart.IterInstance(func(instance spec.Instance) { host := instance.GetManageHost() if initializedHosts.Exist(host) { @@ -175,7 +188,7 @@ func buildScaleOutTask( // Download missing component downloadCompTasks = buildDownloadCompTasks( base.Version, - newPart, + mergedTopo, m.logger, gOpt, ) diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index 3b9a32b1be..7b60d178e4 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -268,6 +268,7 @@ func (m *Manager) Deploy( // Download missing component downloadCompTasks = buildDownloadCompTasks(clusterVersion, topo, m.logger, gOpt) + m.logger.Infof("component version: %v", topo.(*spec.Specification).ComponentVersions) // Deploy components to remote topo.IterInstance(func(inst spec.Instance) { version := inst.CalculateVersion(clusterVersion) From 163c5eb7561eb7ae1ee162024d5c5f59151a4a61 Mon Sep 17 00:00:00 2001 From: djshow832 Date: Tue, 13 Aug 2024 16:05:02 +0800 Subject: [PATCH 2/7] update logs --- pkg/cluster/manager/builder.go | 10 +++++----- pkg/cluster/manager/deploy.go | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/cluster/manager/builder.go b/pkg/cluster/manager/builder.go index a928ada5ae..b93ebd369a 100644 --- a/pkg/cluster/manager/builder.go +++ b/pkg/cluster/manager/builder.go @@ -97,10 +97,10 @@ func buildScaleOutTask( base := metadata.GetBaseMeta() specManager := m.specManager - m.logger.Infof("topo component versions %v, mergedTopo component versions %v, newPart component versions %v", - topo.(*spec.Specification).ComponentVersions, - mergedTopo.(*spec.Specification).ComponentVersions, - newPart.(*spec.Specification).ComponentVersions) + m.logger.Infof("topo %v, mergedTopo %v, newPart %v", + topo.(*spec.Specification), + mergedTopo.(*spec.Specification), + newPart.(*spec.Specification)) tlsCfg, err := topo.TLSConfig(m.specManager.Path(name, spec.TLSCertKeyDir)) if err != nil { @@ -188,7 +188,7 @@ func buildScaleOutTask( // Download missing component downloadCompTasks = buildDownloadCompTasks( base.Version, - mergedTopo, + newPart, m.logger, gOpt, ) diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index 7b60d178e4..3b9a32b1be 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -268,7 +268,6 @@ func (m *Manager) Deploy( // Download missing component downloadCompTasks = buildDownloadCompTasks(clusterVersion, topo, m.logger, gOpt) - m.logger.Infof("component version: %v", topo.(*spec.Specification).ComponentVersions) // Deploy components to remote topo.IterInstance(func(inst spec.Instance) { version := inst.CalculateVersion(clusterVersion) From 3669441926ec18debfce84d7ea1b72d96dd8d66c Mon Sep 17 00:00:00 2001 From: djshow832 Date: Tue, 13 Aug 2024 16:35:36 +0800 Subject: [PATCH 3/7] add more debug logs --- pkg/cluster/manager/builder.go | 8 ++++---- pkg/cluster/manager/deploy.go | 1 + pkg/cluster/spec/spec.go | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/cluster/manager/builder.go b/pkg/cluster/manager/builder.go index b93ebd369a..60626d9a61 100644 --- a/pkg/cluster/manager/builder.go +++ b/pkg/cluster/manager/builder.go @@ -97,10 +97,10 @@ func buildScaleOutTask( base := metadata.GetBaseMeta() specManager := m.specManager - m.logger.Infof("topo %v, mergedTopo %v, newPart %v", - topo.(*spec.Specification), - mergedTopo.(*spec.Specification), - newPart.(*spec.Specification)) + m.logger.Infof("topo %v\n mergedTopo %v\n newPart %v\n", + topo.(*spec.Specification).ComponentVersions, + mergedTopo.(*spec.Specification).ComponentVersions, + newPart.(*spec.Specification).ComponentVersions) tlsCfg, err := topo.TLSConfig(m.specManager.Path(name, spec.TLSCertKeyDir)) if err != nil { diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index 3b9a32b1be..b796c591b6 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -81,6 +81,7 @@ func (m *Manager) Deploy( metadata := m.specManager.NewMetadata() topo := metadata.GetTopology() + m.logger.Infof("topology, %v", topo.(*spec.Specification).ComponentVersions) if err := spec.ParseTopologyYaml(topoFile, topo); err != nil { return err diff --git a/pkg/cluster/spec/spec.go b/pkg/cluster/spec/spec.go index 99bd0e87dd..f00ae02db3 100644 --- a/pkg/cluster/spec/spec.go +++ b/pkg/cluster/spec/spec.go @@ -270,9 +270,10 @@ type UpgradableMetadata interface { // NewPart implements ScaleOutTopology interface. func (s *Specification) NewPart() Topology { return &Specification{ - GlobalOptions: s.GlobalOptions, - MonitoredOptions: s.MonitoredOptions, - ServerConfigs: s.ServerConfigs, + GlobalOptions: s.GlobalOptions, + MonitoredOptions: s.MonitoredOptions, + ServerConfigs: s.ServerConfigs, + ComponentVersions: s.ComponentVersions, } } From 33a3e548c76967b71617465c457e6aa2d3d3031d Mon Sep 17 00:00:00 2001 From: djshow832 Date: Tue, 13 Aug 2024 16:39:56 +0800 Subject: [PATCH 4/7] update log place --- pkg/cluster/manager/deploy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index b796c591b6..8a73ae4192 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -81,12 +81,13 @@ func (m *Manager) Deploy( metadata := m.specManager.NewMetadata() topo := metadata.GetTopology() - m.logger.Infof("topology, %v", topo.(*spec.Specification).ComponentVersions) if err := spec.ParseTopologyYaml(topoFile, topo); err != nil { return err } + m.logger.Infof("topology, %v", topo.(*spec.Specification).ComponentVersions) + if err := checkTiFlashWithTLS(topo, clusterVersion); err != nil { return err } From 3e3a227d45cad741adb22373d60943986ecdd5eb Mon Sep 17 00:00:00 2001 From: djshow832 Date: Tue, 13 Aug 2024 17:13:41 +0800 Subject: [PATCH 5/7] final commit --- pkg/cluster/manager/builder.go | 13 ------------- pkg/cluster/manager/deploy.go | 2 -- pkg/cluster/manager/scale_out.go | 6 ++++++ pkg/cluster/spec/spec.go | 7 +++---- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/pkg/cluster/manager/builder.go b/pkg/cluster/manager/builder.go index 60626d9a61..94b63027c5 100644 --- a/pkg/cluster/manager/builder.go +++ b/pkg/cluster/manager/builder.go @@ -97,11 +97,6 @@ func buildScaleOutTask( base := metadata.GetBaseMeta() specManager := m.specManager - m.logger.Infof("topo %v\n mergedTopo %v\n newPart %v\n", - topo.(*spec.Specification).ComponentVersions, - mergedTopo.(*spec.Specification).ComponentVersions, - newPart.(*spec.Specification).ComponentVersions) - tlsCfg, err := topo.TLSConfig(m.specManager.Path(name, spec.TLSCertKeyDir)) if err != nil { return nil, err @@ -122,14 +117,6 @@ func buildScaleOutTask( }) // uninitializedHosts are hosts which haven't been initialized yet uninitializedHosts := make(map[string]hostInfo) // host -> ssh-port, os, arch - - // When iterating over the newPart, the original component_versions is not passed in. - // Copy the merged component_versions to newPart. - if newSpec, ok := newPart.(*spec.Specification); ok { - if mergedSpec, ok := mergedTopo.(*spec.Specification); ok { - newSpec.ComponentVersions = mergedSpec.ComponentVersions - } - } newPart.IterInstance(func(instance spec.Instance) { host := instance.GetManageHost() if initializedHosts.Exist(host) { diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index 8a73ae4192..3b9a32b1be 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -86,8 +86,6 @@ func (m *Manager) Deploy( return err } - m.logger.Infof("topology, %v", topo.(*spec.Specification).ComponentVersions) - if err := checkTiFlashWithTLS(topo, clusterVersion); err != nil { return err } diff --git a/pkg/cluster/manager/scale_out.go b/pkg/cluster/manager/scale_out.go index 43c6a0ae45..8a7b5ed467 100644 --- a/pkg/cluster/manager/scale_out.go +++ b/pkg/cluster/manager/scale_out.go @@ -175,6 +175,12 @@ func (m *Manager) ScaleOut( } } } + + // newPart needs ComponentVersions but the original ComponentVersions is not passed to newPart. + // Copy the merged ComponentVersions to newPart. + if newSpec, ok := newPart.(*spec.Specification); ok { + newSpec.ComponentVersions = topo.ComponentVersions + } } if err := checkConflict(m, name, mergedTopo); err != nil { diff --git a/pkg/cluster/spec/spec.go b/pkg/cluster/spec/spec.go index f00ae02db3..99bd0e87dd 100644 --- a/pkg/cluster/spec/spec.go +++ b/pkg/cluster/spec/spec.go @@ -270,10 +270,9 @@ type UpgradableMetadata interface { // NewPart implements ScaleOutTopology interface. func (s *Specification) NewPart() Topology { return &Specification{ - GlobalOptions: s.GlobalOptions, - MonitoredOptions: s.MonitoredOptions, - ServerConfigs: s.ServerConfigs, - ComponentVersions: s.ComponentVersions, + GlobalOptions: s.GlobalOptions, + MonitoredOptions: s.MonitoredOptions, + ServerConfigs: s.ServerConfigs, } } From 1decd010d324f0371563be0b2f97c8cebb619890 Mon Sep 17 00:00:00 2001 From: djshow832 Date: Tue, 13 Aug 2024 17:56:44 +0800 Subject: [PATCH 6/7] use NewPart --- pkg/cluster/manager/scale_out.go | 6 ----- pkg/cluster/spec/parse_topology_test.go | 31 +++++++++++++++++++++++++ pkg/cluster/spec/spec.go | 7 +++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/pkg/cluster/manager/scale_out.go b/pkg/cluster/manager/scale_out.go index 8a7b5ed467..43c6a0ae45 100644 --- a/pkg/cluster/manager/scale_out.go +++ b/pkg/cluster/manager/scale_out.go @@ -175,12 +175,6 @@ func (m *Manager) ScaleOut( } } } - - // newPart needs ComponentVersions but the original ComponentVersions is not passed to newPart. - // Copy the merged ComponentVersions to newPart. - if newSpec, ok := newPart.(*spec.Specification); ok { - newSpec.ComponentVersions = topo.ComponentVersions - } } if err := checkConflict(m, name, mergedTopo); err != nil { diff --git a/pkg/cluster/spec/parse_topology_test.go b/pkg/cluster/spec/parse_topology_test.go index 51d0adfb74..4b544da329 100644 --- a/pkg/cluster/spec/parse_topology_test.go +++ b/pkg/cluster/spec/parse_topology_test.go @@ -540,6 +540,37 @@ tiflash_servers: }) } +func (s *topoSuite) TestMergeComponentVersions(c *check.C) { + // test component version overwrite + with2TempFile(` +component_versions: + tidb: v8.0.0 + tikv: v8.0.0 +tidb_servers: + - host: 172.16.5.139 +`, ` +component_versions: + tikv: v8.1.0 + pd: v8.0.0 +tidb_servers: + - host: 172.16.5.134 +`, func(base, scale string) { + baseTopo := Specification{} + c.Assert(ParseTopologyYaml(base, &baseTopo), check.IsNil) + + scaleTopo := baseTopo.NewPart() + c.Assert(ParseTopologyYaml(scale, scaleTopo), check.IsNil) + + mergedTopo := baseTopo.MergeTopo(scaleTopo) + c.Assert(mergedTopo.Validate(), check.IsNil) + + c.Assert(scaleTopo.(*Specification).ComponentVersions, check.Equals, mergedTopo.(*Specification).ComponentVersions) + c.Assert(scaleTopo.(*Specification).ComponentVersions.TiDB, check.Equals, "v8.0.0") + c.Assert(scaleTopo.(*Specification).ComponentVersions.TiKV, check.Equals, "v8.1.0") + c.Assert(scaleTopo.(*Specification).ComponentVersions.PD, check.Equals, "v8.0.0") + }) +} + func (s *topoSuite) TestFixRelativePath(c *check.C) { // base test topo := Specification{ diff --git a/pkg/cluster/spec/spec.go b/pkg/cluster/spec/spec.go index 99bd0e87dd..f00ae02db3 100644 --- a/pkg/cluster/spec/spec.go +++ b/pkg/cluster/spec/spec.go @@ -270,9 +270,10 @@ type UpgradableMetadata interface { // NewPart implements ScaleOutTopology interface. func (s *Specification) NewPart() Topology { return &Specification{ - GlobalOptions: s.GlobalOptions, - MonitoredOptions: s.MonitoredOptions, - ServerConfigs: s.ServerConfigs, + GlobalOptions: s.GlobalOptions, + MonitoredOptions: s.MonitoredOptions, + ServerConfigs: s.ServerConfigs, + ComponentVersions: s.ComponentVersions, } } From 1192c6939bda14695f777f0f0f82f14e76f73331 Mon Sep 17 00:00:00 2001 From: xhe Date: Tue, 13 Aug 2024 19:54:44 +0800 Subject: [PATCH 7/7] fix Signed-off-by: xhe --- .github/workflows/integrate-cluster-cmd.yaml | 3 +++ .github/workflows/integrate-cluster-scale.yaml | 3 +++ .github/workflows/integrate-dm.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/integrate-cluster-cmd.yaml b/.github/workflows/integrate-cluster-cmd.yaml index db14720d69..f0e8d677da 100644 --- a/.github/workflows/integrate-cluster-cmd.yaml +++ b/.github/workflows/integrate-cluster-cmd.yaml @@ -61,6 +61,9 @@ jobs: export PATH=$PATH:$GOPATH/bin make build_integration_test + - uses: KengoTODA/actions-setup-docker-compose@v1 + with: + version: '2.14.2' - name: Build the docker-compose stack working-directory: ${{ env.working-directory }} # with --dev the first run will fail for unknow reason, just retry it and will success now.. diff --git a/.github/workflows/integrate-cluster-scale.yaml b/.github/workflows/integrate-cluster-scale.yaml index 7ce19a5f37..381d27dc76 100644 --- a/.github/workflows/integrate-cluster-scale.yaml +++ b/.github/workflows/integrate-cluster-scale.yaml @@ -61,6 +61,9 @@ jobs: export PATH=$PATH:$GOPATH/bin make build_integration_test + - uses: KengoTODA/actions-setup-docker-compose@v1 + with: + version: '2.14.2' - name: Build the docker-compose stack working-directory: ${{ env.working-directory }} # with --dev the first run will fail for unknow reason, just retry it and will success now.. diff --git a/.github/workflows/integrate-dm.yaml b/.github/workflows/integrate-dm.yaml index 37ef609075..9799dc30cf 100644 --- a/.github/workflows/integrate-dm.yaml +++ b/.github/workflows/integrate-dm.yaml @@ -62,6 +62,9 @@ jobs: make build_integration_test make tiup + - uses: KengoTODA/actions-setup-docker-compose@v1 + with: + version: '2.14.2' - name: Build the docker-compose stack working-directory: ${{ env.working-directory }} # with --dev the first run will fail for unknow reason, just retry it and will success now..