Skip to content

Maintain deterministic order in withCopyFileToContainer and allow file reuse #2861

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

Conversation

findepi
Copy link
Contributor

@findepi findepi commented Jun 12, 2020

withCopyFileToContainer can be invoked multiple times, including with
one containerPath being prefix of another containerPath.

This change makes the end result deterministic.

This also allows copying a single source file (e.g. /dev/null) to
multiple destinations.

Fixes #2956

@findepi findepi force-pushed the findepi/master/maintain-deterministic-order-in-withcopyfiletocontainer-d2fb92 branch from 23dbdcb to 7a17b72 Compare June 13, 2020 20:42
@rnorth
Copy link
Member

rnorth commented Jun 19, 2020

We're seeing a failure in the API-backwards compatibility tests: unfortunately this PR creates a breaking change in the API (removal of the Lombok-generated accessors for copyToFileContainerPathMap).

Would it be possible to reinstate these accessors, marked @Deprecated and delegating to the replacement code? Sorry that this is likely to be a bit of a faff 😬

Once deprecated, we should remove after people have had a chance to migrate. @bsideup, @kiview please shout if you have any other ideas about how to approach this.

@findepi
Copy link
Contributor Author

findepi commented Jun 20, 2020

Would it be possible to reinstate these accessors, marked @Deprecated and delegating to the replacement code?

@rnorth sure but let's be specific what exactly do you want them to do.

@findepi findepi changed the title Maintain deterministic order in withCopyFileToContainer Maintain deterministic order in withCopyFileToContainer and allow file reuse Jun 20, 2020
@rnorth
Copy link
Member

rnorth commented Jun 30, 2020

Sorry for the delay in getting back to this. I'd assume that we'd be fine to have the ArrayList copyToFileContainerPathList as the only internal representation, with two new accessor methods to replace the generated accessors that have gone away:

getCopyToFileContainerPathMap() - should return a map representation of copyToFileContainerPathList, where last-entry-wins if there are any key collisions.

setCopyToFileContainerPathMap(...) - should accept a map, and overwrite the content of copyToFileContainerPathList with each of the elements in the map. If an ordered map happens to be provided, we should respect the ordering.

Both accessors would be marked @deprecated.

Does this make sense?

@findepi
Copy link
Contributor Author

findepi commented Jun 30, 2020

@rnorth thanks for looking into this!

setCopyToFileContainerPathMap(...) - should accept a map, and overwrite the content of copyToFileContainerPathList with each of the elements in the map. If an ordered map happens to be provided, we should respect the ordering.

I can implement that

However, calling code may rely on the fact that the map provided setCopyToFileContainerPathMap is the one being used.

For example, today one can write:

Map x = ....
container.setCopyToFileContainerPathMap(x);
x.put(.....)

-- and have effects of put visible.

If we change setCopyToFileContainerPathMap to accept a map and copy values into a list,
we still do not provide backwards compatibility, in a subtle way.

I leave it up to you to decide whether breaking the API in a compile-error manner
would be actually more user friendly.

getCopyToFileContainerPathMap() - should return a map representation of copyToFileContainerPathList, where last-entry-wins if there are any key collisions.

You mean a copy (like Maps.uniqueIndex) or a live view of a list implementing the Map interface?
read-only, or read-write?

@rnorth
Copy link
Member

rnorth commented Jul 5, 2020

However, calling code may rely on the fact that the map provided setCopyToFileContainerPathMap is the one being used.

Ah yes, you're quite right. In that case, we're running out of options that are not (really) excessive overkill.

The next release (1.15.0) is going to include a swathe of deprecations, and we're allowing some small breaking changes into the API. I think we should go ahead and add this to the list.

@rnorth rnorth added the type/breaking-api-change Public APIs are being changed label Jul 5, 2020
`withCopyFileToContainer` can be invoked multiple times, including with
one `containerPath` being prefix of another `containerPath`.

This change makes the end result deterministic.

This also allows copying a single source file (e.g. `/dev/null`) to
multiple destinations.
@findepi findepi force-pushed the findepi/master/maintain-deterministic-order-in-withcopyfiletocontainer-d2fb92 branch from 7a17b72 to 014dc96 Compare July 19, 2020 14:01
@stale
Copy link

stale bot commented Jan 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Jan 24, 2021
@findepi
Copy link
Contributor Author

findepi commented Jan 24, 2021

stale, getting this in would fix #2956 and allow me to reduce amount of hack-arounds i maintain.

@stale stale bot removed the stale label Jan 24, 2021
@findepi findepi closed this Mar 19, 2021
@findepi findepi deleted the findepi/master/maintain-deterministic-order-in-withcopyfiletocontainer-d2fb92 branch March 19, 2021 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/breaking-api-change Public APIs are being changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected result when withCopyFileToContainer invoked multiple times for the same path
2 participants