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

Generate CRDs & mappers for BigtableInstance #2288

Conversation

justinsb
Copy link
Collaborator

  • chore: generate CRDs for BigtableInstance from protos
  • chore: generate mappers for bigtable

@justinsb justinsb force-pushed the generate_mappers_for_bigtableinstance branch 2 times, most recently from db8622b to eb2318e Compare July 16, 2024 12:33
@justinsb justinsb changed the title generate mappers for bigtableinstance Generate CRDs & mappers for bigtableinstance Jul 16, 2024
@justinsb justinsb changed the title Generate CRDs & mappers for bigtableinstance Generate CRDs & mappers for BigtableInstance Jul 16, 2024
@justinsb justinsb requested a review from yuwenma July 16, 2024 23:19
*/
}

/* NOTYET
Copy link
Collaborator

Choose a reason for hiding this comment

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

If not yet, when?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So typically we / I have started doing one phase where we get the CRD yaml to match the existing CRD yaml. It's not a perfect match, the descriptions aren't exact, and we now mark status.observedGeneration as an int64. But there should be no field changes at this stage (we aren't using a new controller yet)

NOTYET is how I "stash" the fields that are going to be useful as we update the CRD, but we aren't yet adding support.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For this instance, we aren't introducing observedState yet, because it's an existing v1beta1 CRD. The only change we know we need right now for BigtableInstance is around the problems on autoscaling vs numNodes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not against having a TODO/NOTYET but I do think we should communicate when we would want to include it.
If we want other people to contribute, having sign posts which indicate if this fields is ready to be exposed (or not) will help.
It can indicate its time or that not to waste your effort yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any suggestions? We at least want to wait till we have the direct controller. Maybe TODO-AFTER-DIRECT-CONTROLLER ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure. I'd even be happy with something that said something like we want the direct controller to have a minimum 3 month burn in as a beta resource before we add fields the non direct controller did not support.

@@ -70,12 +73,15 @@ spec:
cpuTarget:
description: The target CPU utilization for autoscaling.
Value must be between 10 and 80.
format: int64
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this being explicit or does this represent a change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ugh .. good call...

/hold

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, it's a change, but I think it's a good change. We should not be using integer in CRDs, we should be using int32 or int64. Here it's an int64 according to the proto.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(And we'll validate that it doesn't need to be quoted in our tests)

@@ -268,6 +268,7 @@ func (v *visitor) writeTypes(out io.Writer, msg protoreflect.MessageDescriptor)
goType = "map[string]int64"
} else {
fmt.Fprintf(out, "// TODO: map type %v %v\n", keyKind, valueKind)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to include field or goFieldName or jsonName here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call - will do!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@justinsb
Copy link
Collaborator Author

I think I need to add mappings for the Cluster also - thanks for spotting the int64 change. It led me to check how this field is mapped in the proto.

/hold

@justinsb justinsb force-pushed the generate_mappers_for_bigtableinstance branch 6 times, most recently from 162d6b2 to 35cf679 Compare July 25, 2024 20:36
@justinsb
Copy link
Collaborator Author

Actually, I don't think it matters yet that we aren't handling the clusters, that needs to be done in the controller, not the mappers.

/hold cancel

@@ -0,0 +1,17 @@
Examples:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels a bit off. It seems like its copied from the generate.sh file. Do we need to keep this up to date? What do I learn here that I wouldn't get from the script and if there is something maybe we should highlight it? If we want to explain to someone how to run a generate an individual resource, maybe we should package the script into individual resources to make that easy and then have a top level which runs them all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed - they should be in generate.sh, and we will DRY generate.sh as we add more types.

I feel like I keep deleting this file, it just won't go away! Deleted!

@@ -139,7 +139,7 @@ func scaffoldDocFile(path string, cArgs *apis.APIArgs) error {
if err := WriteToFile(path, out.Bytes()); err != nil {
return err
}
color.HiGreen("New file added %s!\n", path)
color.HiGreen("New file added %s\n", path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest we use %q for paths. I don't expect spaces, new lines etc in them but better to be safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case I removed the ! so that it is clickable. Agreed though, fixed

}

func BackupInfo_StartTime_FromProto(mapCtx *direct.MapContext, in *timestamppb.Timestamp) *string {
mapCtx.NotImplemented()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a test to ensure that passing a StartTime in a big table resource does not cause an error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have a fuzz test that checks the reachable functions, yes. This one is not reachable, because the BackupInfo message is not reachable. @jingyih is adding reachability testing at the proto level in another PR, so we may be able to not generate these unreachable messages in future (and thus we wouldn't need these methods)

I also think when we have the code to not emit functions that are already defined, we can generate default versions of these functions. We just don't have enough data yet on what they should look like ... need to do more resources!

Some more work in the controllerbuilder for oneof and optional enums.
@justinsb justinsb force-pushed the generate_mappers_for_bigtableinstance branch from 35cf679 to 8b11371 Compare July 26, 2024 17:22
@cheftako
Copy link
Collaborator

/lgtm
/approve

Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheftako

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

@google-oss-prow google-oss-prow bot merged commit 378a294 into GoogleCloudPlatform:master Jul 26, 2024
14 checks passed
@yuwenma yuwenma added this to the 1.121 milestone Aug 3, 2024
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.

None yet

3 participants