refactor: Reduce tight-coupling between sync.go <-> canary.go, bluegreen.go #1461
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please let me start with as small as possible change :)
While I was building a PoC towards #1457, I realized that it was hard to cleanly extract the
Deployer
interface out of rolloutContext due to tight coupling between sync.go and canary.go + bluegreen.go.My theory is the dependency graph should ideally be
sync.go --depends-on--> bluegreen.go/canary.go --depends-on--> replicaset.go
, and the codebase looks "mostly" like that.By moving
scaleReplicaSetAndRecordEvent
from sync.go to replicaset.go, I'm removing the unwated reverse dependency frombluegreen.go/canary.go
tosync.go
, so that the codebase gets closer to the ideal state.These source files should eventually be in dedicated sub-packages (if maintainers agree) so that the Go compiler can detect cyclic dependencies like this. Doing that in a single commit would make reviewing hard, hence I'd like to do it one by one.
If you're curious how this refactoring helps to extract the
Deployer
interface, see subsequent commits in my branch: master...mumoshu:refactor-replicaset-deployerYou'll see this change resulting in reducing the diff in the next commit.
Checklist:
"fix(controller): Updates such and such. Fixes #1234"
.refactor:
prefix according to the conventional commits standard