-
Notifications
You must be signed in to change notification settings - Fork 242
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
Migrate BQ reservation from TF-based to direct controller v1alpha1 #3569
base: master
Are you sure you want to change the base?
Migrate BQ reservation from TF-based to direct controller v1alpha1 #3569
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
e5c94ae
to
44a4afc
Compare
Can we rerun the test to update the golden object? The diff looks fine to me. The default value of annotation "cnrm.cloud.google.com/management-conflict-prevention-policy" is "none".
|
// to create a failover reservation or in update reservation calls to convert | ||
// a non-failover reservation to a failover reservation(or vice versa). | ||
// +kcc:proto:field=google.cloud.bigquery.reservation.v1.Reservation.secondary_location | ||
SecondaryLocation *string `json:"secondaryLocation,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how primaryLocation
, secondaryLocation
, and originalPrimaryLocation
are being used. Could we capture their usage by adding a test? Alternatively, we could comment them out for now and reintroduce them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields are being used only for the BQ managed DR when the BQ edition is enterprise-plus.
I will be adding more tests to capture different scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
primaryLocation
and originalPrimaryLocation
are fine, they're both output-only. So when the secondaryLocation
is being specified, this means the managed DR is enabled, in this case the API will return primaryLocation
, secondaryLocation
and originalPrimaryLocation
in the response.
see the http.log:
"originalPrimaryLocation": "us-west2",
"primaryLocation": "us-west2",
"secondaryLocation": "us-east1",
The only tricky part is secondaryLocation
. According to the API, users can set this in create
reservation calls to create a failover reservation or in update
reservation calls to convert a non-failover reservation to a failover reservation(or vice versa).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the API, users can set this in create reservation calls to create a failover reservation or in update reservation calls to convert a non-failover reservation to a failover reservation(or vice versa).
Can we add one test case to convert a failover reservation to a non-failover; and one test case to convert a non failover to a failover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uploaded two tests to capture the http logs from real gcp. Turns out that API doesn't change the output returned to the PATCH requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that API doesn't change the output returned to the PATCH requests
I left a comment regarding updateMask
in the http PATCH request. I think it is related to the behavior you observed here. Let's fix the update logic in controller first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package v1alpha1 | ||
|
||
// +kcc:proto=google.cloud.bigquery.reservation.v1.Reservation | ||
type Reservation struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you record the controller builder commands used for types and mappings in generate.sh
? Also, when rerunning the script, it should remove the type Reservation struct
since it already exists in the reservation_types
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused, do you mean that I should rerun the command below to generate the type for reservation?
go run main.go generate-controller \
--service google.cloud.bigquery.reservation.v1 \
--api-version "bigqueryreservation.cnrm.cloud.google.com/v1alpha1" \
--kind BigqueryReservationReservation \
--proto-resource Reservation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah rerunning the command should help cleanup the unnecessary code in types.generated.go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing has changed after rerunning the command, this is the output:
file /usr/local/google/home/luyul/go/src/github.com/600lyy/k8s-config-connector/pkg/controller/direct/bigqueryreservation/reservation_controller.go already exists, skipping
New controller Reservation has been registered.
pkg/controller/direct/bigqueryreservation/reservation_controller.go
Outdated
Show resolved
Hide resolved
pkg/controller/direct/bigqueryreservation/reservation_controller.go
Outdated
Show resolved
Hide resolved
...rcedefinition_bigqueryreservationreservations.bigqueryreservation.cnrm.cloud.google.com.yaml
Show resolved
Hide resolved
ba8be10
to
a0f4a2c
Compare
a0f4a2c
to
d5f98e2
Compare
...servation/v1alpha1/bigqueryreservationreservation/failovertononfailoverreservation/_http.log
Outdated
Show resolved
Hide resolved
// to create a failover reservation or in update reservation calls to convert | ||
// a non-failover reservation to a failover reservation(or vice versa). | ||
// +kcc:proto:field=google.cloud.bigquery.reservation.v1.Reservation.secondary_location | ||
SecondaryLocation *string `json:"secondaryLocation,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that API doesn't change the output returned to the PATCH requests
I left a comment regarding updateMask
in the http PATCH request. I think it is related to the behavior you observed here. Let's fix the update logic in controller first.
…r and non-failover reservation
1e44066
to
74a97ee
Compare
…ng between failover and non-failover reservation
Change description
Tests you have done
KCC_USE_DIRECT_RECONCILERS=BigqueryReservationReservation hack/compare-mock fixture/bigqueryreservationenterprise
KCC_USE_DIRECT_RECONCILERS=BigqueryReservationReservation hack/compare-mock fixture/bigqueryreservationstandard
make ready-pr
to ensure this PR is ready for review.