Skip to content

chore: tweak schema for forwardingRule -> memorystore service attachemnt#7635

Open
justinsb wants to merge 2 commits intoGoogleCloudPlatform:masterfrom
justinsb:memorystore_forwardingrule_target
Open

chore: tweak schema for forwardingRule -> memorystore service attachemnt#7635
justinsb wants to merge 2 commits intoGoogleCloudPlatform:masterfrom
justinsb:memorystore_forwardingrule_target

Conversation

@justinsb
Copy link
Copy Markdown
Collaborator

Also we finally hit a circular dependency between compute and memorystore,
so we need to move the instance identity and ref into its own package,
that both compute and memorystore can use without creating a circular dependency.

@justinsb justinsb force-pushed the memorystore_forwardingrule_target branch from 0a1506b to a3d37b7 Compare April 19, 2026 02:00
Comment thread apis/compute/v1beta1/forwardingrule_types.go Outdated
@justinsb
Copy link
Copy Markdown
Collaborator Author

cc @suwandim

/assign @cheftako

/assign @ldanielmadariaga

Looks like we have to create a separate refs package; it's kind of surprising we got away without it for this long. The identity & reference are just moved into a new package memorystorerefs, except that NewInstanceIdentity has a dependency on type Instance, so has to stay in the v1beta1 package.

import (
computev1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/compute/v1beta1"
refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1"
"github.com/GoogleCloudPlatform/k8s-config-connector/apis/memorystore/memorystorerefs"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we repeat "memorystore". I think it makes it much more ergonomic though; even if we called it "memorystore/refs" we'd probably still have to alias it to memorystorerefs (just as we alias the refs package currently)

"strings"
)

// InstanceIdentity defines the resource reference to MemorystoreInstance, which "External" field
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note that we clean up the identity and reference types to follow our latest patterns in #7621

@justinsb justinsb changed the title chore: tweak schema for forwaringRule -> memorystore service attachemnt chore: tweak schema for forwardingRule -> memorystore service attachemnt Apr 19, 2026
@justinsb justinsb force-pushed the memorystore_forwardingrule_target branch from a3d37b7 to dc40a42 Compare April 19, 2026 09:27
Also we finally hit a circular dependency between compute and memorystore,
so we need to move the instance identity and ref into its own package,
that both compute and memorystore can use without creating a circular dependency.
@justinsb justinsb force-pushed the memorystore_forwardingrule_target branch from dc40a42 to 22a9b31 Compare April 19, 2026 11:43
@@ -0,0 +1,61 @@
// Copyright 2025 Google LLC
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Guessing this still needs to say 2026 even if the contents of this file are technically a branch

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will update

Comment thread apis/compute/v1beta1/forwardingrule_types.go Outdated
}

// New builds a InstanceIdentity from the Config Connector Instance object.
func NewInstanceIdentity(ctx context.Context, reader client.Reader, obj *MemorystoreInstance) (*memorystorerefs.InstanceIdentity, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we forced to keep this builder here instead of moving it to memorystorerefs? Even if that's the case seems preferable to just have a passthrough here and avoid the exported fields InstanceIdentity.

Passthrough:

NewInstance(...) {
  return memorystorerefs.NewInstance(...)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If we put it back in the same package we end up with circular dependencies again.

In #7621 we're going to export all the fields anyway. There's no reason to "hide" the Identity schema (IMO).

// InstanceIdentity defines the resource reference to MemorystoreInstance, which "External" field
// holds the GCP identifier for the KRM object.
type InstanceIdentity struct {
Parent_ *InstanceParent
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Weird naming scheme and having exported fields collides a bit with having getters. See my comment in apis/memorystore/v1beta1/instance_types.go

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right - we could merge #7621 first if you'd prefer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is intended, it seems in most cases we prefer to have a generate.sh per API version.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It was intended: once we have refs separately it becomes more obvious that we only need one generate.sh per API version.

However, if we put the refs into apis/refs then I can put this back as it was before. We can always clean this up later.

Comment thread go.mod
k8s.io/klog/v2 => k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff
k8s.io/kubectl => k8s.io/kubectl v0.32.1
sigs.k8s.io/structured-merge-diff/v6 => sigs.k8s.io/structured-merge-diff/v4 v4.6.0
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't know why we're pinning so much stuff here, but this alias is very wrong.

@google-oss-prow google-oss-prow bot added the lgtm label Apr 21, 2026
@google-oss-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found here.

Details 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants