-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix PostCommit XVR GoUsingJava Dataflow job #36757
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
Changes from 5 commits
ea096bb
28f4a84
ada02cc
c56f25d
9cfb002
738b2c8
eb363fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,11 +372,56 @@ def buildAndPushDockerPythonContainer = tasks.create("buildAndPushDockerPythonCo | |
| root: "apache", | ||
| tag: project.sdk_version) | ||
| doLast { | ||
| def imageExists = false | ||
| try { | ||
| exec { | ||
| commandLine "docker", "inspect", "--type=image", "${defaultDockerImageName}" | ||
| ignoreExitValue = false | ||
| } | ||
| imageExists = true | ||
| } catch (Exception e) { | ||
| println "Image ${defaultDockerImageName} not found locally: ${e.message}" | ||
|
||
| println "Attempting to load image from buildx cache..." | ||
|
|
||
| def pythonContainerProject = project.project(":sdks:python:container:py${pythonVer.replace('.', '')}") | ||
| def dockerBuildDir = pythonContainerProject.tasks.getByName("dockerPrepare").destinationDir | ||
| def dockerfile = new File(pythonContainerProject.projectDir, "../Dockerfile") | ||
|
|
||
| def loadResult = exec { | ||
| commandLine "sh", "-c", """ | ||
| cd ${dockerBuildDir} && \\ | ||
| docker buildx build --output type=docker \\ | ||
| --tag ${defaultDockerImageName} \\ | ||
| --build-arg py_version=${pythonVer} \\ | ||
| --build-arg pull_licenses=true \\ | ||
| -f ${dockerfile.absolutePath} \\ | ||
| . | ||
| """ | ||
| ignoreExitValue = true | ||
| } | ||
|
|
||
| if (loadResult.exitValue != 0) { | ||
| println "Failed to load from buildx cache. Attempting to pull from registry..." | ||
| def pullResult = exec { | ||
| commandLine "docker", "pull", "${defaultDockerImageName}" | ||
| ignoreExitValue = true | ||
| } | ||
|
|
||
| if (pullResult.exitValue != 0) { | ||
| throw new GradleException( | ||
| "Docker image ${defaultDockerImageName} not found locally, in buildx cache, or in registry. " + | ||
| "Check the Docker build output for errors." | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| exec { | ||
| commandLine "docker", "tag", "${defaultDockerImageName}", "${dockerPythonImageName}" | ||
| } | ||
| exec { | ||
| commandLine "gcloud", "docker", "--", "push", "${dockerPythonImageName}" | ||
| environment "CLOUDSDK_CONFIG", System.getenv("CLOUDSDK_CONFIG") ?: System.getProperty("user.home") + "/.config/gcloud" | ||
| commandLine "docker", "push", "${dockerPythonImageName}" | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other Dataflow XVR tests also push containers in order to run tests: https://github.com/apache/beam/blob/master/.github/workflows/beam_PostCommit_XVR_PythonUsingJava_Dataflow.yml
but what's the reason only this one requires environment setup in github action yaml file? In general we wish to keep GHA yaml minimum, and aims to make gradle target self contained so developers can test the target locally, or in different environment, not necessarily rely on GitHub Action runner to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this workflow needs the explicit CLOUDSDK_CONFIG setup is because we were hitting specific permission errors that weren't occurring in the PythonUsingJava workflow. The original KUBELET_GCLOUD_CONFIG_PATH points to a read only directory in the Kubernetes pod, causing gcloud to crash when trying to write its config files.
error from logs:
WARNING: Could not setup log file in /var/lib/kubelet/pods/.../volumes/kubernetes.io~empty-dir/gcloud/logs, (Error: Could not create directory [...] Permission denied.
ERROR: gcloud crashed (OperationalError): unable to open database file
denied: Permission "artifactregistry.repositories.uploadArtifacts" denied on resource "projects/apache-beam-testing/locations/us/repositories/us.gcr.io"