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

upup/pkg/fi/ upup/pkg/kutil : simplify code and remove code #8118

Merged
merged 1 commit into from
Dec 20, 2019
Merged

upup/pkg/fi/ upup/pkg/kutil : simplify code and remove code #8118

merged 1 commit into from
Dec 20, 2019

Conversation

tanjunchen
Copy link
Member

ref:#7800

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 16, 2019

attempt := 0
Copy link
Member Author

Choose a reason for hiding this comment

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

I am confused that this function of for{} ,
this seems run one,so i think it is ok to remove this code .

@@ -147,10 +147,10 @@ func (_ *StorageBucketIam) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Storage
return nil
}

type terraformStorageBucketIam struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

line 158 refers to this struct , but commented. So I comment this struct not remove it.

@tanjunchen
Copy link
Member Author

tanjunchen commented Dec 16, 2019

/cc @justinsb @rifelpet

@tanjunchen tanjunchen changed the title simplify code and remove code upup/pkg/fi/ upup/pkg/kutil : simplify code and remove code Dec 16, 2019
@tanjunchen
Copy link
Member Author

/test pull-kops-e2e-kubernetes-aws

@@ -69,7 +69,6 @@ func NewLBListenerTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle *fi.Li
}
listenerTask.Pool = poolTask
// TODO: Support Multiple?
break
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't removing this change the listenerTask.Pool from being the first item in lb.Pools to the last item?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, forget it.
NewLBListenerTaskFromCloud has not comment , so i has some questions about this function.
This seems that we need not to use for{} . any advice?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hakman any advice?Thanks

Copy link
Member

Choose a reason for hiding this comment

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

I would try this:

--- upup/pkg/fi/cloudup/openstacktasks/lblistener.go.old
+++ upup/pkg/fi/cloudup/openstacktasks/lblistener.go
@@ -66,10 +66,11 @@
 		poolTask, err := NewLBPoolTaskFromCloud(cloud, lifecycle, &pool, find.Pool)
 		if err != nil {
 			return nil, fmt.Errorf("NewLBListenerTaskFromCloud: Failed to create new LBListener task for pool %s: %v", pool.Name, err)
-		}
-		listenerTask.Pool = poolTask
-		// TODO: Support Multiple?
-		break
+		} else {
+			listenerTask.Pool = poolTask
+			// TODO: Support Multiple?
+			break
+		}
 	}
 	if find != nil {
 		// Update all search terms

@@ -49,7 +49,7 @@ func (s *SecurityGroupRule) CompareWithID() *string {
}

func equalsIgnoreCase(a, b string) bool {
if strings.ToLower(a) == strings.ToLower(b) {
if strings.EqualFold(a, b) {
Copy link
Member

@hakman hakman Dec 17, 2019

Choose a reason for hiding this comment

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

Seems to me that equalsIgnoreCase just reimplements strings.EqualFold and is used only once.
Maybe would be best to just remove it and replace where it's used.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I can do it

@tanjunchen
Copy link
Member Author

/cc @hakman @justinsb @rifelpet i have update it . Please let me know if you have any question or good idea. Thanks

@tanjunchen
Copy link
Member Author

/cc @justinsb @rifelpet

@rifelpet
Copy link
Member

This looks great, the for loops that make AWS calls wouldnt have been necessary even if they were retrying properly because the AWS client has its own retry + backoff built in, so this definitely simplifies those functions. Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 20, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rifelpet, tanjunchen

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 20, 2019
@k8s-ci-robot k8s-ci-robot merged commit 6856358 into kubernetes:master Dec 20, 2019
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants