diff --git a/pkg/api/constant.go b/pkg/api/constant.go index 0f2940c0c9..ded5c02d6f 100644 --- a/pkg/api/constant.go +++ b/pkg/api/constant.go @@ -85,6 +85,8 @@ const ( NestedPodmanSCC = "nested-podman" NestedPodmanClusterRole = "nested-podman-creater" + + LeaseProxyServerPort = 8082 ) var ( diff --git a/pkg/prowgen/jobbase.go b/pkg/prowgen/jobbase.go index a0acc6398a..612d9f0ca1 100644 --- a/pkg/prowgen/jobbase.go +++ b/pkg/prowgen/jobbase.go @@ -146,6 +146,7 @@ func NewProwJobBaseBuilderForTest(configSpec *cioperatorapi.ReleaseBuildConfigur case test.MultiStageTestConfigurationLiteral != nil: if clusterProfile := test.MultiStageTestConfigurationLiteral.ClusterProfile; clusterProfile != "" { p.PodSpec.Add(LeaseClient()) + p.PodSpec.Add(LeaseProxyServer()) p.WithLabel(cioperatorapi.CloudClusterProfileLabel, string(clusterProfile)) p.WithLabel(cioperatorapi.CloudLabel, clusterProfile.ClusterType()) } @@ -158,6 +159,7 @@ func NewProwJobBaseBuilderForTest(configSpec *cioperatorapi.ReleaseBuildConfigur case test.MultiStageTestConfiguration != nil: if clusterProfile := test.MultiStageTestConfiguration.ClusterProfile; clusterProfile != "" { p.PodSpec.Add(LeaseClient()) + p.PodSpec.Add(LeaseProxyServer()) p.WithLabel(cioperatorapi.CloudClusterProfileLabel, string(clusterProfile)) p.WithLabel(cioperatorapi.CloudLabel, clusterProfile.ClusterType()) } diff --git a/pkg/prowgen/podspec.go b/pkg/prowgen/podspec.go index 44f67993ba..973e5e6d14 100644 --- a/pkg/prowgen/podspec.go +++ b/pkg/prowgen/podspec.go @@ -181,6 +181,13 @@ func addVolumeMount(container *corev1.Container, wantMount corev1.VolumeMount) e return nil } +func addPort(c *corev1.Container, name string, port int32) { + c.Ports = append(c.Ports, corev1.ContainerPort{ + Name: name, + ContainerPort: port, + }) +} + func makeSecretAddingMutator(secretName string) PodSpecMutator { return func(spec *corev1.PodSpec) error { safeName := strings.ReplaceAll(secretName, ".", "-") @@ -460,6 +467,15 @@ var ( MountPath: "/etc/boskos", ReadOnly: true, } + + leaseProxyServerEnv = corev1.EnvVar{ + Name: "CI_OPERATOR_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + } ) // LeaseClient configures ci-operator to be able to interact with Boskos (lease @@ -479,6 +495,14 @@ func LeaseClient() PodSpecMutator { } +func LeaseProxyServer() PodSpecMutator { + return func(spec *corev1.PodSpec) error { + container := &spec.Containers[0] + addPort(container, "lease-proxy", cioperatorapi.LeaseProxyServerPort) + return addEnvVar(container, leaseProxyServerEnv) + } +} + var ( hiveSecretVolume = corev1.Volume{ Name: cioperatorapi.HiveControlPlaneKubeconfigSecret, diff --git a/pkg/prowgen/testdata/zz_fixture_TestNewProwJobBaseBuilderForTest_multi_stage_test_with_cluster_profile.yaml b/pkg/prowgen/testdata/zz_fixture_TestNewProwJobBaseBuilderForTest_multi_stage_test_with_cluster_profile.yaml index 1866776d56..7fa05b9360 100644 --- a/pkg/prowgen/testdata/zz_fixture_TestNewProwJobBaseBuilderForTest_multi_stage_test_with_cluster_profile.yaml +++ b/pkg/prowgen/testdata/zz_fixture_TestNewProwJobBaseBuilderForTest_multi_stage_test_with_cluster_profile.yaml @@ -16,9 +16,17 @@ spec: - --target=simple command: - ci-operator + env: + - name: CI_OPERATOR_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest imagePullPolicy: Always name: "" + ports: + - containerPort: 8082 + name: lease-proxy resources: requests: cpu: 10m