Skip to content

Commit

Permalink
ignore patch
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Jul 12, 2024
1 parent 2ebaaeb commit fa0e6f0
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 357 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ require (
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rs/xid v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/vishvananda/netlink v0.0.0-20210530105856-14e832ae1e8f // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUq
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand Down
70 changes: 0 additions & 70 deletions pkg/cluster/operation/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import (
"crypto/tls"
"fmt"
"os"
"path/filepath"
"reflect"
"strings"
"time"

perrs "github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/checkpoint"
"github.com/pingcap/tiup/pkg/cluster/api"
"github.com/pingcap/tiup/pkg/cluster/ctxt"
"github.com/pingcap/tiup/pkg/cluster/spec"
logprinter "github.com/pingcap/tiup/pkg/logger/printer"
"github.com/pingcap/tiup/pkg/set"
Expand Down Expand Up @@ -146,52 +144,6 @@ func Upgrade(
logger.Debugf("Deferred upgrading of PD leader %s", instance.ID())
continue
}
case spec.ComponentTSO:
// if component version is not specified, use the cluster version or latest("")
ins := instance.(*spec.TSOInstance)
version, err := getVersion(ctx, ins.DeployDir(), ins.GetManageHost())
if err != nil {
return err
}
logger.Infof(fmt.Sprintf("tso instance change startScript %s, %s", version, ins.Name))
if tidbver.PDSupportMicroServicesWithName(version) && ins.Name != "" {
tsos := topo.(*spec.Specification).TSOServers
var name string
for _, s := range tsos {
if s.Host == ins.Host && s.Port == ins.Port {
name = s.Name
break
}
}
logger.Infof(fmt.Sprintf("tso instance change startScript %s", name))
ins := instance.(*spec.TSOInstance)
err := spec.ModifyPDStartScriptPath(ctx, ins.Role(), ins.Host, ins.GetMainPort(), name)
if err != nil {
return err
}
}
case spec.ComponentScheduling:
ins := instance.(*spec.SchedulingInstance)
version, err := getVersion(ctx, ins.DeployDir(), ins.GetManageHost())
if err != nil {
return err
}
logger.Infof(fmt.Sprintf("scheduling instance change startScript %s, %s", version, ins.Name))
if tidbver.PDSupportMicroServicesWithName(version) && ins.Name != "" {
schedulings := topo.(*spec.Specification).SchedulingServers
var name string
for _, s := range schedulings {
if s.Host == ins.Host && s.Port == ins.Port {
name = s.Name
break
}
}
logger.Infof(fmt.Sprintf("scheduling instance change startScript %s", name))
err := spec.ModifyPDStartScriptPath(ctx, ins.Role(), ins.Host, ins.GetMainPort(), name)
if err != nil {
return err
}
}
case spec.ComponentCDC:
ins := instance.(*spec.CDCInstance)
address := ins.GetAddr()
Expand Down Expand Up @@ -410,25 +362,3 @@ func decreaseScheduleLimit(pc *api.PDClient, origLeaderScheduleLimit, origRegion
}
return pc.SetReplicationConfig("region-schedule-limit", origRegionScheduleLimit)
}

func getVersion(ctx context.Context, deployDir, host string) (string, error) {
binPath := filepath.Join(deployDir, "bin/pd-server")
e, found := ctxt.GetInner(ctx).GetExecutor(host)
if !found {
return "", fmt.Errorf("no executor")
}
stdout, stderr, err := e.Execute(ctx, binPath+" --version", false)
if err != nil {
return "", perrs.Annotatef(err, "stderr: %s", string(stderr))
}

var version string
for _, line := range strings.Split(string(stdout), "\n") {
if strings.HasPrefix(line, "Release Version:") {
// Extract version number from the line
version = strings.TrimSpace(strings.TrimPrefix(line, "Release Version:"))
break
}
}
return version, nil
}
74 changes: 0 additions & 74 deletions pkg/cluster/operation/upgrade_test.go

This file was deleted.

81 changes: 0 additions & 81 deletions pkg/cluster/spec/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"strings"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/cluster/ctxt"
"github.com/pingcap/tiup/pkg/utils"
"github.com/pingcap/tiup/pkg/version"
"github.com/prometheus/common/expfmt"
Expand Down Expand Up @@ -233,82 +231,3 @@ func GetDMMasterPackageName(topo Topology) string {
}
return ComponentDMMaster
}

var systemdUnitPath = "/etc/systemd/system"

// ModifyPDStartScriptPath modify the start *PD* script path to add `--name` flag
func ModifyPDStartScriptPath(ctx context.Context, component, host string, port int, name string) error {
e, found := ctxt.GetInner(ctx).GetExecutor(host)
if !found {
return fmt.Errorf("no executor")
}
// 1. find the script path
serviceFile := fmt.Sprintf("%s/%s-%d.service",
systemdUnitPath,
component,
port)
cmd := fmt.Sprintf("grep 'ExecStart' %s | sed 's/ExecStart=//'", serviceFile)
stdout, stderr, err := e.Execute(ctx, cmd, false)
if err != nil {
return err
}
if len(stderr) > 0 {
return errors.Errorf(
"can not detect dir paths of %s %s:%d, %s",
component,
host,
port,
stderr,
)
}
// 2. check script content if contains `name`
path := extractScriptPath(string(stdout))
cmd = fmt.Sprintf("cat %s", path)
stdout, stderr, err = e.Execute(ctx, cmd, false)
if err != nil {
return err
}
if len(stderr) > 0 {
return errors.Errorf(
"can not read script path of %s %s:%d, %s",
component,
host,
port,
stderr,
)
}

if strings.Contains(string(stdout), "name") {
return nil
}

// 3. writing the name to the script
content := fmt.Sprintf(" \\\n --name='%s'", name)
cmd = fmt.Sprintf("sed -i '$ s|$| %s|' %s", content, path)
stdout, stderr, err = e.Execute(ctx, cmd, false)
if err != nil {
return err
}
if len(stderr) > 0 {
return errors.Errorf(
"can not modify script path of %s %s:%d, %s",
component,
host,
port,
stderr,
)
}

return nil
}

// path like `/bin/bash -c '/root/tidb-deploy/scheduling-3399/scripts/run_scheduling.sh'\n`
func extractScriptPath(command string) string {
command = strings.TrimSuffix(command, "\n")
parts := strings.Split(command, " ")
if len(parts) < 3 {
return "Invalid command structure"
}

return strings.Trim(parts[2], "'")
}
Loading

0 comments on commit fa0e6f0

Please sign in to comment.