Skip to content

Commit 11a17b8

Browse files
authored
chore: Retry Ekco Api Calls for migrate-multinode-storage cmd (#4743)
Retry http api calls for cluster-migrate-multinode cmd
1 parent 567972d commit 11a17b8

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/golang/mock v1.6.0
1515
github.com/google/go-cmp v0.5.9
1616
github.com/google/uuid v1.3.0
17+
github.com/hashicorp/go-retryablehttp v0.7.4
1718
github.com/itchyny/gojq v0.12.13
1819
github.com/longhorn/longhorn-manager v1.4.1
1920
github.com/mattn/go-isatty v0.0.19
@@ -140,7 +141,6 @@ require (
140141
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
141142
github.com/hashicorp/go-multierror v1.1.1 // indirect
142143
github.com/hashicorp/go-plugin v1.4.9 // indirect
143-
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
144144
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
145145
github.com/hashicorp/go-safetemp v1.0.0 // indirect
146146
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,8 @@ github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER
12921292
github.com/hashicorp/go-retryablehttp v0.6.7/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
12931293
github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
12941294
github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
1295-
github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
1296-
github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
1295+
github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
1296+
github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
12971297
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
12981298
github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
12991299
github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=

pkg/cli/cluster_migrate_multinode_storage.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111
"time"
1212

13+
retryablehttp "github.com/hashicorp/go-retryablehttp"
1314
"github.com/spf13/cobra"
1415
"gopkg.in/yaml.v2"
1516
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -62,7 +63,7 @@ func NewClusterMigrateMultinodeStorageCmd(cli CLI) *cobra.Command {
6263
// getEkcoMigrationLogs returns the logs of the migration as reported back by ekco.
6364
func getEkcoMigrationLogs(opts migrateOpts) (string, error) {
6465
url := fmt.Sprintf("http://%s/storagemigration/logs", opts.ekcoAddress)
65-
resp, err := http.Get(url)
66+
resp, err := retryablehttp.Get(url)
6667
if err != nil {
6768
return "", fmt.Errorf("failed to get migration logs: %w", err)
6869
}
@@ -77,7 +78,7 @@ func getEkcoMigrationLogs(opts migrateOpts) (string, error) {
7778
// getEkcoMigrationStatus returns the status of the storage migration as reported back by ekco.
7879
func getEkcoMigrationStatus(opts migrateOpts) (string, error) {
7980
url := fmt.Sprintf("http://%s/storagemigration/status", opts.ekcoAddress)
80-
resp, err := http.Get(url)
81+
resp, err := retryablehttp.Get(url)
8182
if err != nil {
8283
return "", fmt.Errorf("failed to get migration status: %w", err)
8384
}
@@ -107,7 +108,7 @@ type MigrationReadyStatus struct {
107108

108109
func isClusterReadyForStorageMigration(opts migrateOpts) (*ClusterReadyStatus, error) {
109110
url := fmt.Sprintf("http://%s/storagemigration/cluster-ready", opts.ekcoAddress)
110-
resp, err := http.Get(url)
111+
resp, err := retryablehttp.Get(url)
111112
if err != nil {
112113
return nil, fmt.Errorf("failed to get ekco cluster ready status: %w", err)
113114
}
@@ -129,7 +130,7 @@ func isClusterReadyForStorageMigration(opts migrateOpts) (*ClusterReadyStatus, e
129130

130131
func isEkcoReadyForStorageMigration(opts migrateOpts) (*MigrationReadyStatus, error) {
131132
url := fmt.Sprintf("http://%s/storagemigration/ready", opts.ekcoAddress)
132-
resp, err := http.Get(url)
133+
resp, err := retryablehttp.Get(url)
133134
if err != nil {
134135
return nil, fmt.Errorf("failed to get ekco status: %w", err)
135136
}

0 commit comments

Comments
 (0)