STOR-2997: Minimal implementation of GCP PD CSI driver operator#576
Conversation
This PR implements the minimal set of go-files and yaml-assets to enable the command ``` ./bin/gcp-pd-csi-driver-smb-operator start --kubeconfig $KUBECONFIG --namespace openshift-cluster-csi-drivers ``` to install and run GCP PD CSI driver: ``` gcp-pd-csi-driver-controller-c949b748-xkljz 10/10 Running 0 3m2s gcp-pd-csi-driver-controller-c949b748-xvgl9 10/10 Running 0 3m2s gcp-pd-csi-driver-node-5kcw5 3/3 Running 0 3m2s gcp-pd-csi-driver-node-frl74 3/3 Running 0 3m2s gcp-pd-csi-driver-node-gf9k7 3/3 Running 0 3m2s gcp-pd-csi-driver-node-p95sv 3/3 Running 0 3m2s gcp-pd-csi-driver-node-q4r98 3/3 Running 0 3m2s gcp-pd-csi-driver-node-xvmgq 3/3 Running 0 3m2s ```
|
@mpatlasov: This pull request references STOR-2997 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
@mpatlasov: GitHub didn't allow me to request PR reviews from the following users: openshift/storage. Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn response to this:
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-sigs/prow repository. |
📝 WalkthroughWalkthroughThis pull request adds a new CLI entrypoint for the GCP PD CSI Driver Operator at cmd/gcp-pd-csi-driver-operator/main.go, using Cobra to define a root command and a "start" subcommand wired via controllercmd.NewControllerCommandConfig. It also introduces pkg/driver/gcp-pd/gcp_pd.go, which provides GetGCPPDOperatorConfig for operator runtime configuration and GetGCPPDOperatorControllerConfig for controller configuration, including cluster flavour validation and starting client config informers. Changes
Sequence Diagram(s)sequenceDiagram
participant main
participant NewOperatorCommand
participant runCSIDriverOperator
participant GetGCPPDOperatorConfig
participant RunOperator
main->>NewOperatorCommand: build CLI command
NewOperatorCommand->>runCSIDriverOperator: execute start subcommand
runCSIDriverOperator->>GetGCPPDOperatorConfig: fetch operator config
runCSIDriverOperator->>RunOperator: run with controller context
Related issues: None specified. Related PRs: None specified. Suggested labels: enhancement, gcp-pd, new-driver Suggested reviewers: None specified. Poem: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (2 errors)
✅ Passed checks (13 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mpatlasov The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pkg/driver/gcp-pd/gcp_pd.go (1)
36-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFix malformed log call and redundant/non-idiomatic error message.
klog.Error(nil, "...")treatsnilas afmt.Print-style argument (klog'sErrorargs are "handled in the manner offmt.Print"), so this prints something like<nil>Flavour HyperShift is not supported!instead of a clean message. Additionally, this error is already logged again by the caller (RunOperatorlogs"error building operator config: %v"on any non-nil error from this builder), so the localklog.Errorcall is redundant. Thefmt.Errorfmessage is also capitalized and ends with!, which violates Go's error-string convention (lower-case, no trailing punctuation).🔧 Proposed fix
if flavour != generator.FlavourStandalone { - klog.Error(nil, "Flavour HyperShift is not supported!") - return nil, fmt.Errorf("Flavour HyperShift is not supported!") + return nil, fmt.Errorf("flavour %q is not supported", flavour) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/driver/gcp-pd/gcp_pd.go` around lines 36 - 39, The gcp_pd builder’s unsupported-flavour branch is logging incorrectly and returning a non-idiomatic error. In the config builder path in `gcp_pd.go`, remove the local `klog.Error(nil, ...)` call because `RunOperator` already logs builder failures, and change the returned `fmt.Errorf` message to a lowercase, punctuation-free error string. Keep the check on `flavour != generator.FlavourStandalone` and ensure the branch only returns the clean error.cmd/gcp-pd-csi-driver-operator/main.go (1)
27-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueIgnored error return from
cmd.Help().
cmd.Help()returns anerrorthat's discarded here.🔧 Proposed fix
Run: func(cmd *cobra.Command, args []string) { - cmd.Help() + if err := cmd.Help(); err != nil { + klog.Errorf("failed to print help: %v", err) + } os.Exit(1) },As per path instructions, "Never ignore error returns" for
**/*.go.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/gcp-pd-csi-driver-operator/main.go` around lines 27 - 30, The cobra command’s Run handler is discarding the error from cmd.Help(), which violates the “never ignore error returns” rule. Update the Run function in main.go to check and handle the return value from cmd.Help() explicitly, using the cmd.Help() call itself as the unique locator, and ensure the process still exits with a non-zero status if Help fails.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/gcp-pd-csi-driver-operator/main.go`:
- Around line 27-30: The cobra command’s Run handler is discarding the error
from cmd.Help(), which violates the “never ignore error returns” rule. Update
the Run function in main.go to check and handle the return value from cmd.Help()
explicitly, using the cmd.Help() call itself as the unique locator, and ensure
the process still exits with a non-zero status if Help fails.
In `@pkg/driver/gcp-pd/gcp_pd.go`:
- Around line 36-39: The gcp_pd builder’s unsupported-flavour branch is logging
incorrectly and returning a non-idiomatic error. In the config builder path in
`gcp_pd.go`, remove the local `klog.Error(nil, ...)` call because `RunOperator`
already logs builder failures, and change the returned `fmt.Errorf` message to a
lowercase, punctuation-free error string. Keep the check on `flavour !=
generator.FlavourStandalone` and ensure the branch only returns the clean error.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 51202570-b405-4a12-9cee-b72111c8a207
⛔ Files ignored due to path filters (30)
assets/overlays/gcp-pd/generated/standalone/cabundle_cm.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/controller.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/controller_pdb.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/controller_sa.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/csidriver.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/kube_rbac_proxy_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/kube_rbac_proxy_role.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/lease_leader_election_role.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/lease_leader_election_rolebinding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/main_attacher_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/main_provisioner_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/main_resizer_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/main_snapshotter_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/manifests.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/node.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/node_privileged_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/node_sa.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/privileged_role.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/prometheus_role.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/prometheus_rolebinding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/service.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/servicemonitor.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/storageclass.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/storageclass_reader_resizer_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/storageclass_ssd.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/volumeattributesclass_reader_provisioner_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/volumeattributesclass_reader_resizer_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/volumesnapshot_reader_provisioner_binding.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/volumesnapshotclass.yamlis excluded by!**/generated/**assets/overlays/gcp-pd/generated/standalone/volumesnapshotclass_images.yamlis excluded by!**/generated/**
📒 Files selected for processing (2)
cmd/gcp-pd-csi-driver-operator/main.gopkg/driver/gcp-pd/gcp_pd.go
|
/retest |
|
/retest-required |
1 similar comment
|
/retest-required |
|
@mpatlasov: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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-sigs/prow repository. I understand the commands that are listed here. |
|
/retest-required |
This PR implements the minimal set of go-files and yaml-assets to enable the command
to install and run GCP PD CSI driver:
/cc @openshift/storage