Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove remote cli dependency for CLI #2026

Merged
merged 25 commits into from
Jul 18, 2024
Merged

remove remote cli dependency for CLI #2026

merged 25 commits into from
Jul 18, 2024

Conversation

arturrez
Copy link
Collaborator

sdk PR to follow
ref: ava-labs/avalanche-tooling-sdk-go#76

cmd/nodecmd/sync.go Outdated Show resolved Hide resolved
@@ -73,6 +73,7 @@ var (
deployTeleporterMessenger bool
deployTeleporterRegistry bool
replaceKeyPair bool
depricatedRemoteCLIVersion string
Copy link
Collaborator

@sukantoraymond sukantoraymond Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just delete this

@arturrez arturrez merged commit 14011f3 into main Jul 18, 2024
32 of 33 checks passed
}

func (h *HostInstaller) GetArch() (string, string) {
goArhBytes, err := h.Host.Command("go env GOARCH", nil, constants.SSHScriptTimeout)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can avoid depending on go binary for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. agree

return err
}
if _, err := host.Command(fmt.Sprintf("/home/ubuntu/bin/avalanche subnet join %s %s --avalanchego-config /home/ubuntu/.avalanchego/configs/node.json --plugin-dir /home/ubuntu/.avalanchego/plugins --force-write", subnetName, networkFlag), nil, constants.SSHScriptTimeout); err != nil {
bootstrapIDs, _ := utils.GetValueString(remoteAvagoConfFile, "bootstrap-ids")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check for error here

return err
}
if _, err := host.Command(fmt.Sprintf("/home/ubuntu/bin/avalanche subnet join %s %s --avalanchego-config /home/ubuntu/.avalanchego/configs/node.json --plugin-dir /home/ubuntu/.avalanchego/plugins --force-write", subnetName, networkFlag), nil, constants.SSHScriptTimeout); err != nil {
bootstrapIDs, _ := utils.GetValueString(remoteAvagoConfFile, "bootstrap-ids")
bootstrapIPs, _ := utils.GetValueString(remoteAvagoConfFile, "bootstrap-ips")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

archiveFullPath := filepath.Join(tmpDir, archiveName)

// download and install subnet evm
if _, err := host.Command(fmt.Sprintf("%s %s -O %s", "busybox wget", installURL, archiveFullPath), nil, constants.SSHLongRunningScriptTimeout); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you have scripts for this on shell, eg upgradeSubnetEVM, pkg/ssh/shell/getNewSubnetEVMRelease.sh, why not using them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not having one .sh file for all of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will increase size of scriptInputs struct so I though we can get away without it as operation is straightforward

if err := host.MkdirAll(filepath.Dir(subnetConfigPath), constants.SSHDirOpsTimeout); err != nil {
return err
}
if err := host.Upload(subnetConfigFile.Name(), subnetConfigPath, constants.SSHFileOpsTimeout); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have an upload that takes as input a slice of bytes, so we dont need to create tmp files?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. we should have another func for this

return nil, err
}
defer os.Remove(tmpFile.Name())
if err := host.Download(nodeJSONPath, tmpFile.Name(), constants.SSHFileOpsTimeout); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a download that returns a byte slice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. we should have another func for this

@@ -559,3 +559,11 @@ func Command(cmdLine string, params ...string) *exec.Cmd {
c.Env = os.Environ()
return c
}

// GetValueString returns the value of a key in a map as a string.
func GetValueString(data map[string]interface{}, key string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we improve the name of the function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which one do you suggest ?

@@ -25,3 +25,14 @@ func ValidateJSON(path string) ([]byte, error) {

return contentBytes, nil
}

// MergeJsonMaps merges two maps of type map[string]interface{}
func MergeJSONMaps(a, b map[string]interface{}) map[string]interface{} {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be maps.Copy be used instead of MergeJSONMaps?

@michaelkaplan13 michaelkaplan13 deleted the refactor-join branch September 25, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants