diff --git a/components/cluster/command/check.go b/components/cluster/command/check.go index 0f69fe8ea1..64acea8be4 100644 --- a/components/cluster/command/check.go +++ b/components/cluster/command/check.go @@ -65,7 +65,7 @@ conflict checks with other clusters`, exist, err := tidbSpec.Exist(clusterName) if err != nil { - return perrs.AddStack(err) + return err } if !exist { diff --git a/components/cluster/command/display.go b/components/cluster/command/display.go index 4710cdb2a3..56e1b29855 100644 --- a/components/cluster/command/display.go +++ b/components/cluster/command/display.go @@ -47,7 +47,7 @@ func newDisplayCmd() *cobra.Command { exist, err := tidbSpec.Exist(clusterName) if err != nil { - return perrs.AddStack(err) + return err } if !exist { @@ -57,12 +57,12 @@ func newDisplayCmd() *cobra.Command { metadata, err := spec.ClusterMetadata(clusterName) if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) && !errors.Is(perrs.Cause(err), spec.ErrNoTiSparkMaster) { - return perrs.AddStack(err) + return err } if showDashboardOnly { tlsCfg, err := metadata.Topology.TLSConfig(tidbSpec.Path(clusterName, spec.TLSCertKeyDir)) if err != nil { - return perrs.AddStack(err) + return err } return displayDashboardInfo(clusterName, tlsCfg) } diff --git a/components/cluster/command/import.go b/components/cluster/command/import.go index abbb7a4bc6..04e5affe5a 100644 --- a/components/cluster/command/import.go +++ b/components/cluster/command/import.go @@ -19,7 +19,6 @@ import ( "path/filepath" "github.com/fatih/color" - "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/cliutil" "github.com/pingcap/tiup/pkg/cluster/ansible" "github.com/pingcap/tiup/pkg/cluster/spec" @@ -66,7 +65,7 @@ func newImportCmd() *cobra.Command { exist, err := tidbSpec.Exist(clsName) if err != nil { - return errors.AddStack(err) + return err } if exist { diff --git a/components/cluster/command/test.go b/components/cluster/command/test.go index 505d68d6d4..1ee1a6c9e5 100644 --- a/components/cluster/command/test.go +++ b/components/cluster/command/test.go @@ -43,7 +43,7 @@ func newTestCmd() *cobra.Command { exist, err := tidbSpec.Exist(clusterName) if err != nil { - return perrs.AddStack(err) + return err } if !exist { diff --git a/components/dm/ansible/import.go b/components/dm/ansible/import.go index 54cf1c5581..37202f9501 100644 --- a/components/dm/ansible/import.go +++ b/components/dm/ansible/import.go @@ -76,7 +76,7 @@ func searchConfigFile(dir string) (fname string, err error) { func readConfigFile(dir string) (file *ini.File, err error) { fname, err := searchConfigFile(dir) if err != nil { - return nil, errors.AddStack(err) + return nil, err } file, err = ini.Load(fname) @@ -205,7 +205,7 @@ func setConfig(config *map[string]interface{}, k string, v interface{}) { func (im *Importer) handleWorkerConfig(srv *spec.WorkerSpec, fname string) error { data, err := im.fetchFile(srv.Host, srv.SSHPort, fname) if err != nil { - return errors.AddStack(err) + return err } config := new(Config) @@ -255,7 +255,7 @@ func (im *Importer) ScpSourceToMaster(topo *spec.Specification) (err error) { err = e.Transfer(f.Name(), filepath.Join(target, addr+".yml"), false) if err != nil { - return errors.AddStack(err) + return err } } } @@ -278,7 +278,7 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad cfg, err := readConfigFile(dir) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } fname := filepath.Join(dir, inventoryFileName) @@ -336,11 +336,11 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_dm-master.sh") data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } deployDir, flags, err := parseRunScript(data) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } if deployDir == "" { @@ -384,11 +384,11 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_dm-worker.sh") data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } deployDir, flags, err := parseRunScript(data) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } if deployDir == "" { @@ -427,7 +427,7 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad err = im.handleWorkerConfig(&srv, configFileName) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } topo.Workers = append(topo.Workers, srv) @@ -445,12 +445,12 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_prometheus.sh") data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } deployDir, flags, err := parseRunScript(data) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } if deployDir == "" { @@ -493,12 +493,12 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_alertmanager.sh") data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } deployDir, flags, err := parseRunScript(data) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } if deployDir == "" { @@ -550,11 +550,11 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_grafana.sh") data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } _, flags, err := parseRunScript(data) if err != nil { - return "", nil, errors.AddStack(err) + return "", nil, err } for k, v := range flags { diff --git a/components/dm/command/import.go b/components/dm/command/import.go index f568ae6eae..fde52306e4 100644 --- a/components/dm/command/import.go +++ b/components/dm/command/import.go @@ -39,17 +39,17 @@ func newImportCmd() *cobra.Command { Short: "Import an exist DM 1.0 cluster from dm-ansible and re-deploy 2.0 version", RunE: func(cmd *cobra.Command, args []string) error { if err := supportVersion(clusterVersion); err != nil { - return errors.AddStack(err) + return err } importer, err := ansible.NewImporter(ansibleDir, inventoryFileName, gOpt.SSHType, gOpt.SSHTimeout) if err != nil { - return errors.AddStack(err) + return err } clusterName, meta, err := importer.ImportFromAnsibleDir() if err != nil { - return errors.AddStack(err) + return err } if rename != "" { @@ -58,7 +58,7 @@ func newImportCmd() *cobra.Command { err = importer.ScpSourceToMaster(meta.Topology) if err != nil { - return errors.AddStack(err) + return err } data, err := yaml.Marshal(meta.Topology) @@ -86,7 +86,7 @@ func newImportCmd() *cobra.Command { clusterName, )) if err != nil { - return errors.AddStack(err) + return err } } @@ -104,7 +104,7 @@ func newImportCmd() *cobra.Command { ) if err != nil { - return errors.AddStack(err) + return err } return nil diff --git a/components/dm/command/scale_in.go b/components/dm/command/scale_in.go index 0b9104e84f..9afb548296 100644 --- a/components/dm/command/scale_in.go +++ b/components/dm/command/scale_in.go @@ -143,13 +143,13 @@ func ScaleInDMCluster( name := instance.(*dm.MasterInstance).Name err := dmMasterClient.OfflineMaster(name, nil) if err != nil { - return errors.AddStack(err) + return err } case dm.ComponentDMWorker: name := instance.(*dm.WorkerInstance).Name err := dmMasterClient.OfflineWorker(name, nil) if err != nil { - return errors.AddStack(err) + return err } } diff --git a/components/playground/command.go b/components/playground/command.go index 6c7883de1c..1243e00ccc 100644 --- a/components/playground/command.go +++ b/components/playground/command.go @@ -157,7 +157,7 @@ func newDisplay() *cobra.Command { func scaleIn(pids []int) error { port, err := targetTag() if err != nil { - return errors.AddStack(err) + return err } var cmds []Command @@ -176,7 +176,7 @@ func scaleIn(pids []int) error { func scaleOut(args []string, opt *bootOptions) (num int, err error) { port, err := targetTag() if err != nil { - return 0, errors.AddStack(err) + return 0, err } cmds := buildCommands(ScaleOutCommandType, opt) @@ -191,7 +191,7 @@ func scaleOut(args []string, opt *bootOptions) (num int, err error) { func display(args []string) error { port, err := targetTag() if err != nil { - return errors.AddStack(err) + return err } c := Command{ CommandType: DisplayCommandType, diff --git a/components/playground/grafana.go b/components/playground/grafana.go index 44aa18f349..0b1c86129b 100644 --- a/components/playground/grafana.go +++ b/components/playground/grafana.go @@ -54,7 +54,7 @@ func newGrafana(version string, host string) *grafana { func writeDatasourceConfig(fname string, clusterName string, p8sURL string) error { err := makeSureDir(fname) if err != nil { - return errors.AddStack(err) + return err } tpl := `apiVersion: 1 @@ -100,7 +100,7 @@ func replaceDatasource(dashboardDir string, datasourceName string) error { data, err := ioutil.ReadFile(path) if err != nil { - return err + return errors.AddStack(err) } s := string(data) @@ -113,7 +113,7 @@ func replaceDatasource(dashboardDir string, datasourceName string) error { }) if err != nil { - return errors.AddStack(err) + return err } return nil @@ -122,7 +122,7 @@ func replaceDatasource(dashboardDir string, datasourceName string) error { func writeDashboardConfig(fname string, clusterName string, dir string) error { err := makeSureDir(fname) if err != nil { - return errors.AddStack(err) + return err } tpl := `apiVersion: 1 @@ -157,19 +157,19 @@ var clusterName string = "playground" func (g *grafana) start(ctx context.Context, dir string, p8sURL string) (err error) { g.port, err = utils.GetFreePort(g.host, 3000) if err != nil { - return errors.AddStack(err) + return err } fname := filepath.Join(dir, "conf", "provisioning", "dashboards", "dashboard.yml") err = writeDashboardConfig(fname, clusterName, filepath.Join(dir, "dashboards")) if err != nil { - return errors.AddStack(err) + return err } fname = filepath.Join(dir, "conf", "provisioning", "datasources", "datasource.yml") err = writeDatasourceConfig(fname, clusterName, p8sURL) if err != nil { - return errors.AddStack(err) + return err } tpl := ` @@ -214,7 +214,7 @@ http_port = %d } cmd, err := tiupexec.PrepareCommand(params) if err != nil { - return errors.AddStack(err) + return err } cmd.Stdout = nil cmd.Stderr = nil diff --git a/components/playground/main.go b/components/playground/main.go index da0879e6ac..4a9e95521a 100644 --- a/components/playground/main.go +++ b/components/playground/main.go @@ -124,17 +124,17 @@ Examples: port, err := utils.GetFreePort("0.0.0.0", 9527) if err != nil { - return errors.AddStack(err) + return err } err = dumpPort(filepath.Join(dataDir, "port"), port) p := NewPlayground(dataDir, port) if err != nil { - return errors.AddStack(err) + return err } env, err := environment.InitEnv(repository.Options{}) if err != nil { - return errors.AddStack(err) + return err } environment.SetGlobalEnv(env) @@ -189,7 +189,7 @@ Examples: waitErr := p.wait() if waitErr != nil { - return errors.AddStack(waitErr) + return waitErr } return nil diff --git a/components/playground/monitor.go b/components/playground/monitor.go index cffac3332a..532ae89e43 100644 --- a/components/playground/monitor.go +++ b/components/playground/monitor.go @@ -92,7 +92,7 @@ func newMonitor(ctx context.Context, version string, host, dir string) (*monitor port, err := utils.GetFreePort(host, 9090) if err != nil { - return nil, errors.AddStack(err) + return nil, err } addr := fmt.Sprintf("%s:%d", host, port) diff --git a/components/playground/playground.go b/components/playground/playground.go index 09bbefd569..46115fd9a7 100644 --- a/components/playground/playground.go +++ b/components/playground/playground.go @@ -116,7 +116,7 @@ func (p *Playground) handleDisplay(r io.Writer) (err error) { }) if err != nil { - return errors.AddStack(err) + return err } t.Print() @@ -257,7 +257,7 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error { return nil }) if err != nil { - return errors.AddStack(err) + return err } if inst == nil { @@ -272,7 +272,7 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error { inst := p.pds[i] err := p.pdClient().DelPD(inst.Name(), timeoutOpt) if err != nil { - return errors.AddStack(err) + return err } p.pds = append(p.pds[:i], p.pds[i+1:]...) } @@ -283,7 +283,7 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error { inst := p.tikvs[i] err := p.pdClient().DelStore(inst.Addr(), timeoutOpt) if err != nil { - return errors.AddStack(err) + return err } go p.killKVIfTombstone(inst) @@ -309,7 +309,7 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error { inst := p.tiflashs[i] err := p.pdClient().DelStore(inst.Addr(), timeoutOpt) if err != nil { - return errors.AddStack(err) + return err } go p.killTiFlashIfTombstone(inst) @@ -324,11 +324,11 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error { c, err := p.binlogClient() if err != nil { - return errors.AddStack(err) + return err } err = c.OfflinePump(inst.Addr()) if err != nil { - return errors.AddStack(err) + return err } go p.removePumpWhenTombstone(c, inst) @@ -343,11 +343,11 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error { c, err := p.binlogClient() if err != nil { - return errors.AddStack(err) + return err } err = c.OfflineDrainer(inst.Addr()) if err != nil { - return errors.AddStack(err) + return err } go p.removeDrainerWhenTombstone(c, inst) @@ -416,7 +416,7 @@ func (p *Playground) startInstance(ctx context.Context, inst instance.Instance) fmt.Printf("Start %s instance\n", inst.Component()) err := inst.Start(ctx, pkgver.Version(p.bootOptions.version)) if err != nil { - return errors.AddStack(err) + return err } p.addWaitInstance(inst) return nil @@ -449,12 +449,12 @@ func (p *Playground) handleScaleOut(w io.Writer, cmd *Command) error { } inst, err := p.addInstance(cmd.ComponentID, cmd.Config) if err != nil { - return errors.AddStack(err) + return err } err = p.startInstance(context.Background(), inst) if err != nil { - return errors.AddStack(err) + return err } logIfErr(p.renderSDFile()) @@ -523,7 +523,7 @@ func (p *Playground) RWalkInstances(fn func(componentID string, ins instance.Ins for i := len(ids); i > 0; i-- { err := fn(ids[i-1], instances[i-1]) if err != nil { - return errors.AddStack(err) + return err } } return nil @@ -534,48 +534,48 @@ func (p *Playground) WalkInstances(fn func(componentID string, ins instance.Inst for _, ins := range p.pds { err := fn("pd", ins) if err != nil { - return errors.AddStack(err) + return err } } for _, ins := range p.tikvs { err := fn("tikv", ins) if err != nil { - return errors.AddStack(err) + return err } } for _, ins := range p.pumps { err := fn("pump", ins) if err != nil { - return errors.AddStack(err) + return err } } for _, ins := range p.tidbs { err := fn("tidb", ins) if err != nil { - return errors.AddStack(err) + return err } } for _, ins := range p.ticdcs { err := fn("ticdc", ins) if err != nil { - return errors.AddStack(err) + return err } } for _, ins := range p.drainers { err := fn("drainer", ins) if err != nil { - return errors.AddStack(err) + return err } } for _, ins := range p.tiflashs { err := fn("tiflash", ins) if err != nil { - return errors.AddStack(err) + return err } } return nil @@ -712,7 +712,7 @@ func (p *Playground) bootCluster(ctx context.Context, env *environment.Environme for i := 0; i < inst.Num; i++ { _, err := p.addInstance(inst.comp, inst.Config) if err != nil { - return errors.AddStack(err) + return err } } } @@ -725,7 +725,7 @@ func (p *Playground) bootCluster(ctx context.Context, env *environment.Environme p.monitor, monitorInfo, err = p.bootMonitor(ctx, env) if err != nil { - return errors.AddStack(err) + return err } p.instanceWaiter.Go(func() error { @@ -740,7 +740,7 @@ func (p *Playground) bootCluster(ctx context.Context, env *environment.Environme p.grafana, err = p.bootGrafana(ctx, env, monitorInfo) if err != nil { - return errors.AddStack(err) + return err } p.instanceWaiter.Go(func() error { @@ -780,7 +780,7 @@ func (p *Playground) bootCluster(ctx context.Context, env *environment.Environme return nil }) if err != nil { - return errors.AddStack(err) + return err } p.booted = true @@ -918,7 +918,7 @@ func (p *Playground) bootCluster(ctx context.Context, env *environment.Environme func (p *Playground) wait() error { err := p.instanceWaiter.Wait() if err != nil && atomic.LoadInt32(&p.curSig) == 0 { - return errors.AddStack(err) + return err } return nil @@ -975,7 +975,7 @@ func (p *Playground) renderSDFile() error { err := p.monitor.renderSDFile(cid2targets) if err != nil { - return errors.AddStack(err) + return err } return nil @@ -1010,7 +1010,7 @@ func (p *Playground) bootMonitor(ctx context.Context, env *environment.Environme monitor.cmd.Stdout = os.Stdout if err := monitor.cmd.Start(); err != nil { - return nil, nil, errors.AddStack(err) + return nil, nil, err } return monitor, monitorInfo, nil @@ -1021,11 +1021,11 @@ func (p *Playground) bootGrafana(ctx context.Context, env *environment.Environme // set up grafana options := p.bootOptions if err := installIfMissing(env.Profile(), "grafana", options.version); err != nil { - return nil, errors.AddStack(err) + return nil, err } installPath, err := env.Profile().ComponentInstalledPath("grafana", pkgver.Version(options.version)) if err != nil { - return nil, errors.AddStack(err) + return nil, err } dataDir := p.dataDir @@ -1057,19 +1057,19 @@ func (p *Playground) bootGrafana(ctx context.Context, env *environment.Environme return nil }) if err != nil { - return nil, errors.AddStack(err) + return nil, err } err = replaceDatasource(dashboardDir, clusterName) if err != nil { - return nil, errors.AddStack(err) + return nil, err } grafana := newGrafana(options.version, options.host) // fmt.Println("Start Grafana instance...") err = grafana.start(ctx, grafanaDir, fmt.Sprintf("http://%s:%d", monitorInfo.IP, monitorInfo.Port)) if err != nil { - return nil, errors.AddStack(err) + return nil, err } return grafana, nil diff --git a/pkg/cluster/ansible/service.go b/pkg/cluster/ansible/service.go index 656ed210b3..54c3ebaa32 100644 --- a/pkg/cluster/ansible/service.go +++ b/pkg/cluster/ansible/service.go @@ -141,7 +141,7 @@ func parseDirs(user string, ins spec.InstanceSpec, sshTimeout uint64, sshType ex } err := parseTiflashConfig(e, &newIns, fname) if err != nil { - return nil, errors.AddStack(err) + return nil, err } } } @@ -254,12 +254,12 @@ func parseDirs(user string, ins spec.InstanceSpec, sshTimeout uint64, sshType ex func parseTiflashConfig(e executor.Executor, spec *spec.TiFlashSpec, fname string) error { data, err := readFile(e, fname) if err != nil { - return errors.AddStack(err) + return err } err = parseTiflashConfigFromFileData(spec, data) if err != nil { - return errors.AddStack(err) + return err } return nil diff --git a/pkg/cluster/api/dmapi.go b/pkg/cluster/api/dmapi.go index 2ee6b22cb6..483bd0eb8a 100644 --- a/pkg/cluster/api/dmapi.go +++ b/pkg/cluster/api/dmapi.go @@ -135,7 +135,7 @@ func (dm *DMMasterClient) GetMaster(name string) (isFound bool, isActive bool, i if err != nil { zap.L().Error("get dm master status failed", zap.Error(err)) - return false, false, false, errors.AddStack(err) + return false, false, false, err } for _, member := range memberResp.GetMembers() { @@ -201,7 +201,7 @@ func (dm *DMMasterClient) GetLeader(retryOpt *utils.RetryOption) (string, error) if err := utils.Retry(func() error { memberResp, err = dm.getMember(endpoints) - return errors.AddStack(err) + return err }, *retryOpt); err != nil { return "", err } @@ -228,7 +228,7 @@ func (dm *DMMasterClient) GetRegisteredMembers() ([]string, []string, error) { if err != nil { zap.L().Error("get dm master status failed", zap.Error(err)) - return registeredMasters, registeredWorkers, errors.AddStack(err) + return registeredMasters, registeredWorkers, err } for _, member := range memberResp.Members { diff --git a/pkg/cluster/api/pdapi.go b/pkg/cluster/api/pdapi.go index d124629e0a..1f680e55a2 100644 --- a/pkg/cluster/api/pdapi.go +++ b/pkg/cluster/api/pdapi.go @@ -127,7 +127,7 @@ func (pc *PDClient) CheckHealth() error { }) if err != nil { - return errors.AddStack(err) + return err } return nil @@ -150,7 +150,7 @@ func (pc *PDClient) GetStores() (*pdserverapi.StoresInfo, error) { return body, json.Unmarshal(body, &storesInfo) }) if err != nil { - return nil, errors.AddStack(err) + return nil, err } sort.Slice(storesInfo.Stores, func(i int, j int) bool { @@ -200,7 +200,7 @@ func (pc *PDClient) GetLeader() (*pdpb.Member, error) { }) if err != nil { - return nil, errors.AddStack(err) + return nil, err } return &leader, nil @@ -221,7 +221,7 @@ func (pc *PDClient) GetMembers() (*pdpb.GetMembersResponse, error) { }) if err != nil { - return nil, errors.AddStack(err) + return nil, err } return &members, nil @@ -244,7 +244,7 @@ func (pc *PDClient) GetDashboardAddress() (string, error) { return body, json.Unmarshal(body, &pdConfig) }) if err != nil { - return "", errors.AddStack(err) + return "", err } cfg, err := flatten.Flatten(pdConfig, "", flatten.DotStyle) @@ -285,7 +285,7 @@ func (pc *PDClient) EvictPDLeader(retryOpt *utils.RetryOption) error { }) if err != nil { - return errors.AddStack(err) + return err } // wait for the transfer to complete @@ -376,7 +376,7 @@ func (pc *PDClient) EvictStoreLeader(host string, retryOpt *utils.RetryOption, c return pc.httpClient.Post(endpoint, bytes.NewBuffer(scheduler)) }) if err != nil { - return errors.AddStack(err) + return err } // wait for the transfer to complete @@ -463,7 +463,7 @@ func (pc *PDClient) RemoveStoreEvict(host string) error { return body, nil }) if err != nil { - return errors.AddStack(err) + return err } log.Debugf("Removed store leader evicting scheduler from %s.", latestStore.Store.Address) @@ -498,7 +498,7 @@ func (pc *PDClient) DelPD(name string, retryOpt *utils.RetryOption) error { return body, nil }) if err != nil { - return errors.AddStack(err) + return err } // wait for the deletion to complete @@ -532,7 +532,7 @@ func (pc *PDClient) isSameState(host string, state metapb.StoreState) (bool, err // get info of current stores stores, err := pc.GetStores() if err != nil { - return false, errors.AddStack(err) + return false, err } for _, storeInfo := range stores.Stores { @@ -603,7 +603,7 @@ func (pc *PDClient) DelStore(host string, retryOpt *utils.RetryOption) error { return body, nil }) if err != nil { - return errors.AddStack(err) + return err } // wait for the deletion to complete diff --git a/pkg/cluster/manager/basic.go b/pkg/cluster/manager/basic.go index 0ab60208e4..d0a73bb946 100644 --- a/pkg/cluster/manager/basic.go +++ b/pkg/cluster/manager/basic.go @@ -35,7 +35,7 @@ func (m *Manager) EnableCluster(name string, options operator.Options, isEnable metadata, err := m.meta(name) if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() @@ -78,7 +78,7 @@ func (m *Manager) StartCluster(name string, options operator.Options, fn ...func metadata, err := m.meta(name) if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() @@ -86,7 +86,7 @@ func (m *Manager) StartCluster(name string, options operator.Options, fn ...func tlsCfg, err := topo.TLSConfig(m.specManager.Path(name, spec.TLSCertKeyDir)) if err != nil { - return perrs.AddStack(err) + return err } b := m.sshTaskBuilder(name, topo, base.User, options). @@ -116,7 +116,7 @@ func (m *Manager) StartCluster(name string, options operator.Options, fn ...func func (m *Manager) StopCluster(name string, options operator.Options) error { metadata, err := m.meta(name) if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() @@ -149,7 +149,7 @@ func (m *Manager) StopCluster(name string, options operator.Options) error { func (m *Manager) RestartCluster(name string, options operator.Options) error { metadata, err := m.meta(name) if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() diff --git a/pkg/cluster/manager/cacert.go b/pkg/cluster/manager/cacert.go index 81eacf76b8..984d2227be 100644 --- a/pkg/cluster/manager/cacert.go +++ b/pkg/cluster/manager/cacert.go @@ -52,7 +52,7 @@ func genAndSaveClusterCA(name, tlsPath string) (*crypto.CertificateAuthority, er func genAndSaveClientCert(ca *crypto.CertificateAuthority, name, tlsPath string) error { privKey, err := crypto.NewKeyPair(crypto.KeyTypeRSA, crypto.KeySchemeRSASSAPSSSHA256) if err != nil { - return perrs.AddStack(err) + return err } // save client private key diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index a65bddfab9..a6053ea31f 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -70,7 +70,7 @@ func (m *Manager) Deploy( exist, err := m.specManager.Exist(name) if err != nil { - return perrs.AddStack(err) + return err } if exist { @@ -334,7 +334,7 @@ func (m *Manager) Deploy( // FIXME: Map possible task errors and give suggestions. return err } - return perrs.AddStack(err) + return err } metadata.SetUser(globalOptions.User) @@ -342,7 +342,7 @@ func (m *Manager) Deploy( err = m.specManager.SaveMeta(name, metadata) if err != nil { - return perrs.AddStack(err) + return err } hint := color.New(color.Bold).Sprintf("%s start %s", cliutil.OsArgs0(), name) diff --git a/pkg/cluster/manager/destroy.go b/pkg/cluster/manager/destroy.go index da41f9fc75..105c831512 100644 --- a/pkg/cluster/manager/destroy.go +++ b/pkg/cluster/manager/destroy.go @@ -35,7 +35,7 @@ func (m *Manager) DestroyCluster(name string, gOpt operator.Options, destroyOpt !errors.Is(perrs.Cause(err), spec.ErrNoTiSparkMaster) && !errors.Is(perrs.Cause(err), spec.ErrMultipleTiSparkMaster) && !errors.Is(perrs.Cause(err), spec.ErrMultipleTisparkWorker) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() @@ -93,7 +93,7 @@ func (m *Manager) DestroyTombstone( // cluster if it is somehow in a bad state. if err != nil && !errors.Is(perrs.Cause(err), spec.ErrNoTiSparkMaster) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() diff --git a/pkg/cluster/manager/display.go b/pkg/cluster/manager/display.go index 61026bac6a..910124783d 100644 --- a/pkg/cluster/manager/display.go +++ b/pkg/cluster/manager/display.go @@ -38,7 +38,7 @@ func (m *Manager) Display(name string, opt operator.Options) error { metadata, err := m.meta(name) if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) && !errors.Is(perrs.Cause(err), spec.ErrNoTiSparkMaster) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() @@ -74,12 +74,12 @@ func (m *Manager) Display(name string, opt operator.Options) error { err = ctx.SetSSHKeySet(m.specManager.Path(name, "ssh", "id_rsa"), m.specManager.Path(name, "ssh", "id_rsa.pub")) if err != nil { - return perrs.AddStack(err) + return err } err = ctx.SetClusterSSH(topo, base.User, opt.SSHTimeout, opt.SSHType, topo.BaseTopo().GlobalOptions.SSHType) if err != nil { - return perrs.AddStack(err) + return err } filterRoles := set.NewStringSet(opt.Roles...) diff --git a/pkg/cluster/manager/edit_config.go b/pkg/cluster/manager/edit_config.go index 8e0c5082e0..a8400d7809 100644 --- a/pkg/cluster/manager/edit_config.go +++ b/pkg/cluster/manager/edit_config.go @@ -35,7 +35,7 @@ import ( func (m *Manager) EditConfig(name string, skipConfirm bool) error { metadata, err := m.meta(name) if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() @@ -47,7 +47,7 @@ func (m *Manager) EditConfig(name string, skipConfirm bool) error { newTopo, err := m.editTopo(topo, data, skipConfirm) if err != nil { - return perrs.AddStack(err) + return err } if newTopo == nil { @@ -89,7 +89,7 @@ func (m *Manager) editTopo(origTopo spec.Topology, data []byte, skipConfirm bool err = utils.OpenFileInEditor(name) if err != nil { - return nil, perrs.AddStack(err) + return nil, err } // Now user finish editing the file. diff --git a/pkg/cluster/manager/exec.go b/pkg/cluster/manager/exec.go index 28a64c40c3..7604a4be4f 100644 --- a/pkg/cluster/manager/exec.go +++ b/pkg/cluster/manager/exec.go @@ -34,7 +34,7 @@ type ExecOptions struct { func (m *Manager) Exec(name string, opt ExecOptions, gOpt operator.Options) error { metadata, err := m.meta(name) if err != nil { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() diff --git a/pkg/cluster/manager/list.go b/pkg/cluster/manager/list.go index f1feb10a83..b103721bf1 100644 --- a/pkg/cluster/manager/list.go +++ b/pkg/cluster/manager/list.go @@ -26,7 +26,7 @@ import ( func (m *Manager) ListCluster() error { names, err := m.specManager.List() if err != nil { - return perrs.AddStack(err) + return err } clusterTable := [][]string{ diff --git a/pkg/cluster/manager/manager.go b/pkg/cluster/manager/manager.go index 724105ef77..b7ca189db8 100644 --- a/pkg/cluster/manager/manager.go +++ b/pkg/cluster/manager/manager.go @@ -58,7 +58,7 @@ func NewManager(sysName string, specManager *spec.SpecManager, bindVersion spec. func (m *Manager) meta(name string) (metadata spec.Metadata, err error) { exist, err := m.specManager.Exist(name) if err != nil { - return nil, perrs.AddStack(err) + return nil, err } if !exist { @@ -68,7 +68,7 @@ func (m *Manager) meta(name string) (metadata spec.Metadata, err error) { metadata = m.specManager.NewMetadata() err = m.specManager.Metadata(name, metadata) if err != nil { - return metadata, perrs.AddStack(err) + return metadata, err } return metadata, nil diff --git a/pkg/cluster/manager/patch.go b/pkg/cluster/manager/patch.go index 265f78db56..029d14dccb 100644 --- a/pkg/cluster/manager/patch.go +++ b/pkg/cluster/manager/patch.go @@ -33,7 +33,7 @@ import ( func (m *Manager) Patch(name string, packagePath string, opt operator.Options, overwrite bool) error { metadata, err := m.meta(name) if err != nil { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() diff --git a/pkg/cluster/manager/reload.go b/pkg/cluster/manager/reload.go index 82a384df22..cbec07680c 100644 --- a/pkg/cluster/manager/reload.go +++ b/pkg/cluster/manager/reload.go @@ -28,7 +28,7 @@ func (m *Manager) Reload(name string, opt operator.Options, skipRestart bool) er metadata, err := m.meta(name) if err != nil { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() @@ -58,7 +58,7 @@ func (m *Manager) Reload(name string, opt operator.Options, skipRestart bool) er // handle dir scheme changes if hasImported { if err := spec.HandleImportPathMigration(name); err != nil { - return perrs.AddStack(err) + return err } } diff --git a/pkg/cluster/manager/rename.go b/pkg/cluster/manager/rename.go index 54f1194f0d..94fe4fe240 100644 --- a/pkg/cluster/manager/rename.go +++ b/pkg/cluster/manager/rename.go @@ -16,7 +16,6 @@ package manager import ( "os" - perrs "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/cliutil" operator "github.com/pingcap/tiup/pkg/cluster/operation" "github.com/pingcap/tiup/pkg/cluster/spec" @@ -39,11 +38,11 @@ func (m *Manager) Rename(name string, opt operator.Options, newName string) erro _, err := m.meta(name) if err != nil { // refuse renaming if current cluster topology is not valid - return perrs.AddStack(err) + return err } if err := os.Rename(m.specManager.Path(name), m.specManager.Path(newName)); err != nil { - return perrs.AddStack(err) + return err } log.Infof("Rename cluster `%s` -> `%s` successfully", name, newName) diff --git a/pkg/cluster/manager/scale_in.go b/pkg/cluster/manager/scale_in.go index ebf155792b..7aa686fdd6 100644 --- a/pkg/cluster/manager/scale_in.go +++ b/pkg/cluster/manager/scale_in.go @@ -65,7 +65,7 @@ func (m *Manager) ScaleIn( !errors.Is(perrs.Cause(err), spec.ErrMultipleTisparkWorker) { // ignore conflict check error, node may be deployed by former version // that lack of some certain conflict checks - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() diff --git a/pkg/cluster/manager/scale_out.go b/pkg/cluster/manager/scale_out.go index c57acdeb7d..8127b101c6 100644 --- a/pkg/cluster/manager/scale_out.go +++ b/pkg/cluster/manager/scale_out.go @@ -54,7 +54,7 @@ func (m *Manager) ScaleOut( // cluster if it is somehow in a bad state. if err != nil && !errors.Is(perrs.Cause(err), spec.ErrNoTiSparkMaster) { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() diff --git a/pkg/cluster/manager/upgrade.go b/pkg/cluster/manager/upgrade.go index 0f87980550..8508a677d4 100644 --- a/pkg/cluster/manager/upgrade.go +++ b/pkg/cluster/manager/upgrade.go @@ -35,7 +35,7 @@ import ( func (m *Manager) Upgrade(name string, clusterVersion string, opt operator.Options, skipConfirm bool) error { metadata, err := m.meta(name) if err != nil { - return perrs.AddStack(err) + return err } topo := metadata.GetTopology() diff --git a/pkg/cluster/operation/action.go b/pkg/cluster/operation/action.go index 1a968f2b5b..1b782a70cc 100644 --- a/pkg/cluster/operation/action.go +++ b/pkg/cluster/operation/action.go @@ -272,7 +272,7 @@ func RestartComponent(getter ExecutorGetter, instances []spec.Instance, timeout for _, ins := range instances { err := restartInstance(getter, ins, timeout) if err != nil { - return errors.AddStack(err) + return err } } @@ -387,7 +387,7 @@ func EnableComponent(getter ExecutorGetter, instances []spec.Instance, options O errg.Go(func() error { err := enableInstance(getter, ins, options.OptTimeout, isEnable) if err != nil { - return errors.AddStack(err) + return err } return nil }) @@ -461,7 +461,7 @@ func StartComponent(getter ExecutorGetter, instances []spec.Instance, options Op } err := startInstance(getter, ins, options.OptTimeout) if err != nil { - return errors.AddStack(err) + return err } return nil }) @@ -576,7 +576,7 @@ func StopComponent(getter ExecutorGetter, instances []spec.Instance, timeout uin errg.Go(func() error { err := stopInstance(getter, ins, timeout) if err != nil { - return errors.AddStack(err) + return err } return nil }) diff --git a/pkg/cluster/operation/destroy.go b/pkg/cluster/operation/destroy.go index 7e4b8f3a14..610c4d703c 100644 --- a/pkg/cluster/operation/destroy.go +++ b/pkg/cluster/operation/destroy.go @@ -498,7 +498,7 @@ func DestroyClusterTombstone( binlogClient, err := api.NewBinlogClient(cluster.GetPDList(), tlsCfg) if err != nil { - return nil, errors.AddStack(err) + return nil, err } filterID := func(instance []spec.Instance, id string) (res []spec.Instance) { @@ -517,7 +517,7 @@ func DestroyClusterTombstone( instCount[instance.GetHost()]-- err := StopAndDestroyInstance(getter, cluster, instance, options, instCount[instance.GetHost()] == 0) if err != nil { - return errors.AddStack(err) + return err } } return nil @@ -534,7 +534,7 @@ func DestroyClusterTombstone( tombstone, err := pdClient.IsTombStone(id) if err != nil { - return nil, errors.AddStack(err) + return nil, err } if !tombstone { @@ -564,7 +564,7 @@ func DestroyClusterTombstone( tombstone, err := pdClient.IsTombStone(id) if err != nil { - return nil, errors.AddStack(err) + return nil, err } if !tombstone { @@ -595,7 +595,7 @@ func DestroyClusterTombstone( tombstone, err := binlogClient.IsPumpTombstone(id) if err != nil { - return nil, errors.AddStack(err) + return nil, err } if !tombstone { @@ -624,7 +624,7 @@ func DestroyClusterTombstone( tombstone, err := binlogClient.IsDrainerTombstone(id) if err != nil { - return nil, errors.AddStack(err) + return nil, err } if !tombstone { diff --git a/pkg/cluster/operation/scale_in.go b/pkg/cluster/operation/scale_in.go index 398ad20a3d..a4157b7a08 100644 --- a/pkg/cluster/operation/scale_in.go +++ b/pkg/cluster/operation/scale_in.go @@ -331,7 +331,7 @@ func deleteMember( addr := instance.GetHost() + ":" + strconv.Itoa(instance.GetPort()) err := binlogClient.OfflinePump(addr) if err != nil { - return errors.AddStack(err) + return err } } diff --git a/pkg/cluster/operation/telemetry.go b/pkg/cluster/operation/telemetry.go index c4de340444..191c66eb9d 100644 --- a/pkg/cluster/operation/telemetry.go +++ b/pkg/cluster/operation/telemetry.go @@ -53,7 +53,7 @@ func GetNodeInfo( err = errg.Wait() if err != nil { - return nil, errors.AddStack(err) + return nil, err } // Copy and get info per host. @@ -112,7 +112,7 @@ func GetNodeInfo( err = errg.Wait() if err != nil { - return nil, errors.AddStack(err) + return nil, err } return diff --git a/pkg/cluster/operation/upgrade.go b/pkg/cluster/operation/upgrade.go index 3c7dc947f3..279ece3eaa 100644 --- a/pkg/cluster/operation/upgrade.go +++ b/pkg/cluster/operation/upgrade.go @@ -17,7 +17,6 @@ import ( "crypto/tls" "strconv" - "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/cluster/spec" "github.com/pingcap/tiup/pkg/logger/log" "github.com/pingcap/tiup/pkg/set" @@ -56,18 +55,18 @@ func Upgrade( if isRollingInstance { err := rollingInstance.PreRestart(topo, int(options.APITimeout), tlsCfg) if err != nil && !options.Force { - return errors.AddStack(err) + return err } } if err := restartInstance(getter, instance, options.OptTimeout); err != nil && !options.Force { - return errors.AddStack(err) + return err } if isRollingInstance { err := rollingInstance.PostRestart(topo, tlsCfg) if err != nil && !options.Force { - return errors.AddStack(err) + return err } } } diff --git a/pkg/cluster/spec/grafana.go b/pkg/cluster/spec/grafana.go index 8ab35ed9d8..fc6632bd22 100644 --- a/pkg/cluster/spec/grafana.go +++ b/pkg/cluster/spec/grafana.go @@ -254,7 +254,7 @@ func (i *GrafanaInstance) installDashboards(e executor.Executor, deployDir, clus dstPath := filepath.Join(tmp, filepath.Base(srcPath)) err = e.Transfer(srcPath, dstPath, false) if err != nil { - return errors.AddStack(err) + return err } cmd := fmt.Sprintf(`tar --no-same-owner -zxf %s -C %s && rm %s`, dstPath, tmp, dstPath) diff --git a/pkg/cluster/spec/prometheus.go b/pkg/cluster/spec/prometheus.go index 4a1d5f5bfb..64a72fd909 100644 --- a/pkg/cluster/spec/prometheus.go +++ b/pkg/cluster/spec/prometheus.go @@ -255,7 +255,7 @@ func (i *MonitorInstance) InitConfig( } if err := i.initRules(e, spec, paths); err != nil { - return errors.AddStack(err) + return err } if err := cfig.ConfigToFile(fp); err != nil { @@ -286,7 +286,7 @@ func (i *MonitorInstance) installRules(e executor.Executor, deployDir, clusterVe err = e.Transfer(srcPath, dstPath, false) if err != nil { - return errors.AddStack(err) + return err } cmd := fmt.Sprintf(`tar --no-same-owner -zxf %s -C %s && rm %s`, dstPath, tmp, dstPath) diff --git a/pkg/cluster/spec/server_config.go b/pkg/cluster/spec/server_config.go index f279602269..02e8f8c2b3 100644 --- a/pkg/cluster/spec/server_config.go +++ b/pkg/cluster/spec/server_config.go @@ -196,7 +196,7 @@ func Merge2Toml(comp string, global, overwrite map[string]interface{}) ([]byte, func merge2Toml(comp string, global, overwrite map[string]interface{}) ([]byte, error) { lhs, err := merge(global, overwrite) if err != nil { - return nil, perrs.AddStack(err) + return nil, err } buf := bytes.NewBufferString(fmt.Sprintf(`# WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten! diff --git a/pkg/cluster/spec/spec_manager.go b/pkg/cluster/spec/spec_manager.go index 092a9512cb..90d18378b4 100644 --- a/pkg/cluster/spec/spec_manager.go +++ b/pkg/cluster/spec/spec_manager.go @@ -180,7 +180,7 @@ func (s *SpecManager) GetAllClusters() (map[string]Metadata, error) { clusters := make(map[string]Metadata) names, err := s.List() if err != nil { - return nil, perrs.AddStack(err) + return nil, err } for _, name := range names { metadata := s.NewMetadata() diff --git a/pkg/cluster/spec/tikv.go b/pkg/cluster/spec/tikv.go index a3c11d969f..c078ef942c 100644 --- a/pkg/cluster/spec/tikv.go +++ b/pkg/cluster/spec/tikv.go @@ -328,7 +328,7 @@ func (i *TiKVInstance) PreRestart(topo Topology, apiTimeoutSeconds int, tlsCfg * // But when there's only one PD instance the pd might not serve request right away after restart. err := pdClient.WaitLeader(timeoutOpt) if err != nil { - return errors.AddStack(err) + return err } if err := pdClient.EvictStoreLeader(addr(i), timeoutOpt, genLeaderCounter(tidbTopo, tlsCfg)); err != nil { diff --git a/pkg/cluster/spec/util.go b/pkg/cluster/spec/util.go index beba357750..f20ffa5643 100644 --- a/pkg/cluster/spec/util.go +++ b/pkg/cluster/spec/util.go @@ -20,7 +20,6 @@ import ( "reflect" "strings" - "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/utils" "github.com/pingcap/tiup/pkg/version" "go.etcd.io/etcd/pkg/transport" @@ -105,7 +104,7 @@ func ClusterMetadata(clusterName string) (*ClusterMeta, error) { // validated `edit-config`, or by some unexpected operations from a broken legacy // release, we could provide max possibility that operations like `display`, `scale` // and `destroy` are still (more or less) working, by ignoring certain errors. - return &cm, errors.AddStack(err) + return &cm, err } return &cm, nil diff --git a/pkg/cluster/template/config/alertmanager.go b/pkg/cluster/template/config/alertmanager.go index 3e4a48c20e..622080288f 100644 --- a/pkg/cluster/template/config/alertmanager.go +++ b/pkg/cluster/template/config/alertmanager.go @@ -34,7 +34,7 @@ func (c *AlertManagerConfig) Config() ([]byte, error) { fp := path.Join("/templates", "config", "alertmanager.yml") tpl, err := embed.ReadFile(fp) if err != nil { - return nil, errors.AddStack(err) + return nil, err } return c.ConfigWithTemplate(string(tpl)) } diff --git a/pkg/environment/env.go b/pkg/environment/env.go index c2769fb4ab..854a62a432 100644 --- a/pkg/environment/env.go +++ b/pkg/environment/env.go @@ -113,7 +113,7 @@ func InitEnv(options repository.Options) (*Environment, error) { } else { repo, err = repository.NewRepository(mirror, options) if err != nil { - return nil, errors.AddStack(err) + return nil, err } } diff --git a/pkg/logger/audit.go b/pkg/logger/audit.go index 29f5db9d36..01724ee534 100644 --- a/pkg/logger/audit.go +++ b/pkg/logger/audit.go @@ -18,7 +18,6 @@ import ( "os" "strings" - "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/cluster/audit" utils2 "github.com/pingcap/tiup/pkg/utils" "go.uber.org/atomic" @@ -54,12 +53,12 @@ func OutputAuditLogIfEnabled() error { } if err := utils2.CreateDir(auditDir); err != nil { - return errors.AddStack(err) + return err } err := audit.OutputAuditLog(auditDir, auditBuffer.Bytes()) if err != nil { - return errors.AddStack(err) + return err } auditBuffer.Reset() diff --git a/pkg/repository/clone_mirror.go b/pkg/repository/clone_mirror.go index c46745c05e..f1fd09ad5f 100644 --- a/pkg/repository/clone_mirror.go +++ b/pkg/repository/clone_mirror.go @@ -340,7 +340,7 @@ func download(targetDir, tmpDir string, repo *V1Repository, item *v1manifest.Ver validate := func(dir string) error { hashes, n, err := ru.HashFile(path.Join(dir, item.URL)) if err != nil { - return errors.AddStack(err) + return err } if uint(n) != item.Length { return errors.Errorf("file length mismatch, expected: %d, got: %v", item.Length, n) diff --git a/pkg/repository/v1_repository.go b/pkg/repository/v1_repository.go index 171919987f..0a91f2d49f 100644 --- a/pkg/repository/v1_repository.go +++ b/pkg/repository/v1_repository.go @@ -342,7 +342,7 @@ func (r *V1Repository) updateLocalRoot() error { oldRoot, err := r.loadRoot() if err != nil { - return errors.AddStack(err) + return err } startVersion := oldRoot.Version keyStore := *r.local.KeyStore() @@ -357,7 +357,7 @@ func (r *V1Repository) updateLocalRoot() error { if errors.Cause(err) == ErrNotFound { break } - return errors.AddStack(err) + return err } newManifest = nextManifest @@ -366,13 +366,13 @@ func (r *V1Repository) updateLocalRoot() error { } if err = v1manifest.ExpiresAfter(&newRoot, oldRoot); err != nil { - return errors.AddStack(err) + return err } // This is a valid new version. err = r.local.SaveManifest(newManifest, v1manifest.RootManifestFilename(newRoot.Version)) if err != nil { - return errors.AddStack(err) + return err } oldRoot = &newRoot } @@ -385,14 +385,14 @@ func (r *V1Repository) updateLocalRoot() error { // Check expire of this version. err = v1manifest.CheckExpiry(v1manifest.ManifestFilenameRoot, oldRoot.Expires) if err != nil { - return errors.AddStack(err) + return err } // Save the new trusted root without a version number. This action will also update the key store in r.local from // the new root. err = r.local.SaveManifest(newManifest, v1manifest.ManifestFilenameRoot) if err != nil { - return errors.AddStack(err) + return err } return nil @@ -408,7 +408,7 @@ func (r *V1Repository) updateLocalIndex(snapshot *v1manifest.Snapshot) error { var oldIndex v1manifest.Index _, exists, err := r.local.LoadManifest(&oldIndex) if err != nil { - return errors.AddStack(err) + return err } snapIndexVersion := snapshot.Meta[v1manifest.ManifestURLIndex].Version @@ -461,7 +461,7 @@ func (r *V1Repository) updateComponentManifest(id string, withYanked bool) (*v1m item, ok := components[id] if !ok { - return nil, errors.AddStack(errUnknownComponent) + return nil, errUnknownComponent } var snapshot v1manifest.Snapshot _, _, err = r.local.LoadManifest(&snapshot) @@ -656,7 +656,7 @@ func (r *V1Repository) loadRoot() (*v1manifest.Root, error) { root := new(v1manifest.Root) _, exists, err := r.local.LoadManifest(root) if err != nil { - return nil, errors.AddStack(err) + return nil, err } if !exists { @@ -689,13 +689,13 @@ func (r *V1Repository) FetchRootManfiest() (root *v1manifest.Root, err error) { func (r *V1Repository) FetchIndexManifest() (index *v1manifest.Index, err error) { err = r.ensureManifests() if err != nil { - return nil, errors.AddStack(err) + return nil, err } index = new(v1manifest.Index) _, exists, err := r.local.LoadManifest(index) if err != nil { - return nil, errors.AddStack(err) + return nil, err } if !exists { @@ -737,7 +737,7 @@ func (r *V1Repository) UpdateComponentManifests() error { func (r *V1Repository) FetchComponentManifest(id string, withYanked bool) (com *v1manifest.Component, err error) { err = r.ensureManifests() if err != nil { - return nil, errors.AddStack(err) + return nil, err } return r.updateComponentManifest(id, withYanked) diff --git a/pkg/repository/v1manifest/local_manifests.go b/pkg/repository/v1manifest/local_manifests.go index 674d82acf0..3977d9c1af 100644 --- a/pkg/repository/v1manifest/local_manifests.go +++ b/pkg/repository/v1manifest/local_manifests.go @@ -73,26 +73,26 @@ func NewManifests(profile *localdata.Profile) (*FsManifests, error) { // Load the root manifest. manifest, err := result.load(ManifestFilenameRoot) if err != nil { - return nil, errors.AddStack(err) + return nil, err } // We must load without validation because we have no keys yet. var root Root _, err = ReadNoVerify(strings.NewReader(manifest), &root) if err != nil { - return nil, errors.AddStack(err) + return nil, err } // Populate our key store from the root manifest. err = loadKeys(&root, result.keys) if err != nil { - return nil, errors.AddStack(err) + return nil, err } // Now that we've bootstrapped the key store, we can verify the root manifest we loaded earlier. _, err = ReadManifest(strings.NewReader(manifest), &root, result.keys) if err != nil { - return nil, errors.AddStack(err) + return nil, err } result.cache.Store(ManifestFilenameRoot, manifest) @@ -349,7 +349,7 @@ func (ms *MockManifests) LoadManifest(role ValidManifest) (*Manifest, bool, erro err := loadKeys(role, ms.Ks) if err != nil { - return nil, false, errors.AddStack(err) + return nil, false, err } return manifest, true, nil } diff --git a/pkg/repository/v1manifest/manifest.go b/pkg/repository/v1manifest/manifest.go index 9f6beedeb4..01ee4a34ad 100644 --- a/pkg/repository/v1manifest/manifest.go +++ b/pkg/repository/v1manifest/manifest.go @@ -211,7 +211,7 @@ func (s *SignedBase) isValid(filename string) error { // This checking should be done by the update root flow. if s.Ty != ManifestTypeRoot { if err := CheckExpiry(filename, s.Expires); err != nil { - return errors.AddStack(err) + return err } }