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

Improve configuration management; Improve the relationship between driver, controller, & cloud #1995

Merged

Conversation

torredil
Copy link
Member

@torredil torredil commented Apr 3, 2024

What is this PR about? / Why do we need it?

This patch is the first of two, designed to improve the architecture of the code base with the goal of promoting a more cohesive and understandable design that makes it easier to reason about the driver and make future modifications or extensions more intuitive.

More specifically, this PR improves driver configuration management, migrates the metadata service into its own separate package to encapsulate metadata related functionality, and improves the relationship between driver/controller and cloud by separating the creation of ControllerService from its usage.

Summary of Changes

  1. Fix relationship between cmd/main and pkg/driver

    • The Options struct has been moved to the driver package, consolidating all driver-related configuration options in one place.
    • The cmd package now focuses solely on the main entry point and setting up the necessary dependencies.
    • The NewDriver function now accepts a pointer to Options instead of a variadic function, making it clearer and more straightforward to create a new driver instance.
  2. Migrate metadata service

    • Moved the metadata related files (metadata_ec2.go, metadata.go, metadata_interface.go, metadata_k8s.go, metadata_test.go, and mock_metadata.go) from the cloud package to a new metadata package.
    • Updated hack/update and corresponding generated mocked files.
  3. Improve relationship between driver and cloud

    • Replaced newControllerService with NewControllerService, which now takes a cloud object and options as parameters, allowing for dependency injection and easier testing.
    • Removed the NewMetadataFunc and NewCloudFunc variables as they are no longer needed with the new architecture.
    • Updated the main.go file to create an instance of cloud to pass into NewDriver.
    • Updated tests to reflect the changes made to the ControllerService.

Note to Reviewer

This PR intentionally disables csi-sanity tests temporarily now that NewFakeDriver func which was previously created to instantiate a fake driver utilized in the sanity tests has been removed. These sanity tests must be re-written.

What testing is done?

  • make verify && make test
  • Manual
  • CI

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 3, 2024
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 3, 2024
Copy link

github-actions bot commented Apr 3, 2024

Code Coverage Diff

File Old Coverage New Coverage Delta
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/metadata/ec2.go Does not exist 94.4%
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/metadata/k8s.go Does not exist 80.0%
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/metadata/metadata.go Does not exist 96.7%
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/driver/controller.go 83.6% 83.0% -0.6
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/driver/driver.go 36.5% 0.0% -36.5
github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/driver/options.go Does not exist 100.0%

@torredil torredil changed the base branch from master to csi-refactor April 3, 2024 19:10
@torredil
Copy link
Member Author

torredil commented Apr 3, 2024

/retest

@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from 5ea046f to f1cfddd Compare April 4, 2024 13:38
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 4, 2024
@torredil torredil changed the title Fix relationship between metadata service and cloud Improve configuration management; Improve the relationship between driver, controller, & cloud Apr 4, 2024
@AndrewSirenko
Copy link
Contributor

Nit: let's separate CVE fix from rest of PR. See Fix CVE G0-2024-2687 by bumping go and /x/net dependencies

@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from 7391ee0 to f1cfddd Compare April 4, 2024 19:35
@torredil torredil changed the base branch from csi-refactor to master April 4, 2024 19:43
@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from f1cfddd to c249057 Compare April 4, 2024 19:55
Copy link
Contributor

@AndrewSirenko AndrewSirenko left a comment

Choose a reason for hiding this comment

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

Great work on improving the driver-cloud-metadata-options relationships

cmd/main.go Outdated Show resolved Hide resolved
pkg/driver/options.go Outdated Show resolved Hide resolved
pkg/driver/options.go Outdated Show resolved Hide resolved
pkg/driver/options.go Show resolved Hide resolved
pkg/driver/options.go Outdated Show resolved Hide resolved
pkg/driver/options.go Outdated Show resolved Hide resolved
pkg/driver/options.go Show resolved Hide resolved
pkg/driver/options.go Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
cmd/main.go Show resolved Hide resolved
@torredil
Copy link
Member Author

torredil commented Apr 9, 2024

CI is down:

#14 ERROR: failed to push 209411653980.dkr.ecr.us-west-2.amazonaws.com/aws-ebs-csi-driver:be5dc692422e40e19a55a53cb9388a6e-linux-amd64-al2023: failed commit on ref "manifest-sha256:91d14c9c6a2b2d83d0be6f7224ec8e9061d0f44aa8e82b257491c28de1507d0d": unexpected status from PUT request to https://209411653980.dkr.ecr.us-west-2.amazonaws.com/v2/aws-ebs-csi-driver/manifests/be5dc692422e40e19a55a53cb9388a6e-linux-amd64-al2023: 403 Forbidden

@torredil
Copy link
Member Author

torredil commented Apr 9, 2024

/retest

@torredil
Copy link
Member Author

torredil commented Apr 9, 2024

CI has been restored

@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from 4497e74 to a654703 Compare April 10, 2024 20:34
Copy link
Contributor

@AndrewSirenko AndrewSirenko left a comment

Choose a reason for hiding this comment

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

Much cleaner, wish I ramped up on this version instead :P great work!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
cmd/main.go Outdated Show resolved Hide resolved
cmd/main.go Show resolved Hide resolved
pkg/driver/options.go Show resolved Hide resolved
Makefile Show resolved Hide resolved
@ConnorJC3
Copy link
Contributor

Side note: Will need rebase on top of #2007 after it is merged

@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from a654703 to e6c731a Compare April 12, 2024 18:52
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2024
@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from e6c731a to a32b96b Compare April 12, 2024 19:15
@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from a32b96b to 5caa059 Compare April 12, 2024 19:25
@ConnorJC3
Copy link
Contributor

/label tide/merge-method-squash
/lgtm

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Apr 12, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2024
@torredil
Copy link
Member Author

/retest

1 similar comment
@AndrewSirenko
Copy link
Contributor

/retest

@torredil torredil force-pushed the csi-refactor-cloud-metadata branch from 5caa059 to 42fc084 Compare April 12, 2024 23:00
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2024
@AndrewSirenko
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 15, 2024
@AndrewSirenko
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AndrewSirenko

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 Apr 15, 2024
@k8s-ci-robot k8s-ci-robot merged commit 75d142b into kubernetes-sigs:master Apr 15, 2024
19 checks passed
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants