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

(cleanup) Make the netpol/ model.go model stateful #102919

Open
jayunit100 opened this issue Jun 16, 2021 · 11 comments
Open

(cleanup) Make the netpol/ model.go model stateful #102919

jayunit100 opened this issue Jun 16, 2021 · 11 comments

Comments

@jayunit100
Copy link
Member

@jayunit100 jayunit100 commented Jun 16, 2021

What happened

In #102354 (comment) @aojea brought up the fact that to get Service IPs we currently need to make an API call, i suppose that is suboptimal .

in a nutshell...

  • We CREATE services in one place, and this returns the Service IP that we dont use at that time.
                          // kubemanager.go initializeCluster()
			createdPods = append(createdPods, kubePod)
			svc, err := k.createService(pod.Service())
			if err != nil {
				return err
			}

(model.go)

  • We READ service IPs in another place, and we waste a query to apiserver for the data we just got above, and threw away.
                         // network_policy.go getK8sModelWithServiceIPs()
			service := pod.Service()
			kubeService, err := f.ClientSet.CoreV1().Services(pod.Namespace).Get(context.TODO(), service.Name, metav1.GetOptions{})
			if err != nil {

So we should in an ideal way, find a way to cache the data we get for free in the first bullet, with the function that reads the service data, in the second bullet.

basically any solution that makes this easier to deal with is probably a small win for us, so , good first issue to hack on :)

details

This is because we create the model using a function (rather then caching it somehow).

The functional approach imo is nice bc the model offers no gaurantees, so, we can call it as much as we want and have less state to carry over.

However, i think maybe at some point it would be faster to cache this data, and not call Spec.ClusterIP for ever pod on every test.

Fix

This is a good first issue i think: Take a look at the code path in the netpol suite, and see if you can get it to pass by extending the model class somehow, so that when we converge getK8SModel() and getK8sModelWithServiceIPs(), into a single call to getting the Model, which uses a cached model, that is capable of creating itself somehow, that way, once the model exists, it can be reused.

I think to merge this since we're adding state carry over,it would be interesting to measure wether the tests run any faster afterwards.

I dont have any strong opinions here, but thought i'd follow this as a follow on to #102354

@k8s-ci-robot
Copy link
Contributor

@k8s-ci-robot k8s-ci-robot commented Jun 16, 2021

@jayunit100: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jayunit100
Copy link
Member Author

@jayunit100 jayunit100 commented Jun 16, 2021

/good-first-issue

@k8s-ci-robot
Copy link
Contributor

@k8s-ci-robot k8s-ci-robot commented Jun 16, 2021

@jayunit100:
This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.

In response to this:

/good-first-issue

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jayunit100
Copy link
Member Author

@jayunit100 jayunit100 commented Jun 16, 2021

/sig network

@jayunit100 jayunit100 changed the title Make the netpol/ model.go model stateful (cleanup) Make the netpol/ model.go model stateful Jun 16, 2021
@yangjunmyfm192085
Copy link
Contributor

@yangjunmyfm192085 yangjunmyfm192085 commented Jun 16, 2021

/assign @SANDWISH

@k8s-ci-robot
Copy link
Contributor

@k8s-ci-robot k8s-ci-robot commented Jun 16, 2021

@yangjunmyfm192085: GitHub didn't allow me to assign the following users: sandwish.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @SANDWISH

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@yangjunmyfm192085
Copy link
Contributor

@yangjunmyfm192085 yangjunmyfm192085 commented Jun 16, 2021

/assign sanwishe

@k8s-ci-robot
Copy link
Contributor

@k8s-ci-robot k8s-ci-robot commented Jun 16, 2021

@yangjunmyfm192085: GitHub didn't allow me to assign the following users: sanwishe.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign sanwishe

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sanwishe
Copy link
Contributor

@sanwishe sanwishe commented Jun 16, 2021

/assign

@yangjunmyfm192085
Copy link
Contributor

@yangjunmyfm192085 yangjunmyfm192085 commented Jun 16, 2021

take a look @sanwishe

@jayunit100
Copy link
Member Author

@jayunit100 jayunit100 commented Jun 16, 2021

@sanwishe to understand this, you may need to read and base your work on my branch in the PR #102354 , that should merge in the next few days .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants