Repository: kubernetes-sigs/security-profiles-operator
Pull request #1756 (2023-06-15 12:24:37)

Fix e2e tests


#### What type of PR is this?


/kind failing-test

#### What this PR does / why we need it:

The e2e test are regularly failing in prow.
#### Which issue(s) this PR fixes:

None

#### Does this PR have test?

None

#### Special notes for your reviewer:
None
#### Does this PR introduce a user-facing change?

<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".

For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note
None
```


k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/1756#" title="Author self-approved">saschagrunert</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fsecurity-profiles-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/security-profiles-operator/blob/main/OWNERS)~~ [saschagrunert]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
codecov-commenter: ## [Codecov](https://app.codecov.io/gh/kubernetes-sigs/security-profiles-operator/pull/1756?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) Report
> Merging [#1756](https://app.codecov.io/gh/kubernetes-sigs/security-profiles-operator/pull/1756?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (284c370) into [main](https://app.codecov.io/gh/kubernetes-sigs/security-profiles-operator/commit/45cd463d78cfcc88ec5b81ae744c6a3c65b3b255?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubernetes-sigs) (45cd463) will **not change** coverage.
> The diff coverage is `n/a`.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #1756   +/-   ##
=======================================
  Coverage   49.12%   49.12%           
=======================================
  Files          71       71           
  Lines        6982     6982           
=======================================
  Hits         3430     3430           
  Misses       3418     3418           
  Partials      134      134           
```

</details>
k8s-ci-robot: @saschagrunert: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-security-profiles-operator-verify | 284c3701e43ff06431a554c4757f9b661941aa59 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_security-profiles-operator/1756/pull-security-profiles-operator-verify/1669329476539912192) | true | `/test pull-security-profiles-operator-verify`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=security-profiles-operator&pr=1756). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Asaschagrunert). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/security-profiles-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @saschagrunert: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-security-profiles-operator-test-e2e | 73698ebdde600d1c20f0d9e9770e4fda5300c193 | [link](https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_security-profiles-operator/1756/pull-security-profiles-operator-test-e2e/1669600203503570944) | true | `/test pull-security-profiles-operator-test-e2e`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=security-profiles-operator&pr=1756). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Asaschagrunert). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/security-profiles-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
saschagrunert: /retest

Patch:
diff --git a/.github/workflows/helm-chart-package.yaml b/.github/workflows/helm-chart-package.yaml
index 76ce86916..ecc523086 100644
--- a/.github/workflows/helm-chart-package.yaml
+++ b/.github/workflows/helm-chart-package.yaml
@@ -26,8 +26,8 @@ jobs:
           tgz_path="${helm_output##*saved it to: }"
           echo "helm chart tgz path: '${tgz_path}'"
           [ ! -f "${tgz_path}" ] && echo "failed to find helm chart from 'helm package' stdout" && exit 1
-          echo "::set-output name=helm_tgz_path::${tgz_path}"
-          echo "::set-output name=helm_tgz_name::${tgz_path##*/}"
+          echo "helm_tgz_path=${tgz_path}" >> $GITHUB_OUTPUT
+          echo "helm_tgz_name=${tgz_path##*/}" >> $GITHUB_OUTPUT
       - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
         with:
           name: ${{ steps.package.outputs.helm_tgz_name}}


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index a7839e5a5..596c94225 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -139,7 +139,7 @@ jobs:
       - name: Vagrant box version
         id: vagrant-box
         run: |
-          echo "::set-output name=version::$(curl -s  https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_vagrant.json | jq '.versions[0].version' | tr -d '".')"
+          echo "version=$(curl -s  https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_vagrant.json | jq '.versions[0].version' | tr -d '".')" >> $GITHUB_OUTPUT
         shell: bash
       - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
         with:
diff --git a/test/tc_base_profiles_oci_test.go b/test/tc_base_profiles_oci_test.go
index 63f8178f1..f20f31c27 100644
--- a/test/tc_base_profiles_oci_test.go
+++ b/test/tc_base_profiles_oci_test.go
@@ -34,11 +34,13 @@ func (e *e2e) testCaseBaseProfileOCI([]string) {
 		baseProfileName += strings.ReplaceAll(baseProfileNameRunc, "-", ":")
 	}
 
+	namespace := e.getCurrentContextNamespace(defaultNamespace)
 	helloProfile := fmt.Sprintf(`
 apiVersion: security-profiles-operator.x-k8s.io/v1beta1
 kind: SeccompProfile
 metadata:
   name: hello
+  namespace: %s
 spec:
   defaultAction: SCMP_ACT_ERRNO
   baseProfileName: %s
@@ -48,13 +50,14 @@ spec:
     - arch_prctl
     - set_tid_address
     - exit_group
-`, baseProfileName)
+`, namespace, baseProfileName)
 
-	const helloPod = `
+	helloPod := fmt.Sprintf(`
 apiVersion: v1
 kind: Pod
 metadata:
   name: hello
+  namespace: %s
 spec:
   containers:
   - image: quay.io/security-profiles-operator/test-hello-world:latest
@@ -64,7 +67,7 @@ spec:
       type: Localhost
       localhostProfile: operator/%s/hello.json
   restartPolicy: OnFailure
-`
+`, namespace, namespace)
 
 	e.logf("Creating hello profile")
 	helloProfileFile, err := os.CreateTemp("", "hello-profile*.yaml")
@@ -86,8 +89,7 @@ spec:
 	e.Nil(err)
 	defer os.Remove(helloPodFile.Name())
 
-	namespace := e.getCurrentContextNamespace(defaultNamespace)
-	_, err = fmt.Fprintf(helloPodFile, helloPod, namespace)
+	_, err = helloPodFile.WriteString(helloPod)
 	e.Nil(err)
 	err = helloPodFile.Close()
 	e.Nil(err)
@@ -103,6 +105,10 @@ spec:
 		if strings.Contains(output, "Completed") {
 			break
 		}
+		if strings.Contains(output, "CreateContainerError") {
+			output := e.kubectl("describe", "pod", "hello")
+			e.FailNowf("Unable to create container: %v", output)
+		}
 		time.Sleep(time.Second)
 	}