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

Remove pkg/context dependency from NEG controller #1331

Merged
merged 1 commit into from
Dec 7, 2020

Conversation

freehan
Copy link
Contributor

@freehan freehan commented Nov 23, 2020

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 23, 2020
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 23, 2020
Copy link
Member

@swetharepakula swetharepakula left a comment

Choose a reason for hiding this comment

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

Overall looks good.
A couple areas where commented code can be deleted.
A couple small suggestions to clean up code and to stop importing the built in context package as context2. But these can be ignored and addressed later.

dynamicClient := dynamicfake.NewSimpleDynamicClient(dynamicSchema)

destrinationGVR := schema.GroupVersionResource{Group: "networking.istio.io", Version: "v1alpha3", Resource: "destinationrules"}
Copy link
Member

Choose a reason for hiding this comment

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

nit: destination

negtypes.MockNetworkEndpointAPIs(fakeGCE)
fakeCloud := negtypes.NewAdapter(fakeGCE)

//backendConfigClient := backendconfigclient.NewSimpleClientset()
Copy link
Member

Choose a reason for hiding this comment

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

commented lines can be deleted.

@@ -723,9 +745,10 @@ func TestFilterCommonPorts(t *testing.T) {
func TestNegCRCreations(t *testing.T) {
t.Parallel()

svcNegClient := negfake.NewSimpleClientset()
//svcNegClient := negfake.NewSimpleClientset()
Copy link
Member

Choose a reason for hiding this comment

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

remove commented line

@@ -919,9 +942,12 @@ func TestNegCRDuplicateCreations(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {

svcNegClient := negfake.NewSimpleClientset()
//svcNegClient := negfake.NewSimpleClientset()
Copy link
Member

Choose a reason for hiding this comment

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

remove commented lines.

@@ -83,39 +76,56 @@ func NewTestSyncerManager(kubeClient kubernetes.Interface) *syncerManager {
}

func NewTestSyncerManagerWithNegClient(kubeClient kubernetes.Interface, svcNegClient svcnegclient.Interface) *syncerManager {
Copy link
Member

Choose a reason for hiding this comment

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

this function can be merged with the above since we always create the svcNegClient.

namer := namer_util.NewNamer(ClusterID, "")
dynamicSchema := runtime.NewScheme()
//dynamicSchema.AddKnownTypeWithName(schema.GroupVersionKind{Group: "networking.istio.io", Version: "v1alpha3", Kind: "List"}, &unstructured.UnstructuredList{})
//backendConfigClient := backendconfigclient.NewSimpleClientset()
Copy link
Member

Choose a reason for hiding this comment

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

commented code can be deleted.

@@ -19,6 +19,7 @@ package neg
import (
context2 "context"
Copy link
Member

Choose a reason for hiding this comment

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

This no longer needs to be imported as context2

@@ -20,6 +20,7 @@ import (
context2 "context"
Copy link
Member

Choose a reason for hiding this comment

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

this no longer needs to be imported as context2

@@ -19,6 +19,7 @@ package neg
import (
context2 "context"
"fmt"
svcnegclient "k8s.io/ingress-gce/pkg/svcneg/client/clientset/versioned"
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to the second import block

svcNegClient svcnegclient.Interface,
destinationRuleClient dynamic.NamespaceableResourceInterface,
kubeSystemUID types.UID,
ingressInformer cache.SharedIndexInformer,
Copy link
Contributor

Choose a reason for hiding this comment

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

why not encapsulate informers and clients into separate structs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can follow up with a PR to refactor this into a separate NegControllerContext.

@freehan
Copy link
Contributor Author

freehan commented Dec 3, 2020

Done. Ready for another round.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: freehan, swetharepakula

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rramkumar1 rramkumar1 merged commit 0c6500d into kubernetes:master Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants