-
Notifications
You must be signed in to change notification settings - Fork 235
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
Support AlloyDBInstance type, mapper and direct controller #3281
base: master
Are you sure you want to change the base?
Support AlloyDBInstance type, mapper and direct controller #3281
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 |
09d53c4
to
230a0fd
Compare
666917f
to
2b857bd
Compare
...sions.k8s.io_v1_customresourcedefinition_alloydbinstances.alloydb.cnrm.cloud.google.com.yaml
Outdated
Show resolved
Hide resolved
return updateOp.UpdateStatus(ctx, status, nil) | ||
} | ||
|
||
func compareInstance(ctx context.Context, actual, desired *krm.AlloyDBInstanceSpec) (updatePaths []string, err error) { |
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.
Is there any problems to use the CompareProtoMessage
function?
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.
Yes, two problems:
CompareProtoMessage
compares all the proto fields, but AlloyDBInstance only supports a subset of the proto fields supported by the API now.CompareProtoMessage
doesn't understand the default values determined by the API code logic. e.g. not-yet supported field,spec.observabilityConfig.trackWaitEvents
, has a default valuetrue
:Line 43 in 6fac4a5
trackWaitEvents: true
Because of the problems, CompareProtoMessage
always return an error no matter if there is any KRM object update or not.
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.
Discussed offline. CompareProtoMessage compares the parsed desired pb with the actual pb, and the actual pb is the result of Find() (API GET). actual pb contains all the service-defaulted values of those unsupported fields and will result in a diff.
Because there are actually quite some unsupported fields, I think it'll be easier for us to compare the supported fields in Update() explicitly, and switch to CompareProtoMessage once we support most/all pb fields.
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.
Can you list which fields that have GCP defaulted values are not supported? It means we may need to deal with them specially in other places
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.
@yuwenma are you suggesting I should list them in comments here?
They are handled specially in mockalloydb and probably won't be touched unless we support them in the CRD: https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/master/mockgcp/mockalloydb/instance.go#L50
log.V(2).Info("deleting instance", "name", a.id) | ||
|
||
// Returning true directly if it is to delete a secondary instance. | ||
// Technically the secondary instance is only abandoned but not deleted. |
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.
Is there an option to "abandon" the instance?
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.
Yes, users can still set cnrm.cloud.google.com/deletion-policy: "abandon"
to abandon the secondary AlloyDBInstance.
The API behavior the comment here describes basically means even if users tries to use KCC to delete a secondary AlloyDBInstance, the underlying secondary AlloyDB instance (the GCP resource) will not be deleted. This is because the instance by itself is not deletable. The deletion of a secondary AlloyDB instance is a side effect of force deletion of a secondary AlloyDB cluster, which can be done via the deletion of a secondary AlloyDBCluster with spec.deletionPolicy
set to FORCE
in KCC.
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.
Are you talking about KCC abandon but not GCP having an abandon concept?
What does the a.gcpClient.DeleteInstance(ctx, req)
returns if the type is SECONDARY
?
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.
Yes, I'm talking about KCC abandon. I think this GCP resource doesn't have an abandon concept.
DeleteInstance() returns the following error if it is a secondary instance:
googleapi: Error 400: Invalid resource state for "projects/[projectNumber]/locations/[location]/clusters/alloydbcluster-2-20241210/instances/alloydbinstance-2-20241210": Cannot delete SECONDARY instance without deleting the SECONDARY cluster. Delete the SECONDARY cluster in force mode to delete the entire cluster and the instances
...sourcefixture/testdata/basic/alloydb/v1beta1/alloydbinstance/fullalloydbinstance/create.yaml
Outdated
Show resolved
Hide resolved
431125c
to
8902f25
Compare
8902f25
to
0b6b188
Compare
...sions.k8s.io_v1_customresourcedefinition_alloydbinstances.alloydb.cnrm.cloud.google.com.yaml
Outdated
Show resolved
Hide resolved
f13cccf
to
59e4167
Compare
func NewInstanceIdentity(ctx context.Context, reader client.Reader, obj *AlloyDBInstance) (*InstanceIdentity, error) { | ||
|
||
// Get Parent | ||
clusterRef, err := refsv1beta1.ResolveAlloyDBCluster(ctx, reader, obj, obj.Spec.ClusterRef) |
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.
nit: could we add a comment to remove the ResolveAlloyDBCluster once we migrate the Cluster instance to direct? Otherwise, it could be easy to forget
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.
Added a TODO to the ResolveAlloyDBCluster() function. It shouldn't be needed after we migrate AlloyDBCluster.
return updateOp.UpdateStatus(ctx, status, nil) | ||
} | ||
|
||
func compareInstance(ctx context.Context, actual, desired *krm.AlloyDBInstanceSpec) (updatePaths []string, err error) { |
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.
Can you list which fields that have GCP defaulted values are not supported? It means we may need to deal with them specially in other places
log.V(2).Info("deleting instance", "name", a.id) | ||
|
||
// Returning true directly if it is to delete a secondary instance. | ||
// Technically the secondary instance is only abandoned but not deleted. |
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.
Are you talking about KCC abandon but not GCP having an abandon concept?
What does the a.gcpClient.DeleteInstance(ctx, req)
returns if the type is SECONDARY
?
24d08f8
to
e33dba7
Compare
Note that the direct controller has this suboptimal deletion UX: #3362 |
Change description
Supported AlloyDBInstance type, mapper and direct controller
spec.resourceID
becomes conditionally mutable (can be updated between empty value and the correct value).spec.instanceType
andspec.instanceTypeRef
are no longer mutually exclusive.status.externalRef
is supported.Tests you have done
make ready-pr
to ensure this PR is ready for review.Logs when running against the real GCP using the direct controller: #3361 Note that the dependent resources are all abandoned to save test time so please ignore the diffs unrelated to AlloyDBInstance.