Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(kubernetes): Defer checking valid kinds until after startup (#4005)
* refactor(kubernetes): Rename InvalidKindReason and avoid nulls Instead of having an enum InvalidKindReason, and returning null when a kind is valid, jsut call it KindStatus and use an enum value VALID to represent a valid kind. This avoids the need to use null as a sentinel value. * refactor(kubernetes): Change lists to immutable sets We store a list of kinds and kinds to omit on each account; these lists are never modified after they are created, and we only ever do set-like operations on them (contains, size). In order to make lookups more efficient, and prevent bugs (and make the following refactor easier), change the lists to immutable sets. * perf(kubernetes): Defer checking valid kinds until after startup Instead of blocking the startup of clouddriver while we check whether we can read every kind in every account, defer these checks until first use. Encapsulate this logic in an inner class called KindValidator; this class handles keeping track of what kinds are valid for an account as well as whether metrics are readable for the account. It will only ever attempt to read a kind once (the first time it is asked), and short-circuits just like the earlier logic based on the contents of kinds and omitKinds. * refactor(kubernetes): Rename isMetricsComputed The fact that whether metrics is enabled or not is computed by reading metrics is an implementation details; make it easier for consumers by renaming this function isMetricsEnabled. Also, remove the getter for metrics, which should never be read by consumers of the class, which should always use isMetricsEnabled. * perf(kubernetes): Don't check valid kinds in agent scheduling We currently check whether kinds are valid while scheduling caching agents which blocks agents starting. Caching agents themselves should (and currently do) check whether kinds are valid before actually querying them; remove the check that occurs before scheduling agents. This means that at worst we'll schedule a no-op agent that immediately returns for an invalid kind (though given that kinds are generally grouped in agents that handle many kinds, this likely won't happen much in practice). While the earlier commit in this PR deferred checking readable kinds, the fact that we're checking all readable kinds during agent scheduling means we're still effectively blocking startup on checking readable kinds. Removing this allow startup to proceed before we've checked all readable kinds. * test(kubernetes): Fix function call in tests I had this change locally, but forgot to commit it * style(kubernetes): Address PR review comments * refactor(kubernetes): Move non-permission check logic from inner class Consolidate the inner class PermissionValidator so that it only handles permission checks; pull the logic about handling kinds and omitKinds back up to the outer class.
- Loading branch information
Showing
6 changed files
with
196 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.