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

fix: guard against nil model #2059

Merged

Conversation

acpana
Copy link
Collaborator

@acpana acpana commented Jun 18, 2024

The models for the dynamic controller presubmits are nil bc we never Init the registry. This also proved to me that we probably want to error out in AddController if model is nil for a gvk. Finally, if the registration for a gk contains a nil model, we probably want to err out to signal to consumers that Init was not called.

@acpana acpana force-pushed the acpana/fix-direct-test branch from 8fa12b3 to 89f4b9b Compare June 18, 2024 23:04
@acpana acpana changed the title wip:fix: guard against nil model fix: guard against nil model Jun 18, 2024
@acpana acpana marked this pull request as ready for review June 18, 2024 23:08
@@ -39,7 +39,7 @@ type ModelFactoryFunc func(ctx context.Context, config *config.ControllerConfig)

func GetModel(gk schema.GroupKind) (directbase.Model, error) {
registration := singleton.registrations[gk]
if registration == nil {
if registration == nil || registration.model == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also test this one separately and say "Init not called" (I guess?)

Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb

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 30b7d89 into GoogleCloudPlatform:master Jun 20, 2024
13 checks passed
@yuwenma yuwenma added this to the 1.120 milestone Oct 25, 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.

3 participants