Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sharnoff
Copy link
Member

@sharnoff sharnoff commented Nov 4, 2024

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'.

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'.
Copy link

github-actions bot commented Nov 4, 2024

No changes to the coverage.

HTML Report

Click to open

}

// one level of indirection below State so that the fields can be public, and JSON-serializable
type state struct {
type state[A AlgorithmState] struct {
Copy link
Contributor

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?

Copy link
Member Author

@sharnoff sharnoff Nov 13, 2024

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

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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 😅

pkg/agent/core/state.go Outdated Show resolved Hide resolved
@sharnoff sharnoff self-assigned this Nov 13, 2024
rename:
* core.state.{Metrics => Algorithm}
* (*core.State).{UpdateMetrics => UpdateAlgorithmState}
* core.StdAlgorithm.{System => SystemMetrics}
* core.StdAlgorithm.{LFC => LFCMetrics}
@sharnoff sharnoff assigned Omrigan and unassigned sharnoff Nov 13, 2024
@Omrigan Omrigan mentioned this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants