Skip to content

Commit

Permalink
cluster: fix paths for tispark
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Jul 1, 2020
1 parent 50aaf3b commit 29bbe45
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
27 changes: 27 additions & 0 deletions components/cluster/command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,29 @@ func deploy(clusterName, clusterVersion, topoFile string, opt deployOptions) err
// copy dependency component if needed
switch inst.ComponentName() {
case spec.ComponentTiSpark:
sparkSubPath := spec.ComponentSubDir(spec.ComponentSpark,
spec.ComponentVersion(spec.ComponentSpark, version))
t = t.CopyComponent(
spec.ComponentSpark,
inst.OS(),
inst.Arch(),
spec.ComponentVersion(spec.ComponentSpark, version),
inst.GetHost(),
deployDir,
).Shell( // spark is under a subdir, move it to deploy dir
inst.GetHost(),
fmt.Sprintf(
"mv -f %s %s/ && mv -f %s/* %s/ && rm -rf %s",
filepath.Join(deployDir, "bin", sparkSubPath),
deployDir,
filepath.Join(deployDir, sparkSubPath),
deployDir,
filepath.Join(deployDir, sparkSubPath),
),
false, // (not) sudo
)
}

t = t.CopyComponent(
inst.ComponentName(),
inst.OS(),
Expand All @@ -295,6 +309,19 @@ func deploy(clusterName, clusterVersion, topoFile string, opt deployOptions) err
deployDir,
)

switch inst.ComponentName() {
case spec.ComponentTiSpark:
t = t.Shell( // move tispark jar to correct path
inst.GetHost(),
fmt.Sprintf(
"mv -f %s/*.jar %s/jars/",
filepath.Join(deployDir, "bin"),
deployDir,
),
false, // (not) sudo
)
}

// generate configs for the component
t = t.InitConfig(
clusterName,
Expand Down
4 changes: 3 additions & 1 deletion pkg/cluster/operation/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ func DestroyComponent(getter ExecutorGetter, instances []spec.Instance, cls topo
delPaths.Insert(deployDir)
}

delPaths.Insert(fmt.Sprintf("/etc/systemd/system/%s", ins.ServiceName()))
if svc := ins.ServiceName(); svc != "" {
delPaths.Insert(fmt.Sprintf("/etc/systemd/system/%s", svc))
}
log.Debugf("Deleting paths on %s: %s", ins.GetHost(), strings.Join(delPaths.Slice(), " "))
c := module.ShellModuleConfig{
Command: fmt.Sprintf("rm -rf %s;", strings.Join(delPaths.Slice(), " ")),
Expand Down
14 changes: 14 additions & 0 deletions pkg/cluster/spec/bindversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

package spec

import (
"fmt"
"strings"
)

// ComponentVersion maps the TiDB version to the third components binding version
func ComponentVersion(comp, version string) string {
switch comp {
Expand All @@ -34,3 +39,12 @@ func ComponentVersion(comp, version string) string {
return version
}
}

// ComponentSubDir maps a component with version to a subdir if needed
func ComponentSubDir(comp, version string) string {
switch comp {
case ComponentSpark:
return fmt.Sprintf("spark-%s-bin-hadoop2.7", strings.TrimLeft(version, "v"))
}
return ""
}

0 comments on commit 29bbe45

Please sign in to comment.