From 3d3a221b0964251bd96219046d7fe7a91c4d6664 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 30 Jul 2024 15:27:22 +0200 Subject: [PATCH 1/8] Add platforms variable to image workflow Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 1f8b54a4..f57058f8 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -56,4 +56,5 @@ jobs: with: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} + platforms: linux/amd64,linux/arm64 context: . From 38b7fca2adcd8d692f8aaf65ebf6e332dfe1306b Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 30 Jul 2024 16:16:25 +0200 Subject: [PATCH 2/8] Run E2E on ARC Runner Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/e2e.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 19f96e15..88b24e2b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -25,8 +25,8 @@ on: jobs: e2e-tests: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{ github.event.workflow_run.event == 'push' }} + runs-on: pdx01-arc-runners + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v4 name: Check out code @@ -34,16 +34,14 @@ jobs: id: vars run: | echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV - - name: Set up Holodeck - uses: NVIDIA/holodeck@main + - name: Install Go + uses: actions/setup-go@v5 with: - aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + go-version: 'stable' + check-latest: true - name: Run e2e tests env: LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | make -f tests/Makefile e2e-test - name: Archive test logs From 3a35363b26ea409828b133348455cfb167c48789 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 30 Jul 2024 16:24:43 +0200 Subject: [PATCH 3/8] Test ARC runner Signed-off-by: Carlos Eduardo Arango Gutierrez --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c78f21f4..f11d49ef 100644 --- a/README.md +++ b/README.md @@ -113,4 +113,4 @@ Dryrun environment holodeck 🔍 ✔ Checking if image ami-0fe8bec493a81c7da is supported in region eu-north-1 ✔ Resolving dependencies 📦 Dryrun succeeded 🎉 -``` \ No newline at end of file +``` From c4b71aee9cdbf25edc37507f084efa1372afbdd6 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 30 Jul 2024 16:26:25 +0200 Subject: [PATCH 4/8] Test ARC runner Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/e2e.yml | 9 +++++++-- .github/workflows/go.yml | 1 - README.md | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 88b24e2b..558e67ea 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -39,11 +39,16 @@ jobs: with: go-version: 'stable' check-latest: true - - name: Run e2e tests + - name: Run e2e-aws tests env: LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs run: | - make -f tests/Makefile e2e-test + make -f tests/Makefile e2e-aws + - name: Run e2e-vsphere tests + env: + LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs + run: | + make -f tests/Makefile e2e-vsphere - name: Archive test logs if: ${{ failure() }} uses: actions/upload-artifact@v4 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index fa837c4e..9e215402 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -25,7 +25,6 @@ on: - release-* jobs: - build: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index f11d49ef..c78f21f4 100644 --- a/README.md +++ b/README.md @@ -113,4 +113,4 @@ Dryrun environment holodeck 🔍 ✔ Checking if image ami-0fe8bec493a81c7da is supported in region eu-north-1 ✔ Resolving dependencies 📦 Dryrun succeeded 🎉 -``` +``` \ No newline at end of file From 1e42aa3aeb6460912143891f12ddf1d436f59974 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Wed, 31 Jul 2024 14:58:47 +0200 Subject: [PATCH 5/8] Fix SHH handling Signed-off-by: Carlos Eduardo Arango Gutierrez --- action.yml | 4 ++-- cmd/action/ci/provider.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 4013f44d..82aaed31 100644 --- a/action.yml +++ b/action.yml @@ -24,10 +24,10 @@ runs: inputs: aws_access_key_id: description: 'AWS Access Key ID' - required: true + required: false aws_secret_access_key: description: 'AWS Secret Access Key' - required: true + required: false aws_ssh_key: description: 'AWS SSH Key' required: false diff --git a/cmd/action/ci/provider.go b/cmd/action/ci/provider.go index c70cb5e9..2ebc81f9 100644 --- a/cmd/action/ci/provider.go +++ b/cmd/action/ci/provider.go @@ -59,6 +59,19 @@ func newAwsProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*aws.Provi } } + // Get AWS_SSH_KEY and write it to a file + sshKey := os.Getenv("AWS_SSH_KEY") + if sshKey == "" { + log.Error(fmt.Errorf("ssh key not provided")) + os.Exit(1) + } + + err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600) + if err != nil { + log.Error(fmt.Errorf("error writing ssh key to file: %s", err)) + os.Exit(1) + } + // Set auth.PrivateKey cfg.Spec.Auth.PrivateKey = sshKeyFile cfg.Spec.Auth.Username = username @@ -84,6 +97,22 @@ func newVsphereProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*vsphe } } + // Get VSPHERE_SSH_KEY and write it to a file + sshKey := os.Getenv("VSPHERE_SSH_KEY") + if sshKey == "" { + log.Error(fmt.Errorf("ssh key not provided")) + os.Exit(1) + } + + err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600) + if err != nil { + log.Error(fmt.Errorf("error writing ssh key to file: %s", err)) + os.Exit(1) + } + + // Set auth.PrivateKey + cfg.Spec.Auth.PrivateKey = sshKeyFile + // Set env name setCfgName(&cfg) From 5cb05f39a5db52a533579309896f09082ad0e481 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Wed, 31 Jul 2024 15:01:03 +0200 Subject: [PATCH 6/8] Test new config Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/e2e.yml | 43 +++++++++++++++------------------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 558e67ea..5d41b6a9 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -15,18 +15,20 @@ name: End-to-end Tests on: - workflow_run: - workflows: [Go] - types: - - completed + push: + tags: + - 'v*.*.*' + branches: + - 'main' + - 'release-*' + pull_request: branches: - main - release-* jobs: e2e-tests: - runs-on: pdx01-arc-runners - if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: pdx01-dind-arc-runners steps: - uses: actions/checkout@v4 name: Check out code @@ -34,25 +36,12 @@ jobs: id: vars run: | echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: 'stable' - check-latest: true - - name: Run e2e-aws tests - env: - LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs - run: | - make -f tests/Makefile e2e-aws - - name: Run e2e-vsphere tests - env: - LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs - run: | - make -f tests/Makefile e2e-vsphere - - name: Archive test logs - if: ${{ failure() }} - uses: actions/upload-artifact@v4 + echo "VSPHERE_SSH_KEY<> $GITHUB_ENV + echo "${VSPHERE_SSH_KEY}" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + echo "HOLODECK_VCENTER_USERNAME=${HOLODECK_VCENTER_USERNAME}" >> $GITHUB_ENV + echo "HOLODECK_VCENTER_PASSWORD=${HOLODECK_VCENTER_PASSWORD}" >> $GITHUB_ENV + - name: Set up Holodeck + uses: NVIDIA/holodeck@main with: - name: e2e-test-logs - path: ./e2e_logs/ - retention-days: 15 + holodeck_config: "tests/test_vsphere.yml" From fe7429d62d5a882524e5b52b5a311be5f7404d25 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Wed, 31 Jul 2024 15:58:10 +0200 Subject: [PATCH 7/8] Set the hostUrl based on provider type Signed-off-by: Carlos Eduardo Arango Gutierrez --- cmd/action/ci/ci.go | 3 +-- cmd/action/ci/entrypoint.go | 39 ++++++++++++++++++------------------- cmd/action/ci/provider.go | 3 ++- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/cmd/action/ci/ci.go b/cmd/action/ci/ci.go index a4ef0916..929c5c5b 100644 --- a/cmd/action/ci/ci.go +++ b/cmd/action/ci/ci.go @@ -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 { @@ -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 } diff --git a/cmd/action/ci/entrypoint.go b/cmd/action/ci/entrypoint.go index ada7df7f..6e144086 100644 --- a/cmd/action/ci/entrypoint.go +++ b/cmd/action/ci/entrypoint.go @@ -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" ) @@ -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 diff --git a/cmd/action/ci/provider.go b/cmd/action/ci/provider.go index 2ebc81f9..03812a58 100644 --- a/cmd/action/ci/provider.go +++ b/cmd/action/ci/provider.go @@ -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) @@ -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) From 487b898ab4ec9f10b3f4775a50685f3de3d16831 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Wed, 31 Jul 2024 16:21:55 +0200 Subject: [PATCH 8/8] Ready for v0.2.1 Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/e2e.yml | 47 ++++++++++++++++++++------------------- cmd/action/ci/ci.go | 11 --------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 5d41b6a9..09b9ad48 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -15,33 +15,34 @@ name: End-to-end Tests on: - push: - tags: - - 'v*.*.*' - branches: - - 'main' - - 'release-*' - pull_request: + workflow_run: + workflows: [Go] + types: + - completed branches: - main - release-* jobs: e2e-tests: - runs-on: pdx01-dind-arc-runners + runs-on: pdx01-arc-runners + if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{ github.event.workflow_run.event == 'push' }} steps: - - uses: actions/checkout@v4 - name: Check out code - - name: Calculate build vars - id: vars - run: | - echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV - echo "VSPHERE_SSH_KEY<> $GITHUB_ENV - echo "${VSPHERE_SSH_KEY}" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - echo "HOLODECK_VCENTER_USERNAME=${HOLODECK_VCENTER_USERNAME}" >> $GITHUB_ENV - echo "HOLODECK_VCENTER_PASSWORD=${HOLODECK_VCENTER_PASSWORD}" >> $GITHUB_ENV - - name: Set up Holodeck - uses: NVIDIA/holodeck@main - with: - holodeck_config: "tests/test_vsphere.yml" + - uses: actions/checkout@v4 + name: Checkout code + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + check-latest: true + - name: Run e2e-aws tests + run: make -f tests/Makefile e2e-aws + - name: Run e2e-vsphere tests + run: make -f tests/Makefile e2e-vsphere + - name: Archive test logs + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: e2e-test-logs + path: ./e2e_logs/ + retention-days: 15 diff --git a/cmd/action/ci/ci.go b/cmd/action/ci/ci.go index 929c5c5b..b1031373 100644 --- a/cmd/action/ci/ci.go +++ b/cmd/action/ci/ci.go @@ -77,14 +77,3 @@ func generateUID() string { return string(b) } - -// instanceTags returns the tags to be applied to the holodeck instance -// based on the GitHub environment variables https://docs.github.com/en/actions/learn-github-actions/variables -func instanceTags() map[string]string { - return map[string]string{ - "GITHUB_JOB": os.Getenv("GITHUB_JOB"), - "GITHUB_REPOSITORY": os.Getenv("GITHUB_REPOSITORY"), - "GITHUB_ACTOR": os.Getenv("GITHUB_ACTOR"), - "GITHUB_SHA": os.Getenv("GITHUB_SHA"), - } -}