[build] Fix rsync failure in Docker builds when SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD is enabled#24604
Conversation
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azpw run Azure.sonic-buildimage |
|
/AzurePipelines run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@saiarcot895 Please help review/approve/merge this change to fix the prod trixie build as well |
|
/azpw run Azure.sonic-buildimage |
|
/AzurePipelines run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@liushilongbuaa , @saiarcot895 Can you please help review? |
|
/azpw ms_conflict |
saiarcot895
left a comment
There was a problem hiding this comment.
I see Mellanox platform has been updated, what about Broadcom, VS, and Marvell platforms?
@saiarcot895 as we cannot test it for their platform we cannot do that for other vendors. |
|
@saiarcot895 , could you please approve if no more comments? |
@saiarcot895 , can you please ? |
|
@saiarcot895 Can you please review? Thanks |
|
VS can absolutely be tested; it's just a VM running on a system with at least 6GB of free RAM and 2 cores that can be spared. Additionally, because of the specificity of the command, I'd rather not see this diverge between different dockerfiles. This will just mean more maintenance work later when changes need to be made for whatever reason. |
|
Actually, one improvement is to make this into a macro in |
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…RD_FOR_BUILD is enabled When building with SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y, Docker multi-stage builds fail during rsync operations with the following error: rsync: [generator] failed to set times on "/changes-to-image": Read-only file system (30) rsync error: some files/attrs were not transferred (code 23) Root Cause: When SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD is enabled, Docker BuildKit treats bind mounts as read-only by default. The rsync command with -a flag (which includes -t for preserving times) attempts to set timestamps on the mounted directory itself, which fails when the mount is read-only. Solution: Add --omit-dir-times flag to rsync commands in Dockerfile.j2 templates to skip setting directory timestamps on the bind-mounted source directory. This prevents rsync from attempting to modify the read-only mount while still preserving all file timestamps and content. Impact: - Fixes builds with SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y - No functional impact on default builds - Updated 37 Dockerfile.j2 templates across dockers/ and platform/ Signed-off-by: david.zagury <[email protected]>
Signed-off-by: david.zagury <[email protected]>
| {%- endmacro %} | ||
|
|
||
| {% macro rsync_from_builder_stage() -%} | ||
| RUN --mount=type=bind,from=base,target=/changes-to-image rsync -axAX --omit-dir-times --no-D --exclude=/sys --exclude=/proc --exclude=/dev --exclude=resolv.conf /changes-to-image/ / |
There was a problem hiding this comment.
Have you considered doing it this way:
FROM scratch
COPY --from=base / /
Would that work too?
There was a problem hiding this comment.
@benoit-nexthop That was my initial approach, but because of differences in kernel settings around overlayfs, this could register as all files being changed even if there are no changes. More details in 0b85785.
|
Cherry-pick PR to 202511: #25093 |
…VE_DOCKERD_FOR_BUILD is enabled (sonic-net#24604) [build] Fix rsync failure in Docker builds when SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD is enabled
…_NATIVE_DOCKERD_FOR_BUILD is enabled This is the same fix as in sonic-net#24604 to the new otel docker Signed-off-by: david.zagury <[email protected]>
…_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD is enabled This is the same fix as in sonic-net#24604 to the new restapi-sidecar docker Signed-off-by: david.zagury <[email protected]>
…_NATIVE_DOCKERD_FOR_BUILD is enabled This is the same fix as in sonic-net#24604 to the new otel docker
…_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD is enabled This is the same fix as in sonic-net#24604 to the new restapi-sidecar docker Signed-off-by: david.zagury <[email protected]>
…_NATIVE_DOCKERD_FOR_BUILD is enabled (#25328) This is the same fix as in #24604 to the new otel docker - Why I did it When building SONiC with SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y, Docker multi-stage builds fail during rsync operations with the following error: rsync: [generator] failed to set times on "/changes-to-image": Read-only file system (30) rsync error: some files/attrs were not transferred (see previous errors) (code 23) This issue occurs specifically when: Using Docker Engine 20.10.x with BuildKit Running builds inside containers (Docker-in-Docker scenario) Accessing the host Docker daemon via socket mount Using --mount=type=bind in multi-stage Dockerfiles The root cause is that Docker BuildKit creates read-only bind mounts, and rsync with the -a flag (which includes -t for preserving times) attempts to set timestamps on the mounted directory itself, failing on the read-only mount point. This blocks builds in environments using native dockerd for build acceleration. - How I did it Use the defined in dockerfile-macros.j2 on the otel docker - How to verify it Build SONiC using SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y Verify Docker images build successfully Signed-off-by: david.zagury <[email protected]>
…VE_DOCKERD_FOR_BUILD is enabled (sonic-net#24604) [build] Fix rsync failure in Docker builds when SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD is enabled Signed-off-by: Feng Pan <[email protected]>
…_NATIVE_DOCKERD_FOR_BUILD is enabled (sonic-net#25328) This is the same fix as in sonic-net#24604 to the new otel docker - Why I did it When building SONiC with SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y, Docker multi-stage builds fail during rsync operations with the following error: rsync: [generator] failed to set times on "/changes-to-image": Read-only file system (30) rsync error: some files/attrs were not transferred (see previous errors) (code 23) This issue occurs specifically when: Using Docker Engine 20.10.x with BuildKit Running builds inside containers (Docker-in-Docker scenario) Accessing the host Docker daemon via socket mount Using --mount=type=bind in multi-stage Dockerfiles The root cause is that Docker BuildKit creates read-only bind mounts, and rsync with the -a flag (which includes -t for preserving times) attempts to set timestamps on the mounted directory itself, failing on the read-only mount point. This blocks builds in environments using native dockerd for build acceleration. - How I did it Use the defined in dockerfile-macros.j2 on the otel docker - How to verify it Build SONiC using SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y Verify Docker images build successfully Signed-off-by: david.zagury <[email protected]> Signed-off-by: Feng Pan <[email protected]>
…_NATIVE_DOCKERD_FOR_BUILD is enabled This is the same fix as in sonic-net#24604 to the new otel docker <!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md ** Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it When building SONiC with `SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y`, Docker multi-stage builds fail during rsync operations with the following error: ``` rsync: [generator] failed to set times on "/changes-to-image": Read-only file system (30) rsync error: some files/attrs were not transferred (see previous errors) (code 23) ``` This issue occurs specifically when: - Using Docker Engine 20.10.x with BuildKit - Running builds inside containers (Docker-in-Docker scenario) - Accessing the host Docker daemon via socket mount - Using `--mount=type=bind` in multi-stage Dockerfiles The root cause is that Docker BuildKit creates read-only bind mounts, and rsync with the `-a` flag (which includes `-t` for preserving times) attempts to set timestamps on the mounted directory itself, failing on the read-only mount point. This blocks builds in environments using native dockerd for build acceleration. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Use the defined in dockerfile-macros.j2 on the otel docker #### How to verify it Build SONiC using SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y Verify Docker images build successfully <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [ ] 202511 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> Signed-off-by: Sonic Build Admin <[email protected]> #### A picture of a cute animal (not mandatory but encouraged)
…_NATIVE_DOCKERD_FOR_BUILD is enabled (#25982) This is the same fix as in #24604 to the new otel docker <!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it When building SONiC with `SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y`, Docker multi-stage builds fail during rsync operations with the following error: ``` rsync: [generator] failed to set times on "/changes-to-image": Read-only file system (30) rsync error: some files/attrs were not transferred (see previous errors) (code 23) ``` This issue occurs specifically when: - Using Docker Engine 20.10.x with BuildKit - Running builds inside containers (Docker-in-Docker scenario) - Accessing the host Docker daemon via socket mount - Using `--mount=type=bind` in multi-stage Dockerfiles The root cause is that Docker BuildKit creates read-only bind mounts, and rsync with the `-a` flag (which includes `-t` for preserving times) attempts to set timestamps on the mounted directory itself, failing on the read-only mount point. This blocks builds in environments using native dockerd for build acceleration. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Use the defined in dockerfile-macros.j2 on the otel docker #### How to verify it Build SONiC using SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y Verify Docker images build successfully <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [ ] 202511 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> Signed-off-by: Sonic Build Admin <[email protected]> #### A picture of a cute animal (not mandatory but encouraged)
…VE_DOCKERD_FOR_BUILD is enabled (#24604) [build] Fix rsync failure in Docker builds when SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD is enabled Signed-off-by: dprital <[email protected]>
…_NATIVE_DOCKERD_FOR_BUILD is enabled (#25328) This is the same fix as in #24604 to the new otel docker - Why I did it When building SONiC with SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y, Docker multi-stage builds fail during rsync operations with the following error: rsync: [generator] failed to set times on "/changes-to-image": Read-only file system (30) rsync error: some files/attrs were not transferred (see previous errors) (code 23) This issue occurs specifically when: Using Docker Engine 20.10.x with BuildKit Running builds inside containers (Docker-in-Docker scenario) Accessing the host Docker daemon via socket mount Using --mount=type=bind in multi-stage Dockerfiles The root cause is that Docker BuildKit creates read-only bind mounts, and rsync with the -a flag (which includes -t for preserving times) attempts to set timestamps on the mounted directory itself, failing on the read-only mount point. This blocks builds in environments using native dockerd for build acceleration. - How I did it Use the defined in dockerfile-macros.j2 on the otel docker - How to verify it Build SONiC using SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y Verify Docker images build successfully Signed-off-by: david.zagury <[email protected]> Signed-off-by: dprital <[email protected]>
Why I did it
When building SONiC with
SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y, Docker multi-stage builds fail during rsync operations with the following error:This issue occurs specifically when:
--mount=type=bindin multi-stage DockerfilesThe root cause is that Docker BuildKit creates read-only bind mounts, and rsync with the
-aflag (which includes-tfor preserving times) attempts to set timestamps on the mounted directory itself, failing on the read-only mount point.This blocks builds in environments using native dockerd for build acceleration.
Work item tracking
How I did it
Added
--omit-dir-timesflag to all rsync commands in Dockerfile.j2 templates that use bind mounts for multi-stage builds.This flag tells rsync to skip setting directory timestamps (not needed for functionality) while still preserving:
The fix is applied to 37 Dockerfile.j2 files:
dockers/directory (common base Docker images used by all platforms)platform/mellanox/directoryHow to verify it
Build SONiC using SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y
Verify Docker images build successfully
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)