Skip to content

Commit 85d1df7

Browse files
committed
Improve OpenShift provisioning consistency
1 parent aa35761 commit 85d1df7

File tree

5 files changed

+67
-10
lines changed

5 files changed

+67
-10
lines changed

test/e2e-framework/components/kubernetes/openshift.go

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import (
99
"regexp"
1010
"strings"
1111

12+
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
13+
1214
"github.com/DataDog/datadog-agent/test/e2e-framework/common/config"
1315
"github.com/DataDog/datadog-agent/test/e2e-framework/common/utils"
1416
"github.com/DataDog/datadog-agent/test/e2e-framework/components"
1517
"github.com/DataDog/datadog-agent/test/e2e-framework/components/command"
1618
oscomp "github.com/DataDog/datadog-agent/test/e2e-framework/components/os"
1719
"github.com/DataDog/datadog-agent/test/e2e-framework/components/remote"
18-
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
1920
)
2021

2122
func NewLocalOpenShiftCluster(env config.Env, name string, pullSecretPath string, opts ...pulumi.ResourceOption) (*Cluster, error) {
@@ -136,9 +137,61 @@ func NewOpenShiftCluster(env config.Env, vm *remote.Host, name string, pullSecre
136137
return err
137138
}
138139

139-
clusterComp.KubeConfig = pulumi.All(kubeConfig.StdoutOutput(), vm.Address).ApplyT(func(args []interface{}) string {
140+
// Wait for the control plane to be fully ready before proceeding
141+
waitControlPlane, err := runner.Command(commonEnvironment.CommonNamer().ResourceName("wait-control-plane-ready"), &command.Args{
142+
Create: pulumi.String(`
143+
# Wait for API server to be responsive
144+
for i in {1..30}; do
145+
if curl -sk https://127.0.0.1:6443/healthz 2>/dev/null | grep -q ok; then
146+
echo "API server responsive"
147+
break
148+
fi
149+
echo "Waiting for API server (attempt $i/30)..."
150+
sleep 10
151+
done
152+
153+
export KUBECONFIG=~/.crc/machines/crc/kubeconfig
154+
155+
# Wait for nodes to be ready
156+
echo "Waiting for nodes to be Ready..."
157+
for i in {1..60}; do
158+
ready_nodes=$(kubectl get nodes --no-headers 2>/dev/null | grep -c ' Ready ')
159+
if [ "$ready_nodes" -gt 0 ]; then
160+
echo "Found $ready_nodes Ready nodes"
161+
break
162+
fi
163+
echo "Waiting for nodes (attempt $i/60)..."
164+
sleep 5
165+
done
166+
167+
# Wait for some system pods to be running
168+
echo "Waiting for system pods to be running..."
169+
for namespace in openshift-kube-apiserver openshift-kube-controller-manager; do
170+
for i in {1..60}; do
171+
running_pods=$(kubectl get pods -n "$namespace" --field-selector=status.phase=Running --no-headers 2>/dev/null | wc -l)
172+
if [ "$running_pods" -gt 0 ]; then
173+
echo "Namespace $namespace has $running_pods running pod(s)"
174+
break
175+
fi
176+
if [ $i -lt 60 ]; then
177+
echo "Waiting for $namespace pods (attempt $i/60)..."
178+
sleep 5
179+
fi
180+
done
181+
done
182+
183+
echo "Control plane is ready"
184+
exit 0
185+
`),
186+
}, utils.MergeOptions(opts, utils.PulumiDependsOn(kubeConfig))...)
187+
if err != nil {
188+
return err
189+
}
190+
191+
clusterComp.KubeConfig = pulumi.All(kubeConfig.StdoutOutput(), vm.Address, waitControlPlane.StdoutOutput()).ApplyT(func(args []interface{}) string {
140192
kubeconfigRaw := args[0].(string)
141193
vmIP := args[1].(string)
194+
// args[2] is the output from waitControlPlane, ensuring it completes first
142195
allowInsecure := regexp.MustCompile("certificate-authority-data:.+").ReplaceAllString(kubeconfigRaw, "insecure-skip-tls-verify: true")
143196
updated := strings.ReplaceAll(allowInsecure, "api.crc.testing:6443", vmIP+":8443")
144197
return updated

test/e2e-framework/run/Pulumi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: dd
1+
name: e2elocal
22
runtime: go
33
description: Generic scenario (check scenario variable)
44
config:

test/e2e-framework/testing/provisioners/gcp/kubernetes/openshiftvm/openshiftvm.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func OpenShiftVMRunFunc(ctx *pulumi.Context, env *environments.Kubernetes, param
130130
osDesc := os.DescriptorFromString("redhat:9", os.RedHat9)
131131
vm, err := compute.NewVM(gcpEnv, "openshift",
132132
compute.WithOS(osDesc),
133-
compute.WithInstancetype("n2-standard-8"),
133+
compute.WithInstancetype("n2-standard-16"),
134134
compute.WithNestedVirt(true),
135135
)
136136
if err != nil {
@@ -163,7 +163,13 @@ func OpenShiftVMRunFunc(ctx *pulumi.Context, env *environments.Kubernetes, param
163163
// Deploy a fakeintake
164164
var fakeIntake *fakeintakeComp.Fakeintake
165165
if params.fakeintakeOptions != nil {
166-
fakeIntake, err = fakeintake.NewVMInstance(gcpEnv, params.fakeintakeOptions...)
166+
fakeIntakeOptions := []fakeintake.Option{
167+
fakeintake.WithMemory(6144),
168+
}
169+
if gcpEnv.InfraShouldDeployFakeintakeWithLB() {
170+
fakeIntakeOptions = append(fakeIntakeOptions, fakeintake.WithLoadBalancer())
171+
}
172+
fakeIntake, err = fakeintake.NewVMInstance(gcpEnv, fakeIntakeOptions...)
167173
if err != nil {
168174
return err
169175
}

test/new-e2e/tests/containers/k8s_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (suite *k8sSuite) TearDownSuite() {
9898
func (suite *k8sSuite) Test00UpAndRunning() {
9999
timeout := 10 * time.Minute
100100
// Windows FIPS images are bigger and take longer to pull and start
101-
if suite.Env().Agent.FIPSEnabled {
101+
if suite.Env().Agent.FIPSEnabled || suite.runtime == "cri-o" {
102102
timeout = 20 * time.Minute
103103
}
104104
suite.testUpAndRunning(timeout)
@@ -1118,12 +1118,12 @@ func (suite *k8sSuite) TestDogstatsdInAgent() {
11181118
return
11191119
}
11201120

1121+
// Test with UDS
1122+
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS)
11211123
// Test with UDP + Origin detection
11221124
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPOrigin)
11231125
// Test with UDP + DD_ENTITY_ID
11241126
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDP)
1125-
// Test with UDS
1126-
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS)
11271127
// Test with UDS + CSI Driver
11281128
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDSWithCSI)
11291129
}

test/new-e2e/tests/containers/openshiftvm_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ type openShiftVMSuite struct {
2323
func TestOpenShiftVMSuite(t *testing.T) {
2424
e2e.Run(t, &openShiftVMSuite{}, e2e.WithProvisioner(gcpopenshiftvm.OpenshiftVMProvisioner(
2525
gcpopenshiftvm.WithFakeIntakeOptions(
26-
gcpfakeintake.WithMemory(2048),
2726
gcpfakeintake.WithLoadBalancer(),
28-
gcpfakeintake.WithoutDDDevForwarding(),
2927
gcpfakeintake.WithRetentionPeriod("1h"),
3028
),
3129
gcpopenshiftvm.WithAgentOptions(

0 commit comments

Comments
 (0)