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.
feat: implement reconciliation loop #17261
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
feat: implement reconciliation loop #17261
Changes from 129 commits
300e80f
b788237
8122595
bfb7c28
6639167
769ae1d
e7e9c27
3936047
8bdcafb
412d198
51773ec
23773c2
bc3ff44
7ff747e
baa3076
ed14fb3
3cc74fb
fc32154
d7b4ec4
e8b53f7
9df6554
ccc309e
ee1f16a
d040ddd
83a6722
cd70710
97cc4ff
4d59039
205d6af
e489e1b
1b29686
20470e4
7b9c8ce
e189a0b
692c0e5
f747db0
3166a42
aa6b490
bc4e7d2
f167b92
8fd34ab
7a8ec49
a64d661
c787cd2
bd38603
097f9c3
4cfdd6f
4a34d52
8d9cd45
f870d7e
18ad931
4667171
a26c094
6ed4121
2312f41
8da7f47
5150a5c
bff34ea
ef462b6
dc45165
9c8a352
eb80919
0b2bbee
3a97bf6
2eeb884
73f99e8
c942753
9badf7c
6763ba2
e5117d7
dfec884
5065ad6
e354956
4d3aab6
97b3886
fe60b56
eeb0407
e807d02
d78675e
7f60a5d
8f5c9f9
42582e1
14d924c
82e016c
c03ea52
3693d45
beb814f
a5418ac
f4f9b17
d11fd58
31d3bf6
5007a83
a79fe4c
c0246f4
ed608cb
70223e4
07808c2
a2ceeb6
73fb414
7e9c65f
2ca8030
ce83f92
3bc4d8a
2986574
aa22a8a
f41b19e
61a88e4
9ac7a2c
d0c2094
474fc06
9fac5d7
868d0b6
5f204f2
40b3e5f
5e3adbc
108720f
9d8f6b1
b994eec
eff754e
4b052be
bc5297c
0989636
2b57ac4
41d7e07
ab5fa8f
f485bc0
074f768
a47627a
eebb298
9a672dd
c2f4561
62fb3f4
742d0d3
f3e24b1
08aed24
951c8b5
9c1e82f
46e240c
6dc1f68
23964aa
0a4d053
98d203d
145b9ff
8b91668
cccdab2
a2e5643
1771c84
1fc551d
d99c5cb
b98ccd4
936cc38
32da1ab
5a403c0
908e6eb
77e4472
853af80
172177f
a825bf0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't catch it, but why is
prebuilds
located incoderd
? Are there any components or interfaces used in non-commercial license mode? What I can see here are mainly interfaces and snapshots.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the idea is we have all interfaces and related types defined in
coderd
. Consequently we have to define methods in the same package. IIRC in goalng you can't define methods outside the package.@dannykopping should know more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but since
prebuilds
will be enterprise only, could we just park the entire implementation there?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need at least some of the API in the AGPL code because we need the noop implementation "running" until a premium license is used. Other than that, I think most of this can shift to enterprise.
I believe I had it this way because AGPL cannot import enterprise but the reverse is allowed. The interfaces reference the types which are in this package, and if we moved those to enterprise then it would violate the license.
This is how the implementation will be swapped out at runtime based on the license:
https://github.com/coder/coder/blob/dk/prebuilds/enterprise/coderd/coderd.go#L1165-L1188
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current API feels too low-level. Ideally, we should expose higher-level methods such as:
ReconcileAll()
ReconcilePreset(preset)
Note:
SnapshotState
is currently used only byMetricsCollector
.CalculateActions
is currently unused.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a couple weeks but I believe we only expose these for tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make it an internal interface and internal test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a detailed comments, explaining how this API can be used, and why it may sense to expose all these API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnstcn I also wanted to do it, but:
MetricsCollector
: DO NOT REVIEW/MERGE #16523So removing them means:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for this interface to be exported for the metrics collector to work correctly, since it lives in the same package as the
StoreReconciler
.Tests can be inside the same package if they need to access unexported functions. Also, you don't need to export an interface to call exported functions on, say, the
StoreReconciler
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this refactor in a follow-up? Let's try keep the momentum on this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree that "momentum" should be a reason to check in code that doesn't meet our standards. What is to be gained by fixing it later rather than now? IMO it just makes it more likely that we don't fix the issue at all.
Also, this interface isn't actually used anywhere within this PR, so fixing it within the scope of this PR should be trivial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spikecurtis I reduce number of methods in
Reconciler
interface.Now it looks like this:
In future PRs maybe we'll need additional methods, but we can deal with it when we'll be working on those PRs.
Also we'll have more information at that point.
cc @dannykopping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could probably be removed; I only see it used in one other place and it doesn't seem to provide any ergonomic benefits over
snap := GlobalSnapshot{...}
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I like constructors in Go, because if later we'll add new field to
GlobalSnapshot
, we can update constructor and easily track and update all object creations.We can add validation inside constructor, etc...