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

chore: Refactoring utilities to a separate folder to avoid duplication #977

Merged

Conversation

landreasyan
Copy link
Contributor

@landreasyan landreasyan commented Aug 20, 2021

What type of PR is this?

This PR refactors the utilities functions into a separate directory to facilitate the development of the v2 driver that has dependency on these functions outside of azuredisk package. Refactoring utilities functions into a separate directory avoids duplication of these functions in the v2 driver.

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Requirements:

Special notes for your reviewer:

Release note:

none

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 20, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @landreasyan. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 20, 2021
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 20, 2021
@landreasyan landreasyan changed the title chor: Refactoring utilities to a separate folder to avoid duplication chore: Refactoring utilities to a separate folder to avoid duplication Aug 20, 2021
@landreasyan landreasyan marked this pull request as draft August 20, 2021 00:47
@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 Aug 20, 2021
Adding refactoring changes to v2 files.

Refactoring remaining v2 files.

Updating formatting.
@landreasyan landreasyan force-pushed the azuredisk-utilities-refactoring branch from 2a12f3b to 76da6fe Compare August 20, 2021 02:07
@landreasyan landreasyan marked this pull request as ready for review August 20, 2021 02:23
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Aug 20, 2021
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 20, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 23, 2021
"regexp"
)

const (
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should move these to their own constants package to consistently access them through that alias rather than both constants and azureutils?

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 was also thinking of making constants separate package but left it as this for now. If there are no objections for having them as separate package, I would love to make that change.

Copy link
Collaborator

@edreed edreed Aug 23, 2021

Choose a reason for hiding this comment

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

I have no objections - I believe it would be a good thing to do. @andyzhangx What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

use consts instead of constants ?

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 have refactored constants into a separate pkg.

@andyzhangx
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 24, 2021
"regexp"
)

const (
Copy link
Member

Choose a reason for hiding this comment

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

use consts instead of constants ?

pkg/azuredisk/nodeserver.go Outdated Show resolved Hide resolved
pkg/azuredisk/nodeserver.go Outdated Show resolved Hide resolved
@edreed edreed mentioned this pull request Aug 24, 2021
4 tasks
@landreasyan landreasyan force-pushed the azuredisk-utilities-refactoring branch from cc38df9 to 961207e Compare August 24, 2021 23:43
Refactoring constants into a separate package.

Refactoring constants into a separate package.
@landreasyan landreasyan force-pushed the azuredisk-utilities-refactoring branch from 961207e to 3efbcba Compare August 24, 2021 23:45
pkg/azuredisk/azuredisk.go Outdated Show resolved Hide resolved
@andyzhangx
Copy link
Member

/retest

Copy link
Member

@andyzhangx andyzhangx left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 25, 2021
@andyzhangx
Copy link
Member

there is ut failure:

sigs.k8s.io/azuredisk-csi-driver/pkg/azuredisk [sigs.k8s.io/azuredisk-csi-driver/pkg/azuredisk.test]
pkg/azuredisk/controllerserver_test.go:136:8: undefined: logicalSectorSizeField
pkg/azuredisk/controllerserver_test.go:359:8: undefined: skuNameField
pkg/azuredisk/controllerserver_test.go:371:23: undefined: managedDiskPath
pkg/azuredisk/controllerserver_test.go:771:19: undefined: cachingModeField

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

edreed commented Aug 25, 2021

/lgtm
/retest

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

edreed commented Aug 25, 2021

/retest

@edreed
Copy link
Collaborator

edreed commented Aug 25, 2021

The job pull-azuredisk-csi-driver-verify is failing with the following error:

Verifying gofmt
diff -u ./pkg/azuredisk/fake_azuredisk_v2.go.orig ./pkg/azuredisk/fake_azuredisk_v2.go
--- ./pkg/azuredisk/fake_azuredisk_v2.go.orig	2021-08-25 20:43:08.391083629 +0000
+++ ./pkg/azuredisk/fake_azuredisk_v2.go	2021-08-25 20:43:08.391083629 +0000
@@ -1,3 +1,4 @@
+//go:build azurediskv2
 // +build azurediskv2
...

It looks like Go is changing the format of the build tags from // +build <tag1> <tag2> to //go:build <tag1> || <tag2> enabling the use of Boolean expressions to make it easier to understand when they apply. (See golang/go#41184.) This change is being transitioned in starting with Go 1.17 and it looks like the kubekins-e2e images used to run the Prow jobs have been updated to this version. (kubernetes/test-infra#23354, I think.) Although the Go compiler still accepts 1.16- build tags, gofmt has been updated to flag the usage of the old tags. Thus the reason for the pull-azuredisk-csi-driver-verify failures.

There is a proposed transition here: https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md#transition. Basically, we need to duplicate the old build tags in the new format, e.g.

// +build azurediskv2
//go:build azurediskv2

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

edreed commented Aug 25, 2021

Now verify-boilerplate.sh is failing with the following errors:

Verifying boilerplate
Header in /home/prow/go/src/sigs.k8s.io/azuredisk-csi-driver/hack/../pkg/azuredisk/fake_azuredisk_v2.go does not match reference, diff:

--- reference
+++ /home/prow/go/src/sigs.k8s.io/azuredisk-csi-driver/hack/../pkg/azuredisk/fake_azuredisk_v2.go
@@ -1,3 +1,4 @@
+//go:build azurediskv2
 /*
 Copyright YEAR The Kubernetes Authors.
 
@@ -13,4 +14,3 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 */
-
...

The hack/boilerplate/boilerplate.py script needs to be update to understand the new build tags. A similar change was made in kubernetes/kubernetes#103692 (boilerplate.py).

@edreed
Copy link
Collaborator

edreed commented Aug 26, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 26, 2021
@edreed
Copy link
Collaborator

edreed commented Aug 26, 2021

/retest

Copy link
Member

@andyzhangx andyzhangx left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx, landreasyan

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 merged commit 6663aee into kubernetes-sigs:master Aug 26, 2021
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

4 participants