-
Notifications
You must be signed in to change notification settings - Fork 241
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
feat: Add Apigee instance controller #3554
base: master
Are you sure you want to change the base?
feat: Add Apigee instance controller #3554
Conversation
f56c7d0
to
774c8a3
Compare
774c8a3
to
a4eed02
Compare
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.
return mapCtx.Err() | ||
} | ||
|
||
if resource.AccessLoggingConfig != nil && !reflect.DeepEqual(resource.AccessLoggingConfig, a.actual.AccessLoggingConfig) { |
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 we use this function to sort and the compare? https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/master/pkg/controller/direct/apigee/envgroup_controller.go#L278
op, err := a.instancesClient.Delete(a.id.String()).Context(ctx).Do() | ||
if err != nil { | ||
if direct.IsNotFound(err) { | ||
// Return success if not found (assume it was already 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.
Suggest adding a log?
return true, nil | ||
} | ||
|
||
func (a *ApigeeInstanceAdapter) waitForOp(ctx context.Context, op *api.GoogleLongrunningOperation) 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.
This can be an individual function. And suggest moving it to the controller/direct/common lib for sharing purpose.
out.AccessLoggingConfig = AccessLoggingConfig_ToAPI(mapCtx, in.AccessLoggingConfig) | ||
out.ConsumerAcceptList = in.ConsumerAcceptList | ||
out.Description = direct.ValueOf(in.Description) | ||
// MISSING: DiskEncryptionKeyName |
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.
Just to double check, do you have a NOTYET comment for this field?
--api-version apigee.cnrm.cloud.google.com/v1alpha1 \ | ||
--kind ApigeeInstance \ | ||
--proto-resource GoogleCloudApigeeV1Instance | ||
|
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.
We don't need to update this file. It is just an example (or is it a requirement now?)
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 let's not add generate-controller command.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: yuwenma 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 |
} | ||
|
||
func (a *ApigeeInstanceAdapter) waitForOp(ctx context.Context, op *api.GoogleLongrunningOperation) error { | ||
for { |
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.
We can probably create a helper function which
- respect the ctx timeout
- take a input timeout
Something like this (AI generated)
func waitUntil(ctx context.Context, timeout time.Duration, condition func() bool) error {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
if err := ctx.Err(); err == context.DeadlineExceeded {
return fmt.Errorf("timeout exceeded")
}
return ctx.Err()
case <-ticker.C:
if condition() {
return nil
}
}
}
}
The pulling interval could also be customized via input
out.PeeringCIDRRange = direct.LazyPtr(in.PeeringCidrRange) | ||
return out | ||
} | ||
func ApigeeInstanceSpec_ToAPI(mapCtx *direct.MapContext, in *krm.ApigeeInstanceSpec) *pb.GoogleCloudApigeeV1Instance { |
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.
where is the mapping function for diskEncryptionKMSCryptoKeyRef
?
This PR adds the mappers, controller, and records GCP interaction for ApigeeInstance. MockGCP tests will come in a separate PR.