Skip to content

fix(host-cleanup, docker): protect "tempID:latest" docker tag from parallel "werf host cleanup" process - #7049

Merged
alexey-igrychev merged 1 commit into
fix/host-cleanup/respect-host-locking-for-dry-runfrom
fix/build/protect-tempid-tag-from-host-cleanup
Sep 2, 2025
Merged

fix(host-cleanup, docker): protect "tempID:latest" docker tag from parallel "werf host cleanup" process#7049
alexey-igrychev merged 1 commit into
fix/host-cleanup/respect-host-locking-for-dry-runfrom
fix/build/protect-tempid-tag-from-host-cleanup

Conversation

@nervgh

@nervgh nervgh commented Aug 22, 2025

Copy link
Copy Markdown
Contributor

No description provided.

…erf host cleanup" process

Signed-off-by: Alexandr Zaytsev <alexandr.zaytsev@flant.com>
@nervgh
nervgh marked this pull request as draft August 22, 2025 13:45
@nervgh
nervgh marked this pull request as ready for review August 22, 2025 15:18
@nervgh
nervgh requested a review from iapershin August 22, 2025 17:46
Comment on lines +28 to +30
type DockerServerBackend struct {
locker lockgate.Locker
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't see any reason why locker is a part of DockerServerBackend. As I see from the code it could be called independently in a single implementation of DockerServerBackend method. You can get host locker from anywhere in the code by werf.HostLocker().Locker(), so I don't think it should be a part of initialization of docker backend.
  2. By the way, lockgate.Locker is a very weak abstraction. Ideally, you should declare locker interface on the consumer's side instead importing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pass the locker as the argument to constructor for these reasons:

  1. Prefer explicit over implicit. If we want to use werf.HostLocker().Locker() we are required to call werf.Init() before. In this case it is implicit dependency.
  2. Simplification of testing. If we have the locker as implicit dependency then assertion of locker.Acquire() is not so easy as mocking using standard approach.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's not about explicit over implicit, but dependency injection.
    Ok, left as is, I don't see better approach for this for now
  2. It's interface segregation principle - "Clients should not be forced to depend on methods they do not use".
    It makes the code more coupled and rigid. I don't understand why it's not easy for mocking?
    Your mock object implements all the methods and your interface requires only one, so it satisfies the interface.
    I'm not blocking the PR but encourage you to review this to make code flexible, easily extensible and minimizing dependencies between modules.

Comment on lines +28 to +30
type DockerServerBackend struct {
locker lockgate.Locker
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's not about explicit over implicit, but dependency injection.
    Ok, left as is, I don't see better approach for this for now
  2. It's interface segregation principle - "Clients should not be forced to depend on methods they do not use".
    It makes the code more coupled and rigid. I don't understand why it's not easy for mocking?
    Your mock object implements all the methods and your interface requires only one, so it satisfies the interface.
    I'm not blocking the PR but encourage you to review this to make code flexible, easily extensible and minimizing dependencies between modules.

@alexey-igrychev alexey-igrychev changed the title fix(docker,build,host-cleanup): protect "tempID:latest" docker tag from parallel "werf host cleanup" process fix(build, host-cleanup, docker): protect "tempID:latest" docker tag from parallel "werf host cleanup" process Sep 2, 2025
@alexey-igrychev alexey-igrychev changed the title fix(build, host-cleanup, docker): protect "tempID:latest" docker tag from parallel "werf host cleanup" process fix(host-cleanup, docker): protect "tempID:latest" docker tag from parallel "werf host cleanup" process Sep 2, 2025
@alexey-igrychev
alexey-igrychev merged commit 6fe15ab into fix/host-cleanup/respect-host-locking-for-dry-run Sep 2, 2025
13 checks passed
@alexey-igrychev
alexey-igrychev deleted the fix/build/protect-tempid-tag-from-host-cleanup branch September 2, 2025 09:27
nervgh added a commit that referenced this pull request Sep 2, 2025
…rallel "werf host cleanup" process (#7049)

Signed-off-by: Alexandr Zaytsev <alexandr.zaytsev@flant.com>
alexey-igrychev pushed a commit that referenced this pull request Sep 2, 2025
…rallel "werf host cleanup" process (#7049)

Signed-off-by: Alexandr Zaytsev <alexandr.zaytsev@flant.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants