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

Revendor godep #994

Merged
merged 6 commits into from
Jul 27, 2017
Merged

Revendor godep #994

merged 6 commits into from
Jul 27, 2017

Conversation

freehan
Copy link
Contributor

@freehan freehan commented Jul 19, 2017

Revendor Godep and fix gce controller

This includes a lot of changes. Need careful review.

@nicksardo @nikhiljindal @bowei @madhusudancs

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 19, 2017
@k8s-reviewable
Copy link

This change is Reviewable

expNodes := sets.NewString(nodeNames...)
//expNodes := sets.NewString()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will clean this up in next push

@freehan
Copy link
Contributor Author

freehan commented Jul 20, 2017

/assign nicksardo

if cm.fakeIGs.Ports[0] != testPort {
t.Errorf("Expected the same node port on all igs, got ports %+v", cm.fakeIGs.Ports)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The original test and this change look funky. We should be testing each instance group for the testPort, but this only checks the first port and happens outside the instance group loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my other comment

namer *utils.Namer
fw map[string]*compute.Firewall
namer *utils.Namer
networkUrl string
Copy link
Contributor

Choose a reason for hiding this comment

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

I think namer has to be removed from the fakeFirewallsProvider. Cloudprovider should no longer be generating the name given a suffix - it should just be given the name.

func (f *fakeFirewallsProvider) GetFirewall(prefixedName string) (*compute.Firewall, error) {
rule, exists := f.fw[prefixedName]
func (ff *fakeFirewallsProvider) GetFirewall(prefixedName string) (*compute.Firewall, error) {
rule, exists := ff.fw[prefixedName]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename to just name

prefixedName := f.namer.FrName(name)
_, exists := f.fw[prefixedName]
prefixedName := ff.namer.FrName(name)
_, exists := ff.fw[prefixedName]
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need namer here, right?

firewall, err := fr.createFirewallObject(suffix, "GCE L7 firewall rule", nodePorts, nodeNames)
if err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just call this createFirewallObject once earlier in the function and re-use it here and below?

url := instanceRefs[ix].Instance
parts := strings.Split(url, "/")
instanceNames[ix] = parts[len(parts)-1]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could instead change to storing URLs instead of names. Up to you.

for _, port := range namedPorts {
f.Ports = append(f.Ports, port.Port)
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Either add it now or add a TODO. We should assert existence of the instance group and return an error if missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -63,13 +63,14 @@ func (i *Instances) Init(zl zoneLister) {
// all of which have the exact same named port.
func (i *Instances) AddInstanceGroup(name string, port int64) ([]*compute.InstanceGroup, *compute.NamedPort, error) {
igs := []*compute.InstanceGroup{}
namedPort := &compute.NamedPort{}
namedPort := &compute.NamedPort{Name: fmt.Sprintf("port%v", port), Port: port}
Copy link
Contributor

Choose a reason for hiding this comment

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

Either now or in a TODO, the port name should be moved to namer.

func (f *FakeLoadBalancers) ReserveGlobalAddress(addr *compute.Address) error {
f.calls = append(f.calls, "ReserveGlobalAddress")
f.IP = append(f.IP, addr)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future, we should just refactor this to use a map. Nothing to do now.

@nicksardo
Copy link
Contributor

I didn't see any show stoppers, but would appreciate some minor changes in areas.

return fmt.Errorf("Failed to find instance group %q in zone %q", igName, zone)
}

f.Ports = f.Ports[:0]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicksardo The interface and fakeInstanceGroup changed. Only store the namedports, not append. So there is only one port.

Choose a reason for hiding this comment

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

This seems odd to me. Can we change the FakeInstanceGroup.Ports []int64 to FakeInstanceGroup.Port int64?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. There can be multiple named port passing in.

Choose a reason for hiding this comment

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

I see. I ignored the code below :)

@freehan freehan force-pushed the revendor-godep branch 3 times, most recently from 7d5605b to 92efa39 Compare July 25, 2017 00:17
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 43.982% when pulling 92efa39 on freehan:revendor-godep into a58b800 on kubernetes:master.

@aledbf
Copy link
Member

aledbf commented Jul 25, 2017

@nicksardo @freehan this is ready to be merged?

@nikhiljindal
Copy link
Contributor

lgtm at a quick glance :)

@bowei
Copy link
Member

bowei commented Jul 25, 2017

I'm kind of confused looking at the commits, why are there commits from someone else in the list?

@aledbf
Copy link
Member

aledbf commented Jul 25, 2017

@bowei I started the update until I found the gce controller require changes because of the firewall api changes.

@@ -60,9 +60,15 @@ func (fr *FirewallRules) Sync(nodePorts []int64, nodeNames []string) error {
// instead of the whole name.
name := fr.namer.FrName(suffix)
rule, _ := fr.cloud.GetFirewall(name)

firewall, err := fr.createFirewallObject(suffix, "GCE L7 firewall rule", nodePorts, nodeNames)
Copy link
Contributor

Choose a reason for hiding this comment

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

We pass in suffix though we just computed the name above. Could we either delete line 61 and change uses to "firewall.Name" or pass in the name?

err := fr.cloud.DeleteFirewall(fr.namer.FrSuffix())
name := fr.namer.FrName(fr.namer.FrSuffix())
glog.Infof("Deleting firewall %v", name)
err := fr.cloud.DeleteFirewall(name)
if err != nil && utils.IsHTTPErrorCode(err, 404) {
glog.Infof("Firewall with suffix %v didn't exist at Shutdown", fr.namer.FrSuffix())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can change this line to print the firewall name computed above.

ports := make([]string, len(nodePorts))
for ix := range nodePorts {
ports[ix] = strconv.Itoa(int(nodePorts[ix]))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we de-duping ports anywhere? Checking

Copy link
Contributor

@nicksardo nicksardo Jul 25, 2017

Choose a reason for hiding this comment

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

func (f *FakeLoadBalancers) DeleteGlobalStaticIP(name string) error {
f.calls = append(f.calls, "DeleteGlobalStaticIP")
// DeleteGlobalAddress fakes out static IP deletion.
func (f *FakeLoadBalancers) DeleteGlobalAddress(name string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for future, we should return fake 404 if address wasn't found.

@nicksardo
Copy link
Contributor

My last two comments can be done in another PR. I think it's good to go, but will ping @bowei for last check.

Copy link

@madhusudancs madhusudancs left a comment

Choose a reason for hiding this comment

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

@freehan I lack the depth that @nicksardo has in this code base. I have left a few minor comments. LGTM otherwise.

@@ -26,10 +26,10 @@ import (
"github.com/golang/glog"

compute "google.golang.org/api/compute/v1"
api_v1 "k8s.io/api/core/v1"

Choose a reason for hiding this comment

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

Is there a reason to merge these two blocks? I really like the separation between the k8s API imports and other imports

return fmt.Errorf("Failed to find instance group %q in zone %q", igName, zone)
}

f.Ports = f.Ports[:0]

Choose a reason for hiding this comment

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

This seems odd to me. Can we change the FakeInstanceGroup.Ports []int64 to FakeInstanceGroup.Port int64?

"sort"
"sync"
"time"

"github.com/golang/glog"

api "k8s.io/api/core/v1"

Choose a reason for hiding this comment

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

call this v1 or corev1. It gets pretty confusing when reading the code in these packages. For example, see https://github.com/kubernetes/ingress/pull/994/files#diff-636822cdb1e125937cd0afa244e18161R33.

@freehan
Copy link
Contributor Author

freehan commented Jul 26, 2017

Addressed the comments.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 43.982% when pulling ee3054d on freehan:revendor-godep into a58b800 on kubernetes:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 43.955% when pulling ee3054d on freehan:revendor-godep into a58b800 on kubernetes:master.

@bowei
Copy link
Member

bowei commented Jul 27, 2017

looks ok to me
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 27, 2017
@nicksardo nicksardo merged commit 16a213c into kubernetes:master Jul 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants