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

MCO-1443: Promote onclusterbuild to GA #2090

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

yuqi-zhang
Copy link
Contributor

@yuqi-zhang yuqi-zhang commented Nov 7, 2024

Opened for testing. Based on guidance this is currently the first step: create new v1 API, gate remains off, v1 API is excluded from the image manifests

Also adds in: #2089

Copy link
Contributor

openshift-ci bot commented Nov 7, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

openshift-ci bot commented Nov 7, 2024

Hello @yuqi-zhang! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 7, 2024
Copy link
Contributor

openshift-ci bot commented Nov 7, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yuqi-zhang
Once this PR has been reviewed and has the lgtm label, please assign sjenning for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@yuqi-zhang
Copy link
Contributor Author

/test all

@yuqi-zhang
Copy link
Contributor Author

/test all

First step to GA'ing the currently v1alpha1 APIs. Don't add to payload
manifests yet, and the featuregate is retained.
@yuqi-zhang yuqi-zhang marked this pull request as ready for review November 8, 2024 22:26
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 8, 2024
@yuqi-zhang yuqi-zhang changed the title Promote onclusterbuild to GA MCO-1443: Promote onclusterbuild to GA Nov 8, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 8, 2024

@yuqi-zhang: This pull request references MCO-1443 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.18.0" version, but no target version was set.

In response to this:

Opened for testing. Based on guidance this is currently the first step: create new v1 API, gate remains off, v1 API is excluded from the image manifests

Also adds in: #2089

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 8, 2024
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Can we take this promotion opportunity to go through the API thoroughly and improve validations and godocs please

@@ -0,0 +1,64 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[TechPreview] MachineOSBuild"
Copy link
Contributor

Choose a reason for hiding this comment

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

No longer tech preview? I know it kind of is, but, we aren't likely to remember to update this when we update the gate, so this will become disjoint

@@ -0,0 +1,134 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[TechPreview] MachineOSConfig"
Copy link
Contributor

Choose a reason for hiding this comment

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

No longer TP

// version tracks the newest MachineOSBuild for each MachineOSConfig
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Required
Version int64 `json:"version"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not following how this interoperates, in particular, with ConfigGeneration? Can you remind me?

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 think the original intent was that they track a corresponding MachineOSConfig generation to do rebuilds, but in techpreview the implementation hasn't leveraged either field (hard set to 1). Let me check that and get back to you.

// host[:port][/namespace]/name:<tag> or svc_name.namespace.svc[:port]/repository/name:<tag>
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=447
// +kubebuilder:validation:XValidation:rule=`((self.split(':').size() == 2 && self.split(':')[1].matches('^([a-zA-Z0-9-./:])+$')) || self.matches('^[^.]+\\.[^.]+\\.svc:\\d+\\/[^\\/]+\\/[^\\/]+:[^\\/]+$'))`,message="the OCI Image reference must end with a valid :<tag>, where '<digest>' is 64 characters long and '<tag>' is any valid string Or it must be a valid .svc followed by a port, repository, image name, and tag."
Copy link
Contributor

Choose a reason for hiding this comment

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

The message here references digest, but it's not in the example?

// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
// ImageBuilderType describes the image builder set in the MachineOSConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Godoc for this field is wrong, it's talking about a different field name?

// +kubebuilder:default:=noarch
// +optional
ContainerfileArch ContainerfileArch `json:"containerfileArch"`
// content is the custom content to be built
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this? Can we expand this documentation?


type MachineOSImageBuilder struct {
// imageBuilderType specifies the backend to be used to build the image.
// +kubebuilder:default:=PodImageBuilder
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we want this defaulted? What if we need to change this in the future as we decide there's a better, default image build method that doesn't rely on today's pod based image builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it difficult to change the default here in the API if we wanted to change it in the future?

// +kubebuilder:validation:XValidation:rule=`((self.split(':').size() == 2 && self.split(':')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$')) || self.matches('^[^.]+\\.[^.]+\\.svc:\\d+\\/[^\\/]+\\/[^\\/]+:[^\\/]+$'))`,message="the OCI Image name should follow the host[:port][/namespace]/name format, resembling a valid URL without the scheme. Or it must be a valid .svc followed by a port, repository, image name, and tag."
// +kubebuilder:validation:Required
RenderedImagePushspec string `json:"renderedImagePushspec"`
// releaseVersion is associated with the base OS Image. This is the version of Openshift that the Base Image is associated with.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line almost says the same thing twice, perhaps this should consolidate into one?

@yuqi-zhang yuqi-zhang force-pushed the promote-onclusterbuild branch 3 times, most recently from 60085e1 to 416f317 Compare November 15, 2024 02:16
@yuqi-zhang
Copy link
Contributor Author

Updated based on comments:
- Removed Version and ConfigGeneration from MOSB as they were unused
- Updated relatedobjects list
- Changed all optional,omitempty structs to pointers
- Removed default for ImageBuilderType, but keeping default build arch
to noarch as we don’t foresee changing that.
- Fixed RenderedImagePushspec validators to match description

Also temporarily reverted using format.dns1123subdomain() library while figuring out how it works

@yuqi-zhang yuqi-zhang force-pushed the promote-onclusterbuild branch 2 times, most recently from a663367 to 8f72efb Compare November 15, 2024 06:31
Mostly fixups, with some minor changes to the v1alpha1 API:

 - Removed Version and ConfigGeneration from MOSB as they were unused
 - Updated relatedobjects list
 - Changed all optional,omitempty structs to pointers
 - Removed default for ImageBuilderType, but keeping default build arch
   to noarch as we don’t foresee changing that.
 - Fixed RenderedImagePushspec validators to match description
@yuqi-zhang
Copy link
Contributor Author

/test e2e-aws-serial-techpreview

// describes that the machine-os-builder will use a custom pod builder that uses buildah
PodBuilder MachineOSImageBuilderType = "PodImageBuilder"
// describes that the machine-os-builder will use a Job to spin up a custom pod builder that uses buildah
PodBuilder MachineOSImageBuilderType = "JobImageBuilder"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be renamed to JobBuilder as well?

// +unionMember
// +optional
PodImageBuilder *ObjectReference `json:"buildPod,omitempty"`
JobImageBuilderStatus *ObjectReference `json:"jobImageBuilderStatus,omitempty"`
Copy link
Member

@cheesesashimi cheesesashimi Nov 19, 2024

Choose a reason for hiding this comment

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

I'm not sure that BuilderStatus makes sense here because this is mostly just a reference to the build executor which doesn't include any kind of status message (to my knowledge). Maybe something like JobImageBuilderRef or something like that would be more appropriate? Better yet, this could just be ImageBuilderRef. That, coupled with the value in ImageBuilderType, should be enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the comment above this field might need an update to reflect that it is a reference as well.

Stepping back a bit, I'm guessing the reason we are using a union here is we could have different builders, and they could need different types(other than ObjectReference) to represent their reference? If we are always going to use ObjectReference for multiple kind of builders, then maybe we don't even need to have to a union discriminator? It could be just two fields within this struct as Zack suggested: type and ref.

Copy link
Member

Choose a reason for hiding this comment

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

Those values are arguably common to all image builders. There could be some additional information that may be desired specific to each type of image builder, but we can add that onto this later as a specific type.

Copy link
Member

Choose a reason for hiding this comment

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

And taking a step back from this, if the ObjectReference includes GVK (Group Version Kind) information, we could potentially eliminate the ImageBuilderType field here since I see that as being primarily user-facing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so instead of having individual ImageBuilderRef's, I'll just make it one optional field here to encompass all potential object references.

@yuqi-zhang yuqi-zhang force-pushed the promote-onclusterbuild branch 3 times, most recently from 7597202 to ddb8b4e Compare November 19, 2024 17:50
}

// ObjectReference contains enough information to let you inspect or modify the referred object.
type ObjectReference struct {
Copy link
Member

Choose a reason for hiding this comment

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

Should we also include a UID field here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add one, the corev1 default does have it, but some of the locally defined types do not. Do you see a need for the UID in the status? I thought this was mostly so a user can cross-reference the object from here, and if they need more information, they can look directly at the referenced object (Job)

Copy link
Member

Choose a reason for hiding this comment

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

After some offline discussion about the use-case I had in mind, I don't think we need the UID after all.

// +kubebuilder:validation:XValidation:rule=`(self.split('@').size() == 2 && self.split('@')[1].matches('^sha256:[a-f0-9]{64}$'))`,message="the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
// +kubebuilder:validation:XValidation:rule=`(self.split('@')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$'))`,message="the OCI Image name should follow the host[:port][/namespace]/name format, resembling a valid URL without the scheme"
// +optional
CurrentImagePullspec string `json:"currentImagePullspec,omitempty"`
Copy link
Member

@cheesesashimi cheesesashimi Nov 20, 2024

Choose a reason for hiding this comment

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

I feel like it might be useful to have a reference to the currently active MachineOSBuild here. While it is possible to get the currently active MachineOSBuild just from the current image pullspec, doing so is a bit cumbersome; especially if one is an end-user. In practice, I've been using an annotation for this right now, but having a field on the status object would be more intuitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added 👍

Update from PodImageBuilder to JobImageBuilder, and add a MachineOSBuild
reference to MachineOSConfig.

This matches MCO changes, and add more description around the fields.
Copy link
Contributor

openshift-ci bot commented Nov 21, 2024

@yuqi-zhang: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn 44656cf link false /test okd-scos-e2e-aws-ovn

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants