Refactor ChiStatus internals to make concurrent access safe#1119
Refactor ChiStatus internals to make concurrent access safe#1119sunsingerus merged 1 commit intoAltinity:0.21.0from zcross:zcross/concurrency/status
Conversation
|
FYI @sunsingerus – apologies for closing the first attempt at this |
|
Hmm, I just began a branch to refactor Seem like a correct assessment? If so, there won't really be an "announcer PR" – I'll be turning to a final (third) PR to actually update reconciliation logic (well, returning to my original draft, basing it off of this and the registry branches, and then cleaning it up for PR-readiness) |
|
|
||
| // FillStatus fills .Status | ||
| func (chi *ClickHouseInstallation) FillStatus(endpoint string, pods, fqdns []string, ip string) { | ||
| chi.EnsureStatus().CHOpVersion = version.Version |
There was a problem hiding this comment.
version is always statically available so these 3 field setter calls were pushed within the new Fill function (and therefore absent from the passed params)
|
Code-generator produces errors on generics introduced in this PR. This issue blocks merge atm and needed to be looked into. |
|
@zcross merge is blocked atm until further understanding on code-generator + generics situation. |
|
Ok, ACK that I saw this and will take a shot at cleaning it up next week. Re: generics, I'll just replace them with a few type specific functions as needed for simplicity. BTW: how can I reproduce the problem you're seeing for my own iteration? (E.g., what make/build command are you running) Thanks! |
|
|
|
Sorry for not getting to this until today, but I just:
|
Signed-off-by: Zach Cross <[email protected]>
Background: #1109
Related PR(s):
This PR adds
sync.RWMutexbased synchronization over the mutable state ofChiStatus. It should be relatively straightforward. (Also, around the initialization ofClickHouseInstallation's own status field viaEnsureStatus).The most eyebrow raising bits are probably in the sequenced lock acquisition in
MergeActionsandCopyFromcreating some risk of deadlocking (to be discussed, I'm sure). The only other potentially "hairy" concern is some of the generated code I've found forDeepCopyhelpers on all types.Meta: I began this by trying to define a mediator through which all updates would be made. However, the presence of logic inside some of the other raw types inside of the
v1package (such as theClickHouseInstallationAKA chi) made it apparent to me that it's not that much cleaner to separate the two. My workaround to this was to at least make sure that all field level read and write accesses to theChiStatusstruct were strictly within its single source file (type_status) – with the exception of the deepcopy generated files (which don't seem to be used directly AFAIK, and hopefully aren't used at runtime from potentially competing goroutines).Note: I'll squash all commits from feedback pre-merge.
Important items to consider before making a Pull Request
Please check items PR complies to:
next-releasebranch, not intomasterbranch1. More info