Skip to content

refactor: encapsulate ImageIDs to WLIDs map - #93

Merged
dwertent merged 8 commits into
relevancyfrom
refactor-iwmap
Mar 26, 2023
Merged

refactor: encapsulate ImageIDs to WLIDs map #93
dwertent merged 8 commits into
relevancyfrom
refactor-iwmap

Conversation

@vladklokun

Copy link
Copy Markdown
Collaborator

Overview

This PR encapsulates a map-and-mutex map of Image hashes to WLIDs in a thread-safe map-like type, so that they can be accessed more conveniently, with less leeway to break synchronization.

How to Test

To check unit tests, run:

go test -v ./watcher -race -failfast -count=1000

Other than that, run whatever Operator flows you deem necessary.

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have commented on my code, particularly in hard-to-understand areas
  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • New and existing unit tests pass locally with my changes

This data structure is designed to replace the map-and-mutex that are
side-by-side in the WatchHandler so clients can perform thread-safe
operations on it with more confidence and ease.

Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
As the first step in wiring the refactoring, use the IWMap in
WatchHandler’s private functions that previously handled thread-safe
operations on the raw ImageIDs to WLIDs map

Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
@vladklokun vladklokun self-assigned this Mar 24, 2023
The data structure maps image hashes to WLIDs. Image hashes are not the
same as image IDs. Image hashes are plain hash digest values. Rename
mentions to avoid confusion.

Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
@vladklokun
vladklokun marked this pull request as ready for review March 24, 2023 18:52
Signed-off-by: Vlad Klokun <vklokun@protonmail.ch>
@vladklokun vladklokun mentioned this pull request Mar 24, 2023
5 tasks

@dwertent dwertent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done. I liked the refactoring you did with the lock and unlock :)

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.

2 participants