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

Reduce the number of GET requests #49

Merged
merged 3 commits into from
Jul 8, 2024
Merged

Reduce the number of GET requests #49

merged 3 commits into from
Jul 8, 2024

Conversation

timebertt
Copy link
Owner

This PR refactors the history.History interface and implementations to take a full client.Object instead of a client.ObjectKey.
With this, the ListRevisions function can spare the additional GET request for the object, that is already performed by the kubectl libraries.

Before:

$ k revisions get deploy nginx -v6
I0708 22:15:54.192892   90818 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments/nginx 200 OK in 5 milliseconds
I0708 22:15:54.194036   90818 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments/nginx 200 OK in 0 milliseconds
I0708 22:15:54.195177   90818 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx 200 OK in 1 milliseconds
NAME               REVISION   READY   AGE
nginx-77bdb74675   1          3/3     84m

$ k revisions get deploy -v6
I0708 22:16:02.772346   91043 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments 200 OK in 5 milliseconds
I0708 22:16:02.774134   91043 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments/nginx 200 OK in 1 milliseconds
I0708 22:16:02.775542   91043 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx 200 OK in 1 milliseconds
I0708 22:16:02.776539   91043 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments/nginx2 200 OK in 0 milliseconds
I0708 22:16:02.777557   91043 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx2 200 OK in 0 milliseconds
I0708 22:16:02.778471   91043 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments/nginx3 200 OK in 0 milliseconds
I0708 22:16:02.779407   91043 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx3 200 OK in 0 milliseconds
NAME                REVISION   READY   AGE
nginx-77bdb74675    1          3/3     84m
nginx2-754bbc4897   1          3/3     83m
nginx3-784ddc76db   1          3/3     83m

After:

$ k revisions get deploy nginx -v6
I0708 22:38:01.273952    5075 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments/nginx 200 OK in 5 milliseconds
I0708 22:38:01.276802    5075 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx 200 OK in 1 milliseconds
NAME               REVISION   READY   AGE
nginx-77bdb74675   1          3/3     106m

$ k revisions get deploy -v6
I0708 22:38:04.067928    5144 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/deployments 200 OK in 5 milliseconds
I0708 22:38:04.070295    5144 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx 200 OK in 1 milliseconds
I0708 22:38:04.071345    5144 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx2 200 OK in 0 milliseconds
I0708 22:38:04.072561    5144 round_trippers.go:553] GET https://127.0.0.1:50594/apis/apps/v1/namespaces/default/replicasets?labelSelector=deployment%3Dnginx3 200 OK in 1 milliseconds
NAME                REVISION   READY   AGE
nginx-77bdb74675    1          3/3     106m
nginx2-754bbc4897   1          3/3     105m
nginx3-784ddc76db   1          3/3     105m

@timebertt timebertt added the enhancement New feature or request label Jul 8, 2024
@timebertt timebertt enabled auto-merge (squash) July 8, 2024 20:38
@timebertt timebertt merged commit 513406d into main Jul 8, 2024
3 checks passed
@timebertt timebertt deleted the optimize branch July 8, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant