Skip to content

Commit

Permalink
dynamic holodeck ci instance name
Browse files Browse the repository at this point in the history
Signed-off-by: shiva kumar <shivaku@nvidia.com>
  • Loading branch information
shivakunv committed Dec 15, 2024
1 parent d3280cd commit 974bb03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion cmd/action/ci/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"math/rand"
"os"
"strings"

"github.com/NVIDIA/holodeck/api/holodeck/v1alpha1"
"github.com/NVIDIA/holodeck/internal/logger"
Expand Down Expand Up @@ -133,7 +134,13 @@ func setCfgName(cfg *v1alpha1.Environment) {
// uid is unique for each run
uid := generateUID()

cfg.Name = fmt.Sprintf("ci%s-%s-%s", attempt, sha, uid)
actor := os.Getenv("GITHUB_ACTOR")
branchName := os.Getenv("GITHUB_REF_NAME")
repo_name := os.Getenv("GITHUB_REPOSITORY")
parts := strings.Split(repo_name, "/")
repoName := parts[len(parts)-1]

cfg.Name = fmt.Sprintf("ci%s-%s-%s-%s-%s-%s", attempt, actor, branchName, repoName, sha, uid)
}

func generateUID() string {
Expand Down
9 changes: 7 additions & 2 deletions pkg/provisioner/templates/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ export KUBECONFIG="${HOME}/.kube/config"
# Install Calico
# based on https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
with_retry 3 10s kubectl --kubeconfig $KUBECONFIG apply -f https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/tigera-operator.yaml
echo "SHIVAAAAAAAAAAAAAAAAAAAAA"
#with_retry 3 10s kubectl --kubeconfig $KUBECONFIG apply -f https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/tigera-operator.yaml
with_retry 3 10s kubectl --kubeconfig $KUBECONFIG create -f https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/tigera-operator.yaml
#with_retry 3 10s kubectl --kubeconfig $KUBECONFIG apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
# Calico CRDs created. Now we sleep for 10s to ensure they are fully registered in the K8s etcd
sleep 10s
with_retry 3 10s kubectl --kubeconfig $KUBECONFIG apply -f https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/custom-resources.yaml
# with_retry 3 10s kubectl --kubeconfig $KUBECONFIG apply -f https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/custom-resources.yaml
with_retry 3 10s kubectl --kubeconfig $KUBECONFIG create -f https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/custom-resources.yaml
#with_retry 3 10s kubectl --kubeconfig $KUBECONFIG apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml
# Make single-node cluster schedulable
kubectl taint nodes --all node-role.kubernetes.io/control-plane:NoSchedule-
kubectl label node --all node-role.kubernetes.io/worker=
Expand Down

0 comments on commit 974bb03

Please sign in to comment.