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

engine: make podlogmanager a reconciler #4394

Merged
merged 1 commit into from Apr 5, 2021
Merged

engine: make podlogmanager a reconciler #4394

merged 1 commit into from Apr 5, 2021

Conversation

nicks
Copy link
Member

@nicks nicks commented Mar 31, 2021

Hello @milas,

Please review the following commits I made in branch nicks/ch11687:

ca5eb0f (2021-03-31 19:38:50 -0400)
engine: make podlogmanager a reconciler

Code review reminders, by giving a LGTM you attest that:

  • Commits are adequately tested
  • Code is easy to understand and conforms to style guides
  • Incomplete code is marked with TODOs
  • Code is suitably instrumented with logging and metrics

@nicks nicks requested a review from milas March 31, 2021 23:39
@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #11687: move podlogmanager to be an apiserver reconciler.

"github.com/tilt-dev/tilt/pkg/logger"
)

// Helper struct that captures Pod changes and queues up a Reconcile()
Copy link
Member Author

@nicks nicks Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's definitely some big abstraction here that I'm missing

The controller-runtime has great tools for "if object X creates object Y, then trigger a Reconcile of X every time Y changes".

I feel like we have a common pattern of "object X has a field that references object Y, which means we need a reconcile every time Y changes", and then need lots of custom mapping code to do that efficiently.

not sure what the right answer is yet...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the sense that we might be working against the desired pattern here - since owner references are actually stored on the child, that's how it can map back efficiently on the .Owns() (which is more or less syntactic sugar over .Watches()).

The Kubebuilder book does have an example of adding an index on a field for client lookups, so I guess that could be a possibility - index your pod field and then in the map func when the pod changes, look up the PodLogStreams using the index and emit the requests based off hits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's even more complicated than that, because the Pod comes from a different API server than the PodLogStream

but I think you're right that the long-term goal should be to have something like Owns() that handles all of this generically....there's nothing really Pod-specific here.

@nicks nicks force-pushed the nicks/ch11687 branch 3 times, most recently from 8fef11a to a31e90f Compare April 2, 2021 01:34
@@ -250,7 +258,7 @@ func TestLogReconnection(t *testing.T) {

_, _ = writer.Write([]byte("hello world!"))
f.AssertOutputContains("hello world!")
assert.Equal(t, startTime, f.kClient.LastPodLogStartTime)
assert.Equal(t, startTime.Truncate(time.Second), f.kClient.LastPodLogStartTime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - is this result of (intentionally) reduced precision or something else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, this is not documented super-well, but metav1.Time only provides second-level granularity https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Time.Rfc3339Copy
so all the underlying Log apis truncate this anyway

this test changed because we're serializing the API, which is where the truncation happens

@nicks
Copy link
Member Author

nicks commented Apr 2, 2021

i'm going to wait on tilt-dev/tilt-apiserver#29 before merging (though tbh i don't totally understand why that bug doesn't affect things now)

@nicks nicks merged commit e0eb3bd into master Apr 5, 2021
@nicks nicks deleted the nicks/ch11687 branch April 5, 2021 15:58
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.

None yet

2 participants