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

[v2] Use an apply configuration for the workspace template #713

Merged
merged 6 commits into from
Oct 17, 2024

Conversation

blampe
Copy link
Contributor

@blampe blampe commented Oct 9, 2024

This adds applyconfiguration-gen to generate apply configurations for our APIs. The workspace template is updated to use it.

It's a moderately uphill battle to get apply configurations working with controllers due to various pieces not including built-in support for them. In practice this means we need to cut a couple small corners -- in particular implementing our own DeepCopy and tweaking the generated GroupVersion code.

Fixes #704.

Comment on lines +371 to +372
PodTemplate: &apply.EmbeddedPodTemplateSpecApplyConfiguration{
Metadata: &apply.EmbeddedObjectMetaApplyConfiguration{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we're happy with the direction of this I can take it further and also use an apply config for our pod template -- it should be very minor.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be pretty wonderful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I spoke too soon -- this is actually quite involved. I'll put up a WIP with what I have so far.

WorkspaceTemplate: &autov1alpha1.EmbeddedWorkspaceTemplateSpec{
Metadata: autov1alpha1.EmbeddedObjectMeta{
WorkspaceTemplate: &shared.WorkspaceApplyConfiguration{
ObjectMetaApplyConfiguration: &metav1apply.ObjectMetaApplyConfiguration{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth calling out that ObjectMetaApplyConfiguration differs from EmbeddedWorkspaceTemplateSpec in that it does expose all of the underlying fields (like generation) even if they can't actually be set. I think it makes for a more bloated/confusing schema but I don't see a good way around it.

Copy link
Member

Choose a reason for hiding this comment

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

This approach is similar to PodTemplateSpec so it shouldn't add confusion to K8s users.

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Project coverage is 49.93%. Comparing base (2884fad) to head (f3715ee).
Report is 1 commits behind head on v2.

Files with missing lines Patch % Lines
operator/internal/apply/utils.go 0.00% 25 Missing ⚠️
operator/api/pulumi/shared/stack_types.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2     #713      +/-   ##
==========================================
- Coverage   51.20%   49.93%   -1.27%     
==========================================
  Files          29       30       +1     
  Lines        3199     4031     +832     
==========================================
+ Hits         1638     2013     +375     
- Misses       1379     1836     +457     
  Partials      182      182              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@blampe blampe added impact/no-changelog-required This issue doesn't require a CHANGELOG update and removed impact/changelog labels Oct 9, 2024
Copy link
Contributor

@EronWright EronWright left a comment

Choose a reason for hiding this comment

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

Awesome! Good job finding a workaround for the DeepCopy issue.

Metadata EmbeddedObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Spec *WorkspaceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
}

// EmbeddedObjectMeta contains a subset of the fields included in k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
// Only fields which are relevant to embedded resources are included.
type EmbeddedObjectMeta struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is EmbeddedObjectMeta obsolete?

Comment on lines +371 to +372
PodTemplate: &apply.EmbeddedPodTemplateSpecApplyConfiguration{
Metadata: &apply.EmbeddedObjectMetaApplyConfiguration{
Copy link
Contributor

Choose a reason for hiding this comment

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

That would be pretty wonderful.

@blampe blampe merged commit d52056a into v2 Oct 17, 2024
7 checks passed
@blampe blampe deleted the blampe/applyconfig branch October 17, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants