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

feat: Add Apigee instance controller #3554

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jasonvigil
Copy link
Collaborator

@jasonvigil jasonvigil commented Jan 29, 2025

This PR adds the mappers, controller, and records GCP interaction for ApigeeInstance. MockGCP tests will come in a separate PR.

@jasonvigil jasonvigil force-pushed the apigee-instance-controller branch from 774c8a3 to a4eed02 Compare January 30, 2025 23:14
@jasonvigil jasonvigil changed the title [WIP] Add Apigee instance controller feat: Add Apigee instance controller Jan 30, 2025
Copy link
Collaborator

@yuwenma yuwenma left a comment

Choose a reason for hiding this comment

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

/approve
/assign @jingyih

A few nits but overall looks great on my side. Can I have @jingyih to take another pass?

return mapCtx.Err()
}

if resource.AccessLoggingConfig != nil && !reflect.DeepEqual(resource.AccessLoggingConfig, a.actual.AccessLoggingConfig) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

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 {
Copy link
Collaborator

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
Copy link
Collaborator

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

Copy link
Collaborator

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?)

Copy link
Collaborator

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.

Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

}

func (a *ApigeeInstanceAdapter) waitForOp(ctx context.Context, op *api.GoogleLongrunningOperation) error {
for {
Copy link
Collaborator

@jingyih jingyih Jan 31, 2025

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 {
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants