Skip to content

Commit

Permalink
Deprecate Vsphere provider
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
  • Loading branch information
ArangoGutierrez committed Oct 21, 2024
1 parent 392f37c commit d312f78
Show file tree
Hide file tree
Showing 185 changed files with 5 additions and 177,518 deletions.
2 changes: 0 additions & 2 deletions api/holodeck/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ type Provider string
const (
// ProviderAWS means the infra provider is AWS
ProviderAWS Provider = "aws"
// ProviderVSphere means the infra provider is VSphere
ProviderVSphere Provider = "vsphere"
// ProviderSSH means the user already has a running instance
// and wants to use it as the infra provider via SSH
ProviderSSH Provider = "ssh"
Expand Down
13 changes: 0 additions & 13 deletions cmd/action/ci/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/NVIDIA/holodeck/internal/logger"
"github.com/NVIDIA/holodeck/pkg/jyaml"
"github.com/NVIDIA/holodeck/pkg/provider/aws"
"github.com/NVIDIA/holodeck/pkg/provider/vsphere"
"github.com/NVIDIA/holodeck/pkg/provisioner"
"github.com/NVIDIA/holodeck/pkg/utils"
)
Expand Down Expand Up @@ -82,18 +81,6 @@ func entrypoint(log *logger.FunLogger) error {
break
}
}
} else if cfg.Spec.Provider == v1alpha1.ProviderVSphere {
if err := getSSHKeyFile(log, "VSPHERE_SSH_KEY"); err != nil {
return err
}
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = "nvidia"
for _, p := range cache.Status.Properties {
if p.Name == vsphere.IpAddress {
hostUrl = p.Value
break
}
}
}

// Run the provisioner
Expand Down
27 changes: 0 additions & 27 deletions cmd/action/ci/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/NVIDIA/holodeck/internal/logger"
"github.com/NVIDIA/holodeck/pkg/provider"
"github.com/NVIDIA/holodeck/pkg/provider/aws"
"github.com/NVIDIA/holodeck/pkg/provider/vsphere"
)

func newProvider(log *logger.FunLogger, cfg *v1alpha1.Environment) (provider.Provider, error) {
Expand All @@ -37,11 +36,6 @@ func newProvider(log *logger.FunLogger, cfg *v1alpha1.Environment) (provider.Pro
if err != nil {
return nil, err
}
case v1alpha1.ProviderVSphere:
provider, err = newVsphereProvider(log, cfg)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("provider %s not supported", cfg.Spec.Provider)
}
Expand Down Expand Up @@ -70,27 +64,6 @@ func newAwsProvider(log *logger.FunLogger, cfg *v1alpha1.Environment) (*aws.Prov
return a, nil
}

func newVsphereProvider(log *logger.FunLogger, cfg *v1alpha1.Environment) (*vsphere.Provider, error) {
// Create cachedir directory
if _, err := os.Stat(cachedir); os.IsNotExist(err) {
err := os.Mkdir(cachedir, 0755)
if err != nil {
log.Error(fmt.Errorf("error creating cache directory: %s", err))
return nil, err
}
}

// Set env name
setCfgName(cfg)

v, err := vsphere.New(log, *cfg, cacheFile)
if err != nil {
return nil, err
}

return v, nil
}

// look for file holodeck_ssh_key in GITHUB_WORKSPACE/holodeck_ssh_key
// if file not found, look for env var envKey
// if env var not found, return error
Expand Down
16 changes: 0 additions & 16 deletions cmd/cli/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/NVIDIA/holodeck/pkg/jyaml"
"github.com/NVIDIA/holodeck/pkg/provider"
"github.com/NVIDIA/holodeck/pkg/provider/aws"
"github.com/NVIDIA/holodeck/pkg/provider/vsphere"
"github.com/NVIDIA/holodeck/pkg/provisioner"
"github.com/NVIDIA/holodeck/pkg/utils"

Expand Down Expand Up @@ -140,14 +139,6 @@ func (m command) run(c *cli.Context, opts *options) error {
if err != nil {
return err
}
} else if opts.cfg.Spec.Provider == v1alpha1.ProviderVSphere {
if opts.cfg.Spec.Auth.Username == "" {
opts.cfg.Spec.Auth.Username = "nvidia"
}
provider, err = vsphere.New(m.log, opts.cfg, opts.cachefile)
if err != nil {
return err
}
} else if opts.cfg.Spec.Provider == v1alpha1.ProviderSSH {
// If username is not provided, use the current user
if opts.cfg.Spec.Username == "" {
Expand Down Expand Up @@ -190,13 +181,6 @@ func runProvision(log *logger.FunLogger, opts *options) error {
break
}
}
} else if opts.cfg.Spec.Provider == v1alpha1.ProviderVSphere {
for _, p := range opts.cache.Status.Properties {
if p.Name == vsphere.IpAddress {
hostUrl = p.Value
break
}
}
} else if opts.cfg.Spec.Provider == v1alpha1.ProviderSSH {
hostUrl = opts.cfg.Spec.Instance.HostUrl
}
Expand Down
29 changes: 1 addition & 28 deletions cmd/cli/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/NVIDIA/holodeck/internal/logger"
"github.com/NVIDIA/holodeck/pkg/jyaml"
"github.com/NVIDIA/holodeck/pkg/provider/aws"
"github.com/NVIDIA/holodeck/pkg/provider/vsphere"

cli "github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -81,7 +80,7 @@ func (m command) build() *cli.Command {
return fmt.Errorf("error reading config file: %s", err)
}

if opts.cfg.Spec.Provider != v1alpha1.ProviderAWS && opts.cfg.Spec.Provider != v1alpha1.ProviderVSphere {
if opts.cfg.Spec.Provider != v1alpha1.ProviderAWS {
return fmt.Errorf("provider %s not supported", opts.cfg.Spec.Provider)
}

Expand Down Expand Up @@ -122,13 +121,7 @@ func (m command) run(c *cli.Context, opts *options) error {
m.log.Error(err)
m.log.Exit(1)
}
} else if cfg.Spec.Provider == v1alpha1.ProviderVSphere {
if err := deleteVSphere(m.log, cfg, cachefile); err != nil {
m.log.Error(err)
m.log.Exit(1)
}
}

m.log.Info("Successfully deleted environment %s\n", cfg.Name)

return nil
Expand All @@ -153,23 +146,3 @@ func deleteAWS(log *logger.FunLogger, cfg v1alpha1.Environment, cachefile string

return nil
}

func deleteVSphere(log *logger.FunLogger, cfg v1alpha1.Environment, cachefile string) error {
client, err := vsphere.New(log, cfg, cachefile)
if err != nil {
return err
}

// check if cache exists
if _, err := os.Stat(cachefile); err != nil {
fmt.Printf("Error reading cache file: %s\n", err)
fmt.Printf("Cache file %s does not exist\n", cachefile)
os.Exit(1)
}

if err := client.Delete(); err != nil {
return err
}

return nil
}
19 changes: 0 additions & 19 deletions cmd/cli/dryrun/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/NVIDIA/holodeck/internal/logger"
"github.com/NVIDIA/holodeck/pkg/jyaml"
"github.com/NVIDIA/holodeck/pkg/provider/aws"
"github.com/NVIDIA/holodeck/pkg/provider/vsphere"
"github.com/NVIDIA/holodeck/pkg/provisioner"
"golang.org/x/crypto/ssh"

Expand Down Expand Up @@ -93,11 +92,6 @@ func (m command) run(c *cli.Context, opts *options) error {
if err != nil {
return err
}
case v1alpha1.ProviderVSphere:
err := validateVSphere(m.log, opts)
if err != nil {
return err
}
case v1alpha1.ProviderSSH:
// if username is not provided, use the current user
if opts.cfg.Spec.Username == "" {
Expand Down Expand Up @@ -133,19 +127,6 @@ func validateAWS(log *logger.FunLogger, opts *options) error {
return nil
}

func validateVSphere(log *logger.FunLogger, opts *options) error {
client, err := vsphere.New(log, opts.cfg, opts.envFile)
if err != nil {
return err
}

if err = client.DryRun(); err != nil {
return err
}

return nil
}

// createSshClient creates a ssh client, and retries if it fails to connect
func connectOrDie(keyPath, userName, hostUrl string) error {
var err error
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
github.com/urfave/cli/v2 v2.27.4
github.com/vmware/govmomi v0.42.0
golang.org/x/crypto v0.27.0
k8s.io/apimachinery v0.31.1
sigs.k8s.io/controller-runtime v0.19.0
Expand Down Expand Up @@ -44,6 +43,7 @@ require (
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
5 changes: 1 addition & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM=
github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand All @@ -54,8 +55,6 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA=
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
Expand Down Expand Up @@ -97,8 +96,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
github.com/vmware/govmomi v0.42.0 h1:MbvAlVfjNBE1mHMaQ7yOSop1KLB0/93x6VAGuCtjqtI=
github.com/vmware/govmomi v0.42.0/go.mod h1:1H5LWwsBif8HKZqbFp0FdoKTHyJE4FzL6ACequMKYQg=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
Expand Down
3 changes: 0 additions & 3 deletions hack/e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ GINKGO_FOCUS=${GINKGO_FOCUS:-}
if [ "$1" == "aws" ]; then
ENV_FILE=${ROOT_DIR}/tests/test_aws.yml
GINKGO_FOCUS=${GINKGO_FOCUS:-"AWS"}
elif [ "$1" == "vsphere" ]; then
ENV_FILE=${ROOT_DIR}/tests/test_vsphere.yml
GINKGO_FOCUS=${GINKGO_FOCUS:-"VSPHERE"}
fi

# Set all ENV variables for e2e tests
Expand Down
Loading

0 comments on commit d312f78

Please sign in to comment.