Skip to content

Commit

Permalink
roachprod: allow opting out some providers
Browse files Browse the repository at this point in the history
Azure in particular takes a long time - sometimes well north of 1s.
  • Loading branch information
tbg committed Dec 23, 2024
1 parent 56f005f commit 9cc858a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 22 deletions.
1 change: 1 addition & 0 deletions pkg/roachprod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ go_library(
"//pkg/roachprod/vm",
"//pkg/roachprod/vm/aws",
"//pkg/roachprod/vm/azure",
"//pkg/roachprod/vm/flagstub",
"//pkg/roachprod/vm/gce",
"//pkg/roachprod/vm/local",
"//pkg/server/debug/replay",
Expand Down
70 changes: 48 additions & 22 deletions pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/roachprod/vm"
"github.com/cockroachdb/cockroach/pkg/roachprod/vm/aws"
"github.com/cockroachdb/cockroach/pkg/roachprod/vm/azure"
"github.com/cockroachdb/cockroach/pkg/roachprod/vm/flagstub"
"github.com/cockroachdb/cockroach/pkg/roachprod/vm/gce"
"github.com/cockroachdb/cockroach/pkg/roachprod/vm/local"
"github.com/cockroachdb/cockroach/pkg/server/debug/replay"
Expand Down Expand Up @@ -1809,33 +1810,58 @@ func StageURL(
return urls, nil
}

var disabledProviders = func() map[string]struct{} {
disabled := make(map[string]struct{})
for _, p := range strings.Split(os.Getenv("ROACHPROD_DISABLED_PROVIDERS"), ",") {
disabled[strings.TrimSpace(strings.ToLower(p))] = struct{}{}
}
return disabled
}()

// InitProviders initializes providers and returns a map that indicates
// if a provider is active or inactive.
func InitProviders() map[string]string {
providersState := make(map[string]string)

if err := aws.Init(); err != nil {
providersState[aws.ProviderName] = "Inactive - " + err.Error()
} else {
providersState[aws.ProviderName] = "Active"
}

if err := gce.Init(); err != nil {
providersState[gce.ProviderName] = "Inactive - " + err.Error()
} else {
providersState[gce.ProviderName] = "Active"
}

if err := azure.Init(); err != nil {
providersState[azure.ProviderName] = "Inactive - " + err.Error()
} else {
providersState[azure.ProviderName] = "Active"
}

if err := local.Init(localVMStorage{}); err != nil {
providersState[local.ProviderName] = "Inactive - " + err.Error()
} else {
providersState[local.ProviderName] = "Active"
for _, prov := range []struct {
name string
init func() error
empty vm.Provider
}{
{
name: aws.ProviderName,
init: aws.Init,
empty: &aws.Provider{},
},
{
name: gce.ProviderName,
init: gce.Init,
empty: &gce.Provider{},
},
{
name: azure.ProviderName,
init: azure.Init,
empty: &azure.Provider{},
},
{
name: local.ProviderName,
init: func() error {
return local.Init(localVMStorage{})
},
empty: &local.Provider{},
},
} {
if _, dis := disabledProviders[prov.name]; dis {
reason := "disabled via ROACHPROD_DISABLED_PROVIDERS"
providersState[prov.name] = "Inactive - " + reason
// We need an empty provider that emits errors or we'll
// crash as roachprod expects all providers to be present.
vm.Providers[prov.name] = flagstub.New(prov.empty, reason)
} else if err := prov.init(); err != nil {
providersState[prov.name] = "Inactive - " + err.Error()
} else {
providersState[prov.name] = "Active"
}
}

return providersState
Expand Down

0 comments on commit 9cc858a

Please sign in to comment.