From abfdf67deff56c01a93f28bc08dc79c2128fc2e7 Mon Sep 17 00:00:00 2001 From: Steve Sloka Date: Mon, 29 Nov 2021 15:18:49 -0500 Subject: [PATCH] review comments Signed-off-by: Steve Sloka --- .github/workflows/prbuild.yaml | 48 +++++++++--------- test/e2e/deployment.go | 69 +++++++------------------- test/e2e/deployment/deployment_test.go | 2 +- 3 files changed, 43 insertions(+), 76 deletions(-) diff --git a/.github/workflows/prbuild.yaml b/.github/workflows/prbuild.yaml index 3bc4c909319..404d770c60e 100644 --- a/.github/workflows/prbuild.yaml +++ b/.github/workflows/prbuild.yaml @@ -1,7 +1,7 @@ name: Build and Test Pull Request # Trigger the workflow on push or pull request -on: +on: push: pull_request: types: [opened, synchronize] @@ -74,7 +74,7 @@ jobs: status: ${{ job.status }} steps: ${{ toJson(steps) }} channel: '#contour-ci-notifications' - if: ${{ failure() && github.ref == 'refs/heads/main' }} + if: ${{ failure() && github.ref == 'refs/heads/main' }} build-image: needs: - lint @@ -82,27 +82,27 @@ jobs: - codegen runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - with: - version: latest - - name: Build image - env: - TAG_LATEST: "false" - run: | - make multiarch-build - - name: Upload image - uses: actions/upload-artifact@v2 - with: - name: image - path: image/contour-*.tar - - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#contour-ci-notifications' - if: ${{ failure() && github.ref == 'refs/heads/main' }} + - uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest + - name: Build image + env: + TAG_LATEST: "false" + run: | + make multiarch-build + - name: Upload image + uses: actions/upload-artifact@v2 + with: + name: image + path: image/contour-*.tar + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#contour-ci-notifications' + if: ${{ failure() && github.ref == 'refs/heads/main' }} e2e: runs-on: ubuntu-latest needs: @@ -320,4 +320,4 @@ jobs: status: ${{ job.status }} steps: ${{ toJson(steps) }} channel: '#contour-ci-notifications' - if: ${{ failure() && github.ref == 'refs/heads/main' }} \ No newline at end of file + if: ${{ failure() && github.ref == 'refs/heads/main' }} diff --git a/test/e2e/deployment.go b/test/e2e/deployment.go index f768fe50d46..6d9961dfe2a 100644 --- a/test/e2e/deployment.go +++ b/test/e2e/deployment.go @@ -541,55 +541,21 @@ func (d *Deployment) EnsureResourcesForLocalContour() error { } if d.EnvoyDeploymentMode == DaemonsetMode { - - // Add bootstrap ConfigMap as volume and add envoy admin volume on Envoy pods (also removes cert volume). - d.EnvoyDaemonSet.Spec.Template.Spec.Volumes = []v1.Volume{{ - Name: "envoy-config", - VolumeSource: v1.VolumeSource{ - ConfigMap: &v1.ConfigMapVolumeSource{ - LocalObjectReference: v1.LocalObjectReference{ - Name: "envoy-bootstrap", - }, - }, - }, - }, { - Name: "envoy-admin", - VolumeSource: v1.VolumeSource{ - EmptyDir: &v1.EmptyDirVolumeSource{}, - }, - }} - - // Remove cert volume mount. - d.EnvoyDaemonSet.Spec.Template.Spec.Containers[1].VolumeMounts = []v1.VolumeMount{ - d.EnvoyDaemonSet.Spec.Template.Spec.Containers[1].VolumeMounts[0], // Config mount - d.EnvoyDaemonSet.Spec.Template.Spec.Containers[1].VolumeMounts[2], // Admin mount - } - - d.EnvoyDaemonSet.Spec.Template.Spec.Volumes = append(d.EnvoyDaemonSet.Spec.Template.Spec.Volumes, d.EnvoyExtraVolumes...) - d.EnvoyDaemonSet.Spec.Template.Spec.Containers[1].VolumeMounts = append(d.EnvoyDaemonSet.Spec.Template.Spec.Containers[1].VolumeMounts, d.EnvoyExtraVolumeMounts...) - - // Remove init container. - d.EnvoyDaemonSet.Spec.Template.Spec.InitContainers = nil - - // Remove shutdown-manager container. - d.EnvoyDaemonSet.Spec.Template.Spec.Containers = d.EnvoyDaemonSet.Spec.Template.Spec.Containers[1:] - - // Expose the metrics & admin interfaces via host port to test from outside the kind cluster. - d.EnvoyDaemonSet.Spec.Template.Spec.Containers[0].Ports = append(d.EnvoyDaemonSet.Spec.Template.Spec.Containers[0].Ports, - v1.ContainerPort{ - Name: "metrics", - ContainerPort: 8002, - HostPort: 8002, - Protocol: v1.ProtocolTCP, - }) + d.EnvoyDaemonSet.Spec.Template = d.mutatePodTemplate(d.EnvoyDaemonSet.Spec.Template) return d.EnsureEnvoyDaemonSet() } + d.EnvoyDeployment.Spec.Template = d.mutatePodTemplate(d.EnvoyDeployment.Spec.Template) + // Set the ReplicaCount=1 d.EnvoyDeployment.Spec.Replicas = pointer.Int32(1) + return d.EnsureEnvoyDeployment() +} + +func (d *Deployment) mutatePodTemplate(pts v1.PodTemplateSpec) v1.PodTemplateSpec { // Add bootstrap ConfigMap as volume and add envoy admin volume on Envoy pods (also removes cert volume). - d.EnvoyDeployment.Spec.Template.Spec.Volumes = []v1.Volume{{ + pts.Spec.Volumes = []v1.Volume{{ Name: "envoy-config", VolumeSource: v1.VolumeSource{ ConfigMap: &v1.ConfigMapVolumeSource{ @@ -606,29 +572,30 @@ func (d *Deployment) EnsureResourcesForLocalContour() error { }} // Remove cert volume mount. - d.EnvoyDeployment.Spec.Template.Spec.Containers[1].VolumeMounts = []v1.VolumeMount{ - d.EnvoyDeployment.Spec.Template.Spec.Containers[1].VolumeMounts[0], // Config mount - d.EnvoyDeployment.Spec.Template.Spec.Containers[1].VolumeMounts[2], // Admin mount + pts.Spec.Containers[1].VolumeMounts = []v1.VolumeMount{ + pts.Spec.Containers[1].VolumeMounts[0], // Config mount + pts.Spec.Containers[1].VolumeMounts[2], // Admin mount } - d.EnvoyDeployment.Spec.Template.Spec.Volumes = append(d.EnvoyDeployment.Spec.Template.Spec.Volumes, d.EnvoyExtraVolumes...) - d.EnvoyDeployment.Spec.Template.Spec.Containers[1].VolumeMounts = append(d.EnvoyDeployment.Spec.Template.Spec.Containers[1].VolumeMounts, d.EnvoyExtraVolumeMounts...) + pts.Spec.Volumes = append(pts.Spec.Volumes, d.EnvoyExtraVolumes...) + pts.Spec.Containers[1].VolumeMounts = append(pts.Spec.Containers[1].VolumeMounts, d.EnvoyExtraVolumeMounts...) // Remove init container. - d.EnvoyDeployment.Spec.Template.Spec.InitContainers = nil + pts.Spec.InitContainers = nil // Remove shutdown-manager container. - d.EnvoyDeployment.Spec.Template.Spec.Containers = d.EnvoyDeployment.Spec.Template.Spec.Containers[1:] + pts.Spec.Containers = pts.Spec.Containers[1:] // Expose the metrics & admin interfaces via host port to test from outside the kind cluster. - d.EnvoyDeployment.Spec.Template.Spec.Containers[0].Ports = append(d.EnvoyDeployment.Spec.Template.Spec.Containers[0].Ports, + pts.Spec.Containers[0].Ports = append(pts.Spec.Containers[0].Ports, v1.ContainerPort{ Name: "metrics", ContainerPort: 8002, HostPort: 8002, Protocol: v1.ProtocolTCP, }) - return d.EnsureEnvoyDeployment() + + return pts } // DeleteResourcesForLocalContour ensures deletion of all resources diff --git a/test/e2e/deployment/deployment_test.go b/test/e2e/deployment/deployment_test.go index c6cd7911683..4247a25e35b 100644 --- a/test/e2e/deployment/deployment_test.go +++ b/test/e2e/deployment/deployment_test.go @@ -37,7 +37,7 @@ var ( cleanup []func() ) -func TestInfra(t *testing.T) { +func TestDeployment(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Deployment tests") }