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

Make sure we pass the live config to the conversion webhook #6450

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro
resolutionv1alpha1GroupVersion = resolutionv1alpha1.SchemeGroupVersion.Version
resolutionv1beta1GroupVersion = resolutionv1beta1.SchemeGroupVersion.Version
)
// Decorate contexts with the current state of the config.
store := defaultconfig.NewStore(logging.FromContext(ctx).Named("config-store"))
Copy link
Member

Choose a reason for hiding this comment

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

do you know why in the other controllers, store.WatchConfigs is called within the inner function?

Copy link
Member Author

Choose a reason for hiding this comment

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

do you know why in the other controllers, store.WatchConfigs is called within the inner function?

Ah, that's a good point, I don't know, but it should be the same for all at least 😛 So I can move it there. It works in both cases, not sure what is the reason.

Copy link
Member

Choose a reason for hiding this comment

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

It's because of the difference in the outer function definitions.

Note newValidationAdmissionController takes in a parameter of type string and returns func which has two parameters (Context, Watcher) and returns controller.Impl whereas newConversionController takes two parameters (Context, Watcher) and returns controller.Impl.

func newValidationAdmissionController(name string) func(context.Context, configmap.Watcher) *controller.Impl { ... }
func newConversionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { ... }

Does it make sense?

Copy link
Member Author

Choose a reason for hiding this comment

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

@pritidesai I think it does 😝

store.WatchConfigs(cmw)
return conversion.NewConversionController(ctx,
// The path on which to serve the webhook
"/resource-conversion",
Expand Down Expand Up @@ -209,7 +212,7 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro

// A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata
func(ctx context.Context) context.Context {
return ctx
return store.ToContext(ctx)
},
)
}
Expand Down