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] Program controller and file server for program objects #673

Merged
merged 8 commits into from
Sep 24, 2024

Conversation

rquitales
Copy link
Member

@rquitales rquitales commented Sep 20, 2024

Proposed changes

This PR enables a Workspace pod to fetch a Program object in a similar fashion to how it fetches Flux artifacts. We do this by exposing a HTTP server that serves tarballs of a fully formed Pulumi.yaml file, incorporating the requested Program spec. Unlike the approach with the Flux source-controller, I've opted not to create/store these tar files in local ephemeral storage in the controller pod. Instead, when the artifact URL is accessed, the file server will fetch the requested Program resource from the Kubernetes API server, and wrap it up in a Pulumi.yaml file and tarred. This approach ensures that the most recent Program spec is always served, and it also greatly simplifies storage since we do not need to create a local duplicate of these Program objects. Since the source of truth is always on cluster, we do not need to continuously reconcile and generate new artifacts for new generations of Programs. Should we choose to change this implementation in the future, the current strategy using the status field to convey the URL should make it easy to do so.

  • Add status field to the Program resource to advertise a downloadable URL for the program
  • Scaffold a program-controller to reconcile the status/URL
  • Create a simple file server to serve the fully-formed Pulumi.yaml from a Program URL
  • Update deployment manifests to expose the file server
  • Additional unit tests
  • Rebase PR to take in test changes
  • Integrate with stack-controller

Related issues (optional)

Closes: #651

@rquitales rquitales changed the base branch from master to v2 September 20, 2024 16:45
@rquitales rquitales added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Sep 20, 2024
@rquitales rquitales force-pushed the rquitales/program-controller branch from 53191e3 to a0d0eef Compare September 20, 2024 17:43
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 26.97674% with 157 lines in your changes missing coverage. Please review.

Project coverage is 33.11%. Comparing base (af4964f) to head (c07c641).
Report is 1 commits behind head on v2.

Files with missing lines Patch % Lines
...r/internal/controller/pulumi/program_controller.go 35.53% 69 Missing and 9 partials ⚠️
operator/cmd/main.go 18.30% 56 Missing and 2 partials ⚠️
...tor/internal/controller/pulumi/stack_controller.go 0.00% 17 Missing ⚠️
...ator/internal/controller/pulumi/metrics_program.go 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2     #673      +/-   ##
==========================================
- Coverage   33.25%   33.11%   -0.15%     
==========================================
  Files          25       27       +2     
  Lines        3951     4161     +210     
==========================================
+ Hits         1314     1378      +64     
- Misses       2475     2610     +135     
- Partials      162      173      +11     

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

operator/api/pulumi/v1/artifact_types.go Outdated Show resolved Hide resolved

// LastResyncTime contains a timestamp for the last time a resync of the stack took place.
// +optional
LastResyncTime metav1.Time `json:"lastResyncTime,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand; multiple stacks could use the same program, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

I still think this field should be removed because a) it is redundant given the observedGeneration, and b) it uses the term "sync" which has a particular (different) meaning in PKO.

Copy link
Member Author

Choose a reason for hiding this comment

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

  • field should be removed: I'm opposed to this more so because we can have multiple reconciliation on the same generation. Take the example where a Program object has been reconciled and the status is written to it. If the controller pod restarts, there might be a possibility that the hostname has changed (though very unlikely). When the controller pod restarts, it will reconcile all objects it should watch for, and thus, the URL stored in status will be updated. It would be helpful for debugging purposes to know when the URL was generated.
  • the term "sync" which has a particular (different) meaning in PKO.: yes, a different name for this field, should we ultimately decide to keep it, should be used!

Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed this field for now, to merge this PR in eagerly. We can rethink how we want to handle this and add this in the future if we choose to.

operator/api/pulumi/v1/program_types.go Outdated Show resolved Hide resolved
operator/cmd/main.go Outdated Show resolved Hide resolved
operator/cmd/main.go Outdated Show resolved Hide resolved
operator/cmd/main.go Outdated Show resolved Hide resolved
operator/cmd/main.go Outdated Show resolved Hide resolved
operator/config/manager/kustomization.yaml Outdated Show resolved Hide resolved
operator/internal/controller/pulumi/program_controller.go Outdated Show resolved Hide resolved
@rquitales rquitales changed the title [WIP] Program controller and file server for program objects [V2] Program controller and file server for program objects Sep 21, 2024
@rquitales rquitales force-pushed the rquitales/program-controller branch 2 times, most recently from dcbd67e to f376743 Compare September 23, 2024 22:51
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.

Looks great, just left a couple of comments.

Copy link
Contributor

@blampe blampe left a comment

Choose a reason for hiding this comment

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

Looks good, mostly just some nits but nothing blocking.

operator/internal/controller/pulumi/program_controller.go Outdated Show resolved Hide resolved
operator/internal/controller/pulumi/program_controller.go Outdated Show resolved Hide resolved
operator/internal/controller/pulumi/program_controller.go Outdated Show resolved Hide resolved
Comment on lines +301 to +282
if _, err = stackInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: newProgramCallback,
DeleteFunc: deleteProgramCallback,
}); err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

operator/internal/controller/pulumi/program_controller.go Outdated Show resolved Hide resolved
operator/internal/controller/pulumi/stack_controller.go Outdated Show resolved Hide resolved
@rquitales rquitales force-pushed the rquitales/program-controller branch from 6e343d2 to c07c641 Compare September 24, 2024 19:54
@rquitales rquitales merged commit 2a40b39 into v2 Sep 24, 2024
7 checks passed
@rquitales rquitales deleted the rquitales/program-controller branch September 24, 2024 21:33
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.

Implement the Program API
3 participants