-
Notifications
You must be signed in to change notification settings - Fork 106
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
modified resource sync to use an informer #137
modified resource sync to use an informer #137
Conversation
6a905ca
to
6d67b02
Compare
I have updated the PR to filter out updates in the I'm removing |
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'm no expert with the innards of kube-mgmt
so please bear with me on the questions and comments here 🙃
@@ -474,9 +473,9 @@ func TestGenericSync(t *testing.T) { | |||
|
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.
❓ How do you judge our test coverage here, does it inspire confidence? (I really don't know, it's a genuine question since you're working on 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.
After #135 we have the initial load covered, and I'm confident on that part. But I have failed to add tests for addition / update / removal of resources after the initial load, and that's a problem.
I have tried both FakeDynamicClient.Tracker and FakeDynamicClient.Resource(){.Create, .Update, .Delete}, but I couldn't make them work. The tests didn't work even with the previous version.
So I'm currently testing this "on the field", in my company's dev environment, before we deploy the service to our production. In parallel, I'm checking out the FakeDynamicClient
code to try and find out why the tests don't work.
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 could make the tests work in 602be1f and now the coverage is around 78%. I think it's safe to remove the draft label now.
6d67b02
to
c421f3b
Compare
Hey @rg2011 , are you on the OPA Slack by any chance? |
a773b8f
to
911a83a
Compare
Signed-off-by: rg2011 <[email protected]>
8f5864c
to
b7adb52
Compare
Signed-off-by: rg2011 <[email protected]>
b7adb52
to
602be1f
Compare
Signed-off-by: rg2011 <[email protected]>
7e180bb
to
10f90c4
Compare
@rg2011 didn't get to this today. I'll re-review later this week 🤞 Thanks for pushing this forward. |
Signed-off-by: rg2011 <[email protected]>
d49ee72
to
9a98fac
Compare
Signed-off-by: rg2011 <[email protected]>
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.
Sorry for the radio silence. I've gotten around to skimming the change, it looks good, but I'll need to have another closer look to approve.
Added a comment on what stood out to me when reading this.
return f.actor(req, value) | ||
} | ||
|
||
var errNotSupported = errors.New("PostData not supported") |
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 We could inline this, it's only used once (unless I'm missing something).
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.
No real reason to create a variable, other than I'm used to it because it makes it easier to check this kind of errors with errors.Is
later. But this particular error will never be checked, so we could remove it.
return fmt.Sprintf("{req: %q, path: %q, op: %q}", r.req, r.path, r.op) | ||
} | ||
|
||
func optional(expected ...[]byte) []byte { |
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.
nicely done
@rg2011 @anderseknert @srenatus should I merge this ? |
Rewrite of data.GenericSync that uses an informer to manage the connection to the Kubernetes API. Fixes issue #134
The informer uses a
workqueue
to schedule updates to OPA. To avoid an initial flood of individual resource updates, the controller keeps dropping items from the queue until it has completed the first bulk update to OPA.A major drawback of this PR is that the flood might occur later on, if the informer restarts the watch and flushes all resources to the queue again. The controller will then update OPA item by item.I'm publishing this PR as a draft, in case someone is interested and wants to give it a thought. Any suggestion on how to avoid an update flood when the informer reconnects would be appreciated.