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

feat: add Artifact object #1703

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat: add Artifact object #1703

wants to merge 1 commit into from

Conversation

guilhem
Copy link

@guilhem guilhem commented Dec 23, 2024

This pull request introduces a new Artifact resource to the project, including its schema definition, deep copy functions, and necessary imports and registrations. The most important changes are summarized below:

Introduction of Artifact Resource:

  • Schema Definition: Added the Artifact resource schema, including ArtifactSpec, ArtifactStatus, and ArtifactList in api/v1alpha1/artifact_types.go.
  • Deep Copy Functions: Generated deep copy functions for the Artifact resource in api/v1alpha1/zz_generated.deepcopy.go.

Project Configuration Updates:

  • Resource Grouping: Updated the PROJECT file to include the new Artifact resource.
  • CRD Kustomization: Added the Artifact resource to the config/crd/kustomization.yaml.

Codebase Adjustments:

  • Imports and Scheme Registration: Updated main.go to import the new v1alpha1 package and register it with the scheme [1] [2].

These changes ensure that the new Artifact resource is properly integrated into the existing project structure and configuration.

Signed-off-by: Guilhem Lettron <[email protected]>
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

We really need an RFC for this new type. I made some suggestions, but there are lots of things to decide on, for example readiness (kstatus compat).

Comment on lines +31 to +40
// ArtifactSpec defines the desired state of Artifact
type ArtifactSpec struct {

// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
CurrentVersion string `json:"currentVersion,omitempty"`

// +kubebuilder:validation:Required
Versions map[string]*v1.Artifact `json:"versions,omitempty"`
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// ArtifactSpec defines the desired state of Artifact
type ArtifactSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
CurrentVersion string `json:"currentVersion,omitempty"`
// +kubebuilder:validation:Required
Versions map[string]*v1.Artifact `json:"versions,omitempty"`
}
// ArtifactSpec defines the desired state of Artifact
type ArtifactSpec v1.Artifact

Copy link
Author

@guilhem guilhem Dec 24, 2024

Choose a reason for hiding this comment

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

That's really part of the discussion.
Having only the latest artifact in spec makes it simpler, but also points some problems:

  • status is not made to be backup / stateful. So customers can't rely on it.
  • having status quite implies a controller to manage changes from spec to status.

With everything in spec, it makes things trusty and "backupable":

  • Any producer is responsible for content with any dedicated controller involved.
  • Any consumer can decide to stay on an older version (if user asks “on hold”, for example)

I don't see that many usages of "Status" for an object like an Artifact (but I may be wrong).
But events produced by “consumers” can be a great thing.

Copy link
Member

@stefanprodan stefanprodan Dec 24, 2024

Choose a reason for hiding this comment

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

status is not made to be backup / stateful. So customers can't rely on it.

For sure, no user should relay on anything from this custom resource, status or not is irelevant. This custom resource is a side-efect of some 3rd-party source-controller that should fully manage the artifact. This type of object is not "desired state" it shouldn't be included in the backup. You should backup what ever custom resource your controller uses for "desired state".

source-controller-x would reconcile GitRepositoryX objects and would create/update/delete ArtifactX objects. If you want to pin your source to a Git commit, the user will do this in the GitRepositoryX. Users will never interact with ArtifactX as the artifact is a result of the reconciliation, it's not the "desired state", the artifact is the "actual state".

Copy link
Author

Choose a reason for hiding this comment

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

It's ok for me, just wanted to know if the desired state should be managed by source controller and just an information storage :)

And yes, I'm developing a source-controller for Omaha / Nebraska, so I will need a way to interact with consumers controllers :)

Copy link
Member

@stefanprodan stefanprodan Dec 24, 2024

Choose a reason for hiding this comment

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

Flux source-controller plays no role here, this ArtifactX type is to enable other source controllers to feed data to Flux kustomize-controller. We discussed this in the dev meetings, the artifact for the native Flux sources will remain unchanged, it's part of the .status. For 3rd-party source controllers, they will have to generate the artifact in a standalone object that can be referenced in Flux Kustomizations.

Comment on lines +43 to +44
type ArtifactStatus struct {
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
type ArtifactStatus struct {
}
type ArtifactStatus struct {
// +kubebuilder:validation:Required
History []v1.Artifact `json:"history"`
}

This is how we track versions in Flux APIs, the first entry is the current version, all this logic is already in helm-controller.

@guilhem
Copy link
Author

guilhem commented Dec 24, 2024

Hi @stefanprodan
Definitely this PR + this one fluxcd/kustomize-controller#1324 need more discussion, that's why I put in draft to be used for discussion in a next dev meeting.
It follows this closed PR fluxcd/kustomize-controller#1321 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants