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

[Digital Ocean] Code cleanup with no functional modifications #11592

Merged
merged 3 commits into from
Jun 1, 2021

Conversation

srikiz
Copy link
Contributor

@srikiz srikiz commented May 24, 2021

  • Using interfaces for better unit testing (haven't added yet, but will create that separately)
  • Removing cyclic dependency - moved the code from pkg/resources/digitalocean/cloud.go to upup/pkg/fi/cloudup/do/cloud.go.
  • No changes to the functionality, but just moving code so it's easier to maintain going forward.

FYI - @timoreimann

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 24, 2021
@k8s-ci-robot k8s-ci-robot added the area/provider/digitalocean Issues or PRs related to digitalocean provider label May 24, 2021
@johngmyers
Copy link
Member

Please edit commit history so reviewers don't have to see the back-and-forth. A series of smaller commits is better, making it easier for reviewers to verify that any given refactoring has no functional modification, but the stream should not add an unrelated file and then delete it later.

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

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

Looks good from a DO perspective. I'll leave the official approval to those that bear the right powers. :)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 25, 2021
@timoreimann
Copy link
Contributor

/unassign

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 25, 2021
@johngmyers
Copy link
Member

@srikiz please edit the commit stream so it doesn't add status_discovery.go and then delete it again.

@srikiz
Copy link
Contributor Author

srikiz commented May 25, 2021

@srikiz please edit the commit stream so it doesn't add status_discovery.go and then delete it again.

@johngmyers - is it okay if I squash all the commits once I fix couple of bazel issues?

@srikiz
Copy link
Contributor Author

srikiz commented May 25, 2021

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 25, 2021
@srikiz srikiz changed the title [Digital Ocean] Code cleanup with no functional modifications [WIP] [Digital Ocean] Code cleanup with no functional modifications May 25, 2021
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 25, 2021
@johngmyers
Copy link
Member

@srikiz I'm concerned this might be a bit too big to review in one go. It's easier to review if code is moved in one commit and then cleaned up in a separate commit.

@srikiz
Copy link
Contributor Author

srikiz commented May 26, 2021

@johngmyers - that sounds like a plan. Once I get the issues resolved, I will close this pull request, and create a new one with 2 commits as you suggested. I'll just move the file in the first commit and keep the rest of the changes in a different commit.

@johngmyers
Copy link
Member

@srikiz alternatively you could force-push to this PR.

@srikiz
Copy link
Contributor Author

srikiz commented May 27, 2021

@johngmyers - Hopefully, I got it right :)
In my first commit, I just moved over the file from pkg/resources/digitalocean/cloud.go to upup/pkg/cloudup/do/cloud.go - with the same content.
In my second commit, I have modified the file to make it really work.

All other changes are updating the dependencies to point to the new interface.
Hopefully this helps, please feel free to let me know if you need any additional changes to make it easier for review.

Thanks !

@srikiz srikiz changed the title [WIP] [Digital Ocean] Code cleanup with no functional modifications [Digital Ocean] Code cleanup with no functional modifications May 27, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 27, 2021
Copy link
Member

@johngmyers johngmyers left a comment

Choose a reason for hiding this comment

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

Unfortunately, the second commit is to big. I cannot easily follow to verify the lack of functional modifications. The fact that functions are being reordered at the same time as they or other things are being modified makes the diffs extremely hard to follow.

It also looks like the first commit won't compile, but is fixed up in the second commit. I can work around some of that, but it makes reviewing a harder task.

upup/pkg/fi/cloudup/do/cloud.go Outdated Show resolved Hide resolved
@@ -0,0 +1,566 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

This file should not be added then removed. Please edit it out of the commit stream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, Removed it.

protokube/pkg/protokube/do_volume.go Show resolved Hide resolved
@srikiz
Copy link
Contributor Author

srikiz commented May 28, 2021

Unfortunately, the second commit is to big. I cannot easily follow to verify the lack of functional modifications. The fact that functions are being reordered at the same time as they or other things are being modified makes the diffs extremely hard to follow.

It also looks like the first commit won't compile, but is fixed up in the second commit. I can work around some of that, but it makes reviewing a harder task.

@johngmyers - Apologize, its creating a problem in reviewing this. My first commit is failing since I just moved the same file over to upup/pkg/fi/cloudup/do. But I fixed all issues in my second commit, but placing of the functions didn't match well with the original code.

@johngmyers
Copy link
Member

(I haven't yet had time to review your latest push.)

@srikiz my primary task as reviewer is to verify the claim that there are no functional modifications. Like any human, I have limited short-term memory, so the fewer things I have to track at once the more practical the task.

So the request is to have a series of self-contained commits, so that I can review one commit, then discard most state about that commit and move to the next. As an exception to the expectation that each commit should be self-contained and compile, it is customary for larger changes to automatically generated files to be in a separate commit.

You might find it helpful to look at some of my refactoring PRs, for example #11219 (though that has functional changes mixed in).

@srikiz
Copy link
Contributor Author

srikiz commented May 28, 2021

/retest

@srikiz
Copy link
Contributor Author

srikiz commented May 28, 2021

@johngmyers - thank you for your time on this. My updated commit stream should hopefully make it easier now. I have re-ordered the functions so it is in-line with the changes in the first commit. Please feel free to let me know if you need further modifications. Thanks again, for the help !!

// DOCloud exposes all the interfaces required to operate on DigitalOcean resources
type DOCloud interface {
fi.Cloud
//Client() *godo.Client
Copy link
Member

Choose a reason for hiding this comment

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

nit: this should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated.

//Client() *godo.Client
DropletsService() godo.DropletsService
DropletActionService() godo.DropletActionsService
VolumeService() godo.StorageService
Copy link
Member

Choose a reason for hiding this comment

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

Since this is specific to DO, perhaps it should stick with the DO terminology.

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'll probably keep this as-is for now, and rename this to StorageService as a separate PR.


dns dnsprovider.Interface

// region holds the DO region
Copy link
Member

Choose a reason for hiding this comment

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

nit: should be a complete sentence, including punctuation:

Suggested change
// region holds the DO region
// region holds the DO region.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated.

func (c *Cloud) DNS() (dnsprovider.Interface, error) {
return c.dns, nil
func (c *doCloudImplementation) DNS() (dnsprovider.Interface, error) {
provider := dns.NewProvider(c.Client)
Copy link
Member

Choose a reason for hiding this comment

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

Why doesn't this return c.dns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed that, updated it.

Copy link
Member

@johngmyers johngmyers left a comment

Choose a reason for hiding this comment

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

These comments are all small enough to leave to follow-up work.

Thank you, that was much easier to review.


// FindVPCInfo is not implemented, it's only here to satisfy the fi.Cloud interface
func (c *doCloudImplementation) FindVPCInfo(id string) (*fi.VPCInfo, error) {
return nil, errors.New("Not implemented")
Copy link
Member

Choose a reason for hiding this comment

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

Go errors should always start with lowercase letters

Suggested change
return nil, errors.New("Not implemented")
return nil, errors.New("not implemented")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, updated.

// MockLoadBalancers godo.LoadBalancersService
// MockDomain godo.DomainsService
// MockActions godo.ActionsService
// }
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-out code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, removed.


// FindVPCInfo is not implemented, it's only here to satisfy the fi.Cloud interface
func (c *doCloudMockImplementation) FindVPCInfo(id string) (*fi.VPCInfo, error) {
return nil, errors.New("Not implemented")
Copy link
Member

Choose a reason for hiding this comment

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

lowercase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, updated.

}

func (c *doCloudMockImplementation) DeleteInstance(instance *cloudinstances.CloudInstance) error {
return errors.New("Not tested")
Copy link
Member

Choose a reason for hiding this comment

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

lowercase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: johngmyers, timoreimann

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 May 29, 2021
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2021
@johngmyers
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2021
@srikiz
Copy link
Contributor Author

srikiz commented Jun 1, 2021

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 1, 2021
@k8s-ci-robot k8s-ci-robot merged commit 91d8ffe into kubernetes:master Jun 1, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone Jun 1, 2021
@srikiz srikiz deleted the DO-Use-Interfaces branch June 1, 2021 14:19
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. area/provider/digitalocean Issues or PRs related to digitalocean provider 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants