-
Notifications
You must be signed in to change notification settings - Fork 551
CNTRLPLANE-3646: make lifecycle binaries configurable for non-CI environments #9021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,15 @@ func main() { | |
| hypershiftBin = "hypershift" | ||
| } | ||
|
|
||
| specs := platform.ClusterSpecs("", "") | ||
| namespace := os.Getenv("HYPERSHIFT_NAMESPACE") | ||
| if namespace == "" { | ||
| namespace = lifecycle.DefaultNamespace | ||
| } | ||
|
|
||
| baseDomain := os.Getenv("HYPERSHIFT_BASE_DOMAIN") | ||
| infraIDFromName := os.Getenv("HYPERSHIFT_INFRA_ID_FROM_NAME") == "true" | ||
|
|
||
| specs := lifecycle.FilterClusterSpecs(platform.ClusterSpecs("", ""), os.Getenv("HYPERSHIFT_VARIANTS")) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| log.Printf("Destroying %d clusters derived from PROW_JOB_ID=%s", len(specs), prowJobID) | ||
|
|
||
|
|
@@ -67,7 +75,7 @@ func main() { | |
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| if err := destroyCluster(hypershiftBin, clusterName, spec.Variant, platform); err != nil { | ||
| if err := destroyCluster(hypershiftBin, clusterName, namespace, baseDomain, infraIDFromName, platform); err != nil { | ||
| log.Printf("WARNING: Failed to destroy cluster %s (%s): %v", clusterName, spec.Variant, err) | ||
| log.Printf("ACTION REQUIRED: cloud resources for cluster %s may be orphaned and need manual cleanup (resource group, DNS records, etc.)", clusterName) | ||
| mu.Lock() | ||
|
|
@@ -85,14 +93,21 @@ func main() { | |
| log.Printf("All clusters destroyed successfully") | ||
| } | ||
|
|
||
| func destroyCluster(hypershiftBin, name, variant string, platform lifecycle.PlatformConfig) error { | ||
| log.Printf("Destroying cluster %s (%s)", name, variant) | ||
| func destroyCluster(hypershiftBin, name, namespace, baseDomain string, infraIDFromName bool, platform lifecycle.PlatformConfig) error { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Not blocking — just noting the data-clump smell before it grows.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems worth a followup refactor |
||
| log.Printf("Destroying cluster %s", name) | ||
|
|
||
| args := []string{ | ||
| "destroy", "cluster", platform.Name(), | ||
| "--name=" + name, | ||
| "--namespace=" + namespace, | ||
| "--cluster-grace-period=" + clusterGracePeriod, | ||
| } | ||
| if infraIDFromName { | ||
| args = append(args, "--infra-id="+name) | ||
| } | ||
| if baseDomain != "" { | ||
| args = append(args, "--base-domain="+baseDomain) | ||
| } | ||
| args = append(args, platform.DestroyArgs()...) | ||
|
|
||
| log.Printf("Running: %s %v", hypershiftBin, args) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,11 @@ import ( | |
| ) | ||
|
|
||
| func main() { | ||
| hypershiftBinary := flag.String("hypershift-binary", "hypershift", "Path to the hypershift CLI binary") | ||
| defaultBinary := "hypershift" | ||
| if v := os.Getenv("HYPERSHIFT_BINARY"); v != "" { | ||
| defaultBinary = v | ||
| } | ||
| hypershiftBinary := flag.String("hypershift-binary", defaultBinary, "Path to the hypershift CLI binary") | ||
| flag.Parse() | ||
|
|
||
| prowJobID := os.Getenv("PROW_JOB_ID") | ||
|
|
@@ -52,7 +56,8 @@ func main() { | |
| log.Fatalf("Failed to initialize platform config: %v", err) | ||
| } | ||
|
|
||
| specs := platform.ClusterSpecs("", "") | ||
| variants := os.Getenv("HYPERSHIFT_VARIANTS") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: The pattern Fine for now, but if more env vars get added across all four binaries, a shared config loader in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree all this stuff needs cleaned up into a structure with uniform env handling applied and passed around |
||
| specs := lifecycle.FilterClusterSpecs(platform.ClusterSpecs("", ""), variants) | ||
| log.Printf("Dumping %d clusters derived from PROW_JOB_ID=%s", len(specs), prowJobID) | ||
|
|
||
| var wg sync.WaitGroup | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,7 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| testBinary = "bin/test-e2e-v2" | ||
| clusterNS = "clusters" | ||
| defaultVerbose = "false" | ||
| defaultVerbose = "false" | ||
| defaultGinkgoTimeout = "3h" | ||
| ) | ||
|
|
||
|
|
@@ -37,6 +35,11 @@ func main() { | |
| artifactDir := requireEnv("ARTIFACT_DIR") | ||
| releaseImage := os.Getenv("RELEASE_IMAGE_LATEST") | ||
|
|
||
| testBinary := "bin/test-e2e-v2" | ||
| if binDir := os.Getenv("E2EV2_BIN_DIR"); binDir != "" { | ||
| testBinary = filepath.Join(binDir, "test-e2e-v2") | ||
| } | ||
|
|
||
| eventuallyVerbose := os.Getenv("EVENTUALLY_VERBOSE") | ||
| if eventuallyVerbose == "" { | ||
| eventuallyVerbose = defaultVerbose | ||
|
|
@@ -51,7 +54,22 @@ func main() { | |
| // Let the platform set up any env vars it needs for tests. | ||
| platform.SetupTestEnv(sharedDir) | ||
|
|
||
| matrix := platform.TestMatrix(releaseImage) | ||
| variants := os.Getenv("HYPERSHIFT_VARIANTS") | ||
| specs := lifecycle.FilterClusterSpecs(platform.ClusterSpecs(releaseImage, os.Getenv("OCP_IMAGE_N1")), variants) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. observation (not blocking): Might be worth a brief comment here noting the assumption that env vars must be consistent across all four binaries.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this general consistency issue be applicable to every environment variable shared amongst the binaries? Not sure it's worth calling out this single instance. What may be lacking is a stable non-environment input passed through to all of the binaries if there's some concern of environment drift during the same workflow, or something. Seems like a systemic thing to follow up on? |
||
| matrix := lifecycle.FilterTestMatrix(platform.TestMatrix(releaseImage), specs) | ||
|
|
||
| // Allow overriding the label filter for all test groups. | ||
| if override := os.Getenv("GINKGO_LABEL_FILTER"); override != "" { | ||
| log.Printf("Overriding label filters with GINKGO_LABEL_FILTER=%s", override) | ||
| for i := range matrix.Parallel { | ||
| matrix.Parallel[i].LabelFilter = override | ||
| } | ||
| for i := range matrix.Sequential { | ||
| for j := range matrix.Sequential[i].Steps { | ||
| matrix.Sequential[i].Steps[j].LabelFilter = override | ||
| } | ||
| } | ||
| } | ||
|
|
||
| var ( | ||
| mu sync.Mutex | ||
|
|
@@ -67,7 +85,7 @@ func main() { | |
| defer wg.Done() | ||
| clusterName := readClusterName(sharedDir, g.ClusterFile) | ||
| log.Printf("Running %s tests against %s...", g.Name, clusterName) | ||
| err := runTestBinary(clusterName, g.LabelFilter, g.Skip, | ||
| err := runTestBinary(testBinary, clusterName, g.LabelFilter, g.Skip, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| filepath.Join(artifactDir, g.JUnitFile), g.ExtraEnv) | ||
| mu.Lock() | ||
| results = append(results, testResult{name: g.Name, err: err}) | ||
|
|
@@ -90,7 +108,7 @@ func main() { | |
| for i, step := range sg.Steps { | ||
| clusterName := readClusterName(sharedDir, step.ClusterFile) | ||
| log.Printf("Running %s tests against %s...", step.Name, clusterName) | ||
| err := runTestBinary(clusterName, step.LabelFilter, step.Skip, | ||
| err := runTestBinary(testBinary, clusterName, step.LabelFilter, step.Skip, | ||
| filepath.Join(artifactDir, step.JUnitFile), step.ExtraEnv) | ||
| mu.Lock() | ||
| results = append(results, testResult{name: step.Name, err: err}) | ||
|
|
@@ -126,7 +144,7 @@ func main() { | |
| log.Println("All test groups passed") | ||
| } | ||
|
|
||
| func runTestBinary(clusterName, labelFilter, skip, junitPath string, extraEnv []string) error { | ||
| func runTestBinary(testBinary, clusterName, labelFilter, skip, junitPath string, extraEnv []string) error { | ||
| ginkgoTimeout := os.Getenv("GINKGO_TIMEOUT") | ||
| if ginkgoTimeout == "" { | ||
| ginkgoTimeout = defaultGinkgoTimeout | ||
|
|
@@ -146,6 +164,10 @@ func runTestBinary(clusterName, labelFilter, skip, junitPath string, extraEnv [] | |
| cmd.Stdout = os.Stdout | ||
| cmd.Stderr = os.Stderr | ||
|
|
||
| clusterNS := os.Getenv("HYPERSHIFT_NAMESPACE") | ||
| if clusterNS == "" { | ||
| clusterNS = lifecycle.DefaultNamespace | ||
| } | ||
| cmd.Env = append(os.Environ(), | ||
| fmt.Sprintf("E2E_HOSTED_CLUSTER_NAME=%s", clusterName), | ||
| fmt.Sprintf("E2E_HOSTED_CLUSTER_NAMESPACE=%s", clusterNS), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.