Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
skip reachability test in airgapped (#31)
Browse files Browse the repository at this point in the history
* disable some prereq tests in airgapped

* disable some prereq tests in airgapped

* disable some prereq tests in airgapped

* disable some prereq tests in airgapped

* disable some prereq tests in airgapped

* PR comments
  • Loading branch information
doronyaary-runai authored Aug 4, 2024
1 parent cd0e059 commit 219cdd6
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 62 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ chmod +x ./preinstall-diagnostics-darwin-arm64 && \
--domain ${CONTROL_PLANE_FQDN} \
--cluster-domain ${CLUSTER_FQDN} \
--image-pull-secret ${IMAGE_PULL_SECRET_NAME} \
--image ${PRIVATE_REGISTRY_IMAGE_URL}
--image ${PRIVATE_REGISTRY_IMAGE_URL} --airgapped
```

### Example
Expand Down Expand Up @@ -88,6 +88,9 @@ Usage of ./preinstall-diagnostics-darwin-arm64:
URL the Run:AI service to check connectivity to (default "https://app.run.ai")
-version
Prints the binary version
-airgapped
skip reachability checks to external servers
```

## Build
Expand Down
30 changes: 15 additions & 15 deletions cmd/preinstall-diagnostics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
runaiSaasArgName = "saas-address"
outputArgName = "output"
versionArgName = "version"
airgappedArgName = "airgapped"
)

const (
Expand All @@ -33,19 +34,18 @@ const (

var (
runInternalClusterTests bool

clean bool
backendDomainFQDN string
clusterDomainFQDN string
image string
imagePullSecretName string
dryRun bool
runaiContainerRegistry string
runaiSaas string
output string
version bool

outputFile *os.File
clean bool
backendDomainFQDN string
clusterDomainFQDN string
image string
imagePullSecretName string
dryRun bool
runaiContainerRegistry string
runaiSaas string
output string
version bool
airgapped bool
outputFile *os.File
)

func init() {
Expand All @@ -62,7 +62,7 @@ func init() {
flag.StringVar(&runaiSaas, runaiSaasArgName, saas.RunAISaasAddress, "URL the Run:AI service to check connectivity to")
flag.StringVar(&output, outputArgName, defaultOutputFileName, "File to save the output to")
flag.BoolVar(&version, versionArgName, false, "Prints the binary version")

flag.BoolVar(&airgapped, airgappedArgName, false, "skip tests that require network access")
flag.Parse()
}

Expand All @@ -84,6 +84,6 @@ func main() {
logger := log.NewLogger(outputFile)

cli.Main(clean, dryRun, backendDomainFQDN, clusterDomainFQDN, image,
imagePullSecretName, runaiContainerRegistry, runaiSaas, version, logger)
imagePullSecretName, runaiContainerRegistry, runaiSaas, version, airgapped, logger)
}
}
7 changes: 5 additions & 2 deletions internal/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ import (
)

func Main(clean, dryRun bool, backendFQDN, clusterFQDN, image, imagePullSecretName, imageRegistry,
runaiSaas string, version bool, logger *log.Logger) {
runaiSaas string, version bool, airgapped bool, logger *log.Logger) {
if airgapped {
fmt.Println("airgapped")
}
if version {
fmt.Println(ver.Version)
return
}

creationOrder, deletionOrder := resources.TemplateResources(backendFQDN, image,
imagePullSecretName, imageRegistry, runaiSaas)
imagePullSecretName, imageRegistry, runaiSaas, airgapped)

if dryRun {
err := resources.PrintResources(creationOrder)
Expand Down
88 changes: 47 additions & 41 deletions internal/cmd/job/internal_cluster_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package job

import (
v2 "github.com/run-ai/preinstall-diagnostics/internal"
"github.com/run-ai/preinstall-diagnostics/internal/env"
internal_cluster_tests2 "github.com/run-ai/preinstall-diagnostics/internal/internal-cluster-tests"
"github.com/run-ai/preinstall-diagnostics/internal/log"
"strconv"
)

func runTestsAndAppendResults(logger *log.Logger) []v2.TestResult {
var testResults []v2.TestResult

osInfo, err := internal_cluster_tests2.ShowOSInfo()
if err != nil {
testResults = append(testResults, v2.TestResult{
Expand Down Expand Up @@ -61,51 +62,56 @@ func runTestsAndAppendResults(logger *log.Logger) []v2.TestResult {
})
}

reachable, err := internal_cluster_tests2.RunAIAuthProviderReachable()
airgapped, err := strconv.ParseBool(env.EnvOrDefault(env.AirgappedEnvVar, "false"))
if err != nil {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Auth Provider Reachable",
Result: false,
Message: err.Error(),
})
} else {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Auth Provider Reachable",
Result: reachable,
Message: "",
})
airgapped = false
}
if !airgapped {
reachable, err := internal_cluster_tests2.RunAIAuthProviderReachable()
if err != nil {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Auth Provider Reachable",
Result: false,
Message: err.Error(),
})
} else {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Auth Provider Reachable",
Result: reachable,
Message: "",
})
}

reachable, err = internal_cluster_tests2.RunAIPrometheusReachable()
if err != nil {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Prometheus Reachable",
Result: false,
Message: err.Error(),
})
} else {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Prometheus Reachable",
Result: reachable,
Message: "",
})
}
reachable, err = internal_cluster_tests2.RunAIPrometheusReachable()
if err != nil {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Prometheus Reachable",
Result: false,
Message: err.Error(),
})
} else {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Prometheus Reachable",
Result: reachable,
Message: "",
})
}

reachable, err = internal_cluster_tests2.RunAIBackendReachable()
if err != nil {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Backend Reachable",
Result: false,
Message: err.Error(),
})
} else {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Backend Reachable",
Result: reachable,
Message: "",
})
reachable, err = internal_cluster_tests2.RunAIBackendReachable()
if err != nil {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Backend Reachable",
Result: false,
Message: err.Error(),
})
} else {
testResults = append(testResults, v2.TestResult{
Name: "RunAI Backend Reachable",
Result: reachable,
Message: "",
})
}
}

err = internal_cluster_tests2.CheckNodeConnectivity(logger)
if err != nil {
testResults = append(testResults, v2.TestResult{
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package job
import (
"context"
"encoding/json"

v2 "github.com/run-ai/preinstall-diagnostics/internal"
"github.com/run-ai/preinstall-diagnostics/internal/env"
"github.com/run-ai/preinstall-diagnostics/internal/k8sclient"
Expand Down
1 change: 1 addition & 0 deletions internal/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
RegistryEnvVar = "REGISTRY"

RunAISaasEnvVar = "RUNAI_SAAS"
AirgappedEnvVar = "AIRGAPPED"
)

func EnvOrError(envVar string) (string, error) {
Expand Down
3 changes: 3 additions & 0 deletions internal/internal-cluster-tests/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func WaitForJobPodsToBeRunning(logger *log.Logger) error {
logger.LogF("waiting for pods to be available...")
availablePods := 0
for _, job := range jobs.Items {
if job.Status.Ready == nil {
continue
}
availablePods += int(*job.Status.Ready)
}

Expand Down
17 changes: 16 additions & 1 deletion internal/resources/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func CreateResources(objs []client.Object, kubeDynamicClient dynamic.Interface)
}

func TemplateResources(backendFQDN, image, imagePullSecretName,
imageRegistry, runaiSaas string) (creationOrder, deletionOrder []client.Object) {
imageRegistry, runaiSaas string, airgapped bool) (creationOrder, deletionOrder []client.Object) {
creationOrder = []client.Object{}

k8s, err := k8sclient.ClientSet()
Expand Down Expand Up @@ -121,6 +121,21 @@ func TemplateResources(backendFQDN, image, imagePullSecretName,
},
}
}
if airgapped {
job.Spec.Template.Spec.Containers[0].Env =
append(job.Spec.Template.Spec.Containers[0].Env,
v1.EnvVar{
Name: env.AirgappedEnvVar,
Value: "true",
})
} else {
job.Spec.Template.Spec.Containers[0].Env =
append(job.Spec.Template.Spec.Containers[0].Env,
v1.EnvVar{
Name: env.AirgappedEnvVar,
Value: "false",
})
}

if imageRegistry != "" {
job.Spec.Template.Spec.Containers[0].Env =
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ OUT_DIR=_out
BIN=preinstall-diagnostics

REGISTRY=gcr.io/run-ai-lab
VERSION=v2.16.19
VERSION=v2.18.14

IMAGE_DOCKER_FILE=cmd/preinstall-diagnostics/Dockerfile
IMAGE=$(REGISTRY)/preinstall-diagnostics:$(VERSION)
Expand Down

0 comments on commit 219cdd6

Please sign in to comment.