Refactor database DiscoveryResourceChecker#29864
Conversation
| // | ||
| // Note that this checker warns the user with suggestions on how to configure | ||
| // the credentials correctly instead of returning errors. | ||
| type credentialsChecker struct { |
There was a problem hiding this comment.
moved from watcher.go without logic change
| type DiscoveryResourceChecker interface { | ||
| // Check performs required checks on provided database resource before it | ||
| // gets registered. | ||
| Check(ctx context.Context, database types.Database) error |
There was a problem hiding this comment.
moved from watcher.go but now returns error
There was a problem hiding this comment.
LGTM
as for the data race detected during the test, I believe this is caused by the resource watcher's collector returning all of its collected resources every time a database is created:
teleport/lib/services/watcher.go
Lines 864 to 873 in 3ecc0f0
Not sure why the extra test case you added caused the race detector to trip now - I can't reproduce a data race failure if I remove the extra test case. I don't think it's caused by these changes though
I believe the race happens because the last test case (launching heartbeat/iam service etc.) and the new test case (applyResourceMatchersToDatabases) race on |
|
I've added a fix for the race d77047f. The idea is to ensure that we don't change the attributes of databases in Let me know what you think. Thanks! |
|
we should backport the race fix to v13 as well |
Moving
discoveryResourceCheckerfromlib/srv/db/watcher.gotolib/srv/db/cloud/resource_checker.goThis changes prepares for adding database URL validation as more checkers will be implemented