Skip to content
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

Create Custom Cypress Container Image for Content-Build #12435

Closed
3 of 12 tasks
olivereri opened this issue Feb 3, 2023 · 6 comments
Closed
3 of 12 tasks

Create Custom Cypress Container Image for Content-Build #12435

olivereri opened this issue Feb 3, 2023 · 6 comments
Assignees
Labels
CMS Team CMS Product team that manages both editor exp and devops DevOps CMS team practice area

Comments

@olivereri
Copy link
Contributor

olivereri commented Feb 3, 2023

Description

Implement a solution that allows Cypress test containers to execute without requiring root privileges.

Two Content-Build Github Actions (GHA) workflows run Cypress tests using container images. To execute without failure the containers are run with root privileges. When launched with those elevated privileges GHA runner servers file system privileges is changed to root. Other GHA workflows that run on the same runner servers fail due to the previous file system permission changes. To harmonize these workflows create a custom Cypress container image.

Acceptance Criteria

  • Custom Cypress container image exists that does not require root permissions to use.
  • Verify the new container image runs the continuous integration and accessibility Cypress jobs
  • Content-Build workflows that use a Cypress container image for tests don't run as root
  • Content-Build workflows runs the continuous integration and accessibility Cypress jobs without failures.

Relations:

department-of-veterans-affairs/va.gov-team#50148

Implementation Details

Proposed solution described here:
https://github.com/cypress-io/cypress-docker-images/tree/master/examples/included-as-non-root-mapped

Proposed tasks:

Team

Please check the team(s) that will do this work.

  • CMS Team
  • Public Websites
  • Facilities
  • User support
@olivereri olivereri added CMS Team CMS Product team that manages both editor exp and devops DevOps CMS team practice area Needs refining Issue status labels Feb 3, 2023
@timcosgrove
Copy link
Contributor

timcosgrove commented Feb 14, 2023

@olivereri just a note that when running the Cypress docker container build command, the user/uid that needs to be added to the Docker container is runner and the uid is 1001

@EWashb
Copy link
Contributor

EWashb commented Feb 15, 2023

Let's determine success metrics for this effort working. Do we have data on how much time we have lost for this issue? Can we gather the baseline metrics to track success over time?

@olivereri
Copy link
Contributor Author

Let's determine success metrics for this effort working. Do we have data on how much time we have lost for this issue? Can we gather the baseline metrics to track success over time?

I think from the last failure (mid Jan.) we pretty much lost a sprint to it. Other than that @timcosgrove did a good job discovering the failure rate:

https://dsva.slack.com/archives/CT4GZBM8F/p1676487279441419

Lastly, Github Actions integration with Datadog will definitely help record the metrics we want. We'll unfortunately have to wait for that functionality:

https://dsva.slack.com/archives/C01G6J7UGGH/p1676577201346119

@olivereri
Copy link
Contributor Author

Ultimately this didn't require creating custom containers to fix the base issue. The initial assumptions weren't entirely wrong. During local testing starting a container with -u 1001:1001 would fail. However, Content-Build repository GHA workflows accept -u 1001:1001 as an option and run the container without failing. This is despite the container not having a user with that UID.

All that was required to remediate this issue was to remove any options to run Cypress Containers that included the root user UID. The other part was to make sure all the ASG GHA runner instances had their permissions fixed in the /home/runner directory.

With the above two (2) items corrected Cypress tests that run in a container on Content-Build repository GHA runners no longer require root and are no longer a problem for other workflows.

@olivereri
Copy link
Contributor Author

Raw troubleshooting slack thread
https://dsva.slack.com/archives/CT4GZBM8F/p1677089769027479

@olivereri
Copy link
Contributor Author

The solution that closes this issue didn't require creating a custom container. It was determined that including the option to run as UID 1001 ran successfully without needing to modify the container. The ACs changed but that had no affect on the pointing for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMS Team CMS Product team that manages both editor exp and devops DevOps CMS team practice area
Projects
None yet
Development

No branches or pull requests

3 participants