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

fix: Prevent GCPManagedCluster reconciler to not crash if Network.Name and Network.Subnets is not passed to it #1284

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tasdikrahman
Copy link
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1187

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

fix: Prevent GCPManagedCluster reconciler to not crash if Network.Name and Network.Subnets is not passed to it

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 8, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @tasdikrahman. 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-sigs/prow repository.

Copy link

netlify bot commented Jul 8, 2024

Deploy Preview for kubernetes-sigs-cluster-api-gcp ready!

Name Link
🔨 Latest commit 3f56e75
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-gcp/deploys/66bdd582e4d04000080d39d6
😎 Deploy Preview https://deploy-preview-1284--kubernetes-sigs-cluster-api-gcp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 8, 2024
@tasdikrahman
Copy link
Member Author

$ make test    
KUBEBUILDER_ASSETS="/Users/trahman/Library/Application Support/io.kubebuilder.envtest/k8s/1.29.0-darwin-arm64" go test ./...
?   	sigs.k8s.io/cluster-api-provider-gcp	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/cloud	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/cloud/gcperrors	[no test files]
ok  	sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/providerid	(cached)
?   	sigs.k8s.io/cluster-api-provider-gcp/cloud/scope/mocks	[no test files]
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/scope	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/firewalls	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/instances	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/loadbalancers	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/networks	(cached)
?   	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/container/nodepools	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/shared	[no test files]
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/subnets	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/cloud/services/container/clusters	1.290s
?   	sigs.k8s.io/cluster-api-provider-gcp/exp	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/feature	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/hack/boilerplate/test	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/util/resourceurl	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/util/location	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/util/hash	[no test files]
?   	sigs.k8s.io/cluster-api-provider-gcp/version	[no test files]
ok  	sigs.k8s.io/cluster-api-provider-gcp/controllers	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/exp/controllers	(cached)
ok  	sigs.k8s.io/cluster-api-provider-gcp/util/reconciler	(cached)
$ make lint                                                                                                                                (test-beneficial-bean/default)
/Users/trahman/work/src/github.com/tasdikrahman/cluster-api-provider-gcp/hack/tools/bin/golangci-lint-v1.58.2 run -v
INFO [config_reader] Config search paths: [./ /Users/trahman/work/src/github.com/tasdikrahman/cluster-api-provider-gcp /Users/trahman/work/src/github.com/tasdikrahman /Users/trahman/work/src/github.com /Users/trahman/work/src /Users/trahman/work /Users/trahman /Users /]
INFO [config_reader] Used config file .golangci.yml
WARN [config_reader] The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`.
INFO [lintersdb] Active 64 linters: [asasalint asciicheck bidichk bodyclose canonicalheader decorder dogsled durationcheck errcheck errchkjson errname exportloopref fatcontext ginkgolinter gocheckcompilerdirectives gochecksumtype goconst gocritic gocyclo godox gofmt gofumpt goheader goimports gomodguard goprintffuncname gosec gosimple gosmopolitan govet grouper importas ineffassign loggercheck makezero mirror misspell musttag nakedret nolintlint nosprintfhostport perfsprint prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint spancheck sqlclosecheck staticcheck stylecheck tagalign tenv testableexamples unconvert unparam unused usestdlibvars wastedassign whitespace zerologlint]
INFO [loader] Go packages loading at mode 575 (deps|files|types_sizes|compiled_files|exports_file|imports|name) took 745.976208ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 4.947416ms
INFO [linters_context/goanalysis] analyzers took 2.486599605s with top 10 stages: gosec: 1.278079083s, the_only_name: 437.987ms, buildir: 196.913091ms, wastedassign: 135.083584ms, unparam: 40.940417ms, buildssa: 40.341834ms, gocritic: 38.963125ms, gofumpt: 33.484709ms, S1038: 32.878ms, goimports: 24.902833ms
INFO [runner] Issues before processing: 59, after processing: 0
INFO [runner] Processors filtering stat (out/in): skip_files: 57/59, exclude-rules: 6/51, cgo: 59/59, invalid_issue: 59/59, path_prettifier: 59/59, nolint: 0/6, filename_unadjuster: 59/59, skip_dirs: 57/57, autogenerated_exclude: 57/57, identifier_marker: 57/57, exclude: 51/57
INFO [runner] processing took 5.965333ms with stages: autogenerated_exclude: 2.286458ms, nolint: 1.063208ms, exclude-rules: 973.917µs, path_prettifier: 649.249µs, identifier_marker: 615.874µs, exclude: 206.541µs, skip_dirs: 69.792µs, skip_files: 63.667µs, invalid_issue: 25.876µs, cgo: 6.208µs, filename_unadjuster: 2.082µs, max_same_issues: 666ns, fixer: 375ns, diff: 250ns, uniq_by_line: 250ns, source_code: 209ns, sort_results: 208ns, severity-rules: 126ns, max_from_linter: 125ns, path_prefixer: 84ns, path_shortener: 84ns, max_per_file_from_linter: 84ns
INFO [runner] linters took 2.581693791s with stages: goanalysis_metalinter: 2.575655958s
INFO File cache stats: 22 entries of total size 77.9KiB
INFO Memory: 35 samples, avg is 227.1MB, max is 457.8MB
INFO Execution took 3.346837959s

Lint and Tests pass locally.

@richardcase
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 Jul 10, 2024
@tasdikrahman
Copy link
Member Author

Hello @damdo @richardcase , I saw that the https://github.com/joelanford/go-apidiff diff test is failing above for the change introduced here https://github.com/kubernetes-sigs/cluster-api-provider-gcp/pull/1284/files#diff-e36fd81faa8d27206684360336226f7384431b104ff17c7d1dc677628a881e41R119 to an interface to ease testing as earlier it was pointing to a concrete type. Please let me know if you would like me to make any changes for it.

The two places where this new interface is introduced is

  • ManagedControlPlaneScopeParams
  • ManagedControlPlaneScope
  • ManagedMachinePoolScopeParams
  • ManagedMachinePoolScope

@tasdikrahman
Copy link
Member Author

Hello folks, whenever you get time to check the PR again for any changes you would like me to make, I will make the changes requested. Thanks for your time.

Copy link
Member

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

Thanks for this @tasdikrahman .

For an non-GKE cluster, we allow not specifying the network. What this change does is effectively make Network required for GKE clusters even though its marked optional in the API: https://github.com/kubernetes-sigs/cluster-api-provider-gcp/blob/main/exp/api/v1beta1/gcpmanagedcluster_types.go#L44.

We need to be able to have a nil network as this will cause the "default" network to be used. Could you look at where we set the network (here) and instead of what we currently do check for a nil value before setting it? Like we do for ControlPlaneVersion

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 6, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tasdikrahman
Once this PR has been reviewed and has the lgtm label, please ask for approval from richardcase. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 15, 2024
@k8s-ci-robot
Copy link
Contributor

@tasdikrahman: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-gcp-verify 3f56e75 link true /test pull-cluster-api-provider-gcp-verify
pull-cluster-api-provider-gcp-apidiff 3f56e75 link false /test pull-cluster-api-provider-gcp-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 15, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nil pointer dereference, on an invalid spec
3 participants