Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/action/ci/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const (
cacheFile = "/github/workspace/.cache/holodeck.yaml"
kubeconfig = "/github/workspace/kubeconfig"
sshKeyFile = "/github/workspace/.cache/key.pem"
// Default EC2 instance UserName for ubuntu AMI's
username = "ubuntu"
)

func Run(log *logger.FunLogger) error {
Expand All @@ -43,6 +41,7 @@ func Run(log *logger.FunLogger) error {
}
} else {
if err := entrypoint(log); err != nil {
log.Error(err)
if err := cleanup(log); err != nil {
return err
}
Expand Down
39 changes: 19 additions & 20 deletions cmd/action/ci/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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 @@ -64,30 +65,28 @@ func entrypoint(log *logger.FunLogger) error {
return fmt.Errorf("failed to read cache file: %v", err)
}

// Get the host url
var hostUrl string
var instanceID string
var vpcID string
for _, p := range cache.Status.Properties {
switch p.Name {
case aws.PublicDnsName:
hostUrl = p.Value
case aws.InstanceID:
instanceID = p.Value
case aws.VpcID:
vpcID = p.Value
default:
continue
var username string
if cfg.Spec.Provider == v1alpha1.ProviderAWS {
username = "ubuntu"
for _, p := range cache.Status.Properties {
if p.Name == aws.PublicDnsName {
hostUrl = p.Value
break
}
}
} else if cfg.Spec.Provider == v1alpha1.ProviderVSphere {
username = "nvidia"
for _, p := range cache.Status.Properties {
if p.Name == vsphere.IpAddress {
hostUrl = p.Value
break
}
}
}

// Tag the instance with info the GitHub event
resources := []string{instanceID, vpcID}
tags := instanceTags()
err = provider.UpdateResourcesTags(tags, resources...)
if err != nil {
return err
}

// Run the provisioner
p, err := provisioner.New(log, sshKeyFile, username, hostUrl)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion cmd/action/ci/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func newAwsProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*aws.Provi

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = username
cfg.Spec.Auth.Username = "ubuntu"

// Set env name
setCfgName(&cfg)
Expand Down Expand Up @@ -112,6 +112,7 @@ func newVsphereProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*vsphe

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = "nvidia"

// Set env name
setCfgName(&cfg)
Expand Down