-
Notifications
You must be signed in to change notification settings - Fork 21
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
agent/core: Allow setting goal CU in tests #1129
base: main
Are you sure you want to change the base?
Conversation
No changes to the coverage.
HTML Report |
} | ||
|
||
// one level of indirection below State so that the fields can be public, and JSON-serializable | ||
type state struct { | ||
type state[A AlgorithmState] struct { |
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.
Is there a reason why this has to be a type parameter, compared with just having an interface-typed field?
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.
Yeah, otherwise callers of (*core.State).UpdateAlgorithmState()
would have to downcast to the specific type in order to do the updates — possible, but I figured why bother downcasting when we can just use the exact type
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 you take a quick look at #1140? I wanted to try to implement the same change, but without introducing generics, so that the impact is minimal.
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.
Ah, I see, the idea there is that the algorithm doesn't store the metrics? So, the "manual CU" algorithm would have shared state that's updated externally?
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.
Ah, I see, the idea there is that the algorithm doesn't store the metrics? So, the "manual CU" algorithm would have shared state that's updated externally?
Yes and yes. These are the consequences of doing the minimal possible changes.
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, I see. My two cents: I think the changes here aren't too bad (it's mostly in tests), and having shared mutable state makes me nervous (specifically: changing things out from underneath another object) — but maybe that's just a holdover from my Rust programming 😅
rename: * core.state.{Metrics => Algorithm} * (*core.State).{UpdateMetrics => UpdateAlgorithmState} * core.StdAlgorithm.{System => SystemMetrics} * core.StdAlgorithm.{LFC => LFCMetrics}
This is kind of a second take on #737, and a pre-req to #729 so that we can freely change how metrics are interpreted without needing to rewrite our unit tests in 'pkg/agent/core/state_test.go'.