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

k8s: Convert from Resource[Pod] to Table[LocalPod] #36101

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Nov 21, 2024

This kicks off the transition away from Resource[T] to Table[T] by switching Resource[*Pod] into Table[LocalPod]. I've talked about the benefits in #34060. The daemon/k8s/testdata/pod.txtar somewhat show-cases the benefits to inspection, testing and indexing. By storing the K8s objects in StateDB tables we get all the machinery for querying, watching for changes, testing (with 'db' script commands) and inspecting with cilium-dbg.

I'm starting with pods as that's needed for #35652.

I'm not making Table[LocalPod] a OnDemand[Table[LocalPod]], e.g. we'll start reflecting pods regardless of whether there's users for it or not, since it's one of the fundamental core k8s objects that we always pull regardless of configuration.

For other conversions we'll need to consider carefully whether or not to start the reflection, or whether to expose the table as the reference counted OnDemand resource.

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Nov 21, 2024
@joamaki joamaki added the release-note/misc This PR makes changes that have no direct user impact. label Nov 21, 2024
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Nov 21, 2024
@joamaki joamaki force-pushed the pr/joamaki/pod-table branch 2 times, most recently from fed2d41 to cd15e5f Compare November 25, 2024 14:38
@joamaki joamaki marked this pull request as ready for review December 3, 2024 09:45
@joamaki joamaki requested review from a team as code owners December 3, 2024 09:45
@joamaki
Copy link
Contributor Author

joamaki commented Dec 3, 2024

/test

@joamaki joamaki force-pushed the pr/joamaki/pod-table branch from cd15e5f to 99557d3 Compare December 3, 2024 15:33
@joamaki
Copy link
Contributor Author

joamaki commented Dec 3, 2024

/test

@joamaki joamaki force-pushed the pr/joamaki/pod-table branch from 99557d3 to 10ec1bd Compare December 3, 2024 16:27
daemon/k8s/testdata/pod.txtar Outdated Show resolved Hide resolved
@joamaki joamaki force-pushed the pr/joamaki/pod-table branch from 10ec1bd to d5531f5 Compare December 4, 2024 13:01
@joamaki joamaki marked this pull request as draft December 5, 2024 10:41
@joamaki

This comment was marked as outdated.

Copy link

github-actions bot commented Jan 5, 2025

This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jan 5, 2025
@joamaki joamaki removed the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jan 13, 2025
@joamaki joamaki force-pushed the pr/joamaki/pod-table branch from d5531f5 to c1616fb Compare January 23, 2025 09:01
@joamaki
Copy link
Contributor Author

joamaki commented Jan 23, 2025

/test

@joamaki joamaki requested review from brb and removed request for aspsk January 23, 2025 09:10
@joamaki joamaki marked this pull request as ready for review January 23, 2025 09:34
@joamaki joamaki requested review from a team as code owners January 23, 2025 09:34
@joamaki joamaki requested a review from sayboras January 23, 2025 09:34
@joamaki joamaki force-pushed the pr/joamaki/pod-table branch 3 times, most recently from 2b1ff8a to 2cc303d Compare January 23, 2025 11:51
@joamaki
Copy link
Contributor Author

joamaki commented Jan 23, 2025

/test

Copy link
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

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

Seems like a good substitution as far as I can see

Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

Did a quick first pass, just a couple of nits, will do another pass soon.

daemon/k8s/pods.go Outdated Show resolved Hide resolved
daemon/k8s/pods.go Outdated Show resolved Hide resolved
@joamaki joamaki force-pushed the pr/joamaki/pod-table branch from 2cc303d to f5407d8 Compare January 24, 2025 09:20
Copy link
Member

@brb brb left a comment

Choose a reason for hiding this comment

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

🍕

daemon/k8s/pods.go Show resolved Hide resolved
Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

✔️

@joamaki
Copy link
Contributor Author

joamaki commented Jan 27, 2025

/test

@joamaki
Copy link
Contributor Author

joamaki commented Jan 27, 2025

ping @youngnick @sayboras

Signed-off-by: Jussi Maki <jussi@isovalent.com>
As the first conversion of Resource[T] to Table[T],
refactor Resource[Pod] into Table[LocalPod].

Signed-off-by: Jussi Maki <jussi@isovalent.com>
@joamaki joamaki force-pushed the pr/joamaki/pod-table branch from f5407d8 to 9d55fe7 Compare January 27, 2025 09:22
@joamaki
Copy link
Contributor Author

joamaki commented Jan 27, 2025

/test

@joamaki joamaki enabled auto-merge January 27, 2025 10:04
@joamaki joamaki added this pull request to the merge queue Jan 28, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jan 28, 2025
Merged via the queue into cilium:main with commit 6a4fe9c Jan 28, 2025
64 checks passed
@joamaki joamaki deleted the pr/joamaki/pod-table branch January 28, 2025 03:29
Comment on lines +30 to +33
time.Now = func() time.Time {
return time.Date(2000, 1, 1, 10, 30, 0, 0, time.UTC)
}
os.Setenv("TZ", "")
Copy link
Member

@tklauser tklauser Jan 28, 2025

Choose a reason for hiding this comment

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

These should probably be restored after the test finishes, so they don't influence any successive tests:

now := time.Now
time.Now = func() time.Time {
	return time.Date(2000, 1, 1, 10, 30, 0, 0, time.UTC)
}
t.Cleanup(func() { time.Now = now })
t.Setenv("TZ", "")

Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants