-
Notifications
You must be signed in to change notification settings - Fork 465
MCO-1131: Merge implementation machineOSBuild and machineOSConfig in MCO #4327
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f58b593
ocb-api
cdoern c894999
further cleanup
inesqyx 084a4e3
Test fixes for the new OCB API
umohnani8 1da14cc
Build controller test fixes for the new OCB API
inesqyx 17e78c7
adds Red Hat entitlement functionality for on-cluster layering
cheesesashimi e8e945c
Final cleanup
inesqyx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package apihelpers | ||
|
|
||
| import ( | ||
| mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // NewMachineOSBuildCondition creates a new MachineOSBuild condition. | ||
| func NewMachineOSBuildCondition(condType string, status metav1.ConditionStatus, reason, message string) *metav1.Condition { | ||
| return &metav1.Condition{ | ||
| Type: condType, | ||
| Status: status, | ||
| LastTransitionTime: metav1.Now(), | ||
| Reason: reason, | ||
| Message: message, | ||
| } | ||
| } | ||
|
|
||
| func GetMachineOSBuildCondition(status mcfgv1alpha1.MachineOSBuildStatus, condType mcfgv1alpha1.BuildProgress) *metav1.Condition { | ||
| // in case of sync errors, return the last condition that matches, not the first | ||
| // this exists for redundancy and potential race conditions. | ||
| var LatestState *metav1.Condition | ||
| for i := range status.Conditions { | ||
| c := status.Conditions[i] | ||
| if mcfgv1alpha1.BuildProgress(c.Type) == condType { | ||
| LatestState = &c | ||
| } | ||
| } | ||
| return LatestState | ||
| } | ||
|
|
||
| // SetMachineOSBuildCondition updates the MachineOSBuild to include the provided condition. If the condition that | ||
| // we are about to add already exists and has the same status and reason then we are not going to update. | ||
| func SetMachineOSBuildCondition(status *mcfgv1alpha1.MachineOSBuildStatus, condition metav1.Condition) { | ||
| currentCond := GetMachineOSBuildCondition(*status, mcfgv1alpha1.BuildProgress(condition.Type)) | ||
| if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason && currentCond.Message == condition.Message { | ||
| return | ||
| } | ||
| // Do not update lastTransitionTime if the status of the condition doesn't change. | ||
| if currentCond != nil && currentCond.Status == condition.Status { | ||
| condition.LastTransitionTime = currentCond.LastTransitionTime | ||
| } | ||
|
|
||
| // this may not be necessary | ||
| newConditions := filterOutMachineOSBuildCondition(status.Conditions, mcfgv1alpha1.BuildProgress(condition.Type)) | ||
| status.Conditions = append(newConditions, condition) | ||
| } | ||
|
|
||
| // RemoveMachineOSBuildCondition removes the MachineOSBuild condition with the provided type. | ||
| func RemoveMachineOSBuildCondition(status *mcfgv1alpha1.MachineOSBuildStatus, condType mcfgv1alpha1.BuildProgress) { | ||
| status.Conditions = filterOutMachineOSBuildCondition(status.Conditions, condType) | ||
| } | ||
|
|
||
| // filterOutMachineOSBuildCondition returns a new slice of MachineOSBuild conditions without conditions with the provided type. | ||
| func filterOutMachineOSBuildCondition(conditions []metav1.Condition, condType mcfgv1alpha1.BuildProgress) []metav1.Condition { | ||
| var newConditions []metav1.Condition | ||
| for _, c := range conditions { | ||
| if mcfgv1alpha1.BuildProgress(c.Type) == condType { | ||
| continue | ||
| } | ||
| newConditions = append(newConditions, c) | ||
| } | ||
| return newConditions | ||
| } | ||
|
|
||
| func IsMachineOSBuildConditionTrue(conditions []metav1.Condition, conditionType mcfgv1alpha1.BuildProgress) bool { | ||
| return IsMachineOSBuildConditionPresentAndEqual(conditions, conditionType, metav1.ConditionTrue) | ||
| } | ||
|
|
||
| // IsMachineOSBuildConditionPresentAndEqual returns true when conditionType is present and equal to status. | ||
| func IsMachineOSBuildConditionPresentAndEqual(conditions []metav1.Condition, conditionType mcfgv1alpha1.BuildProgress, status metav1.ConditionStatus) bool { | ||
| for _, condition := range conditions { | ||
| if mcfgv1alpha1.BuildProgress(condition.Type) == conditionType { | ||
| return condition.Status == status | ||
| } | ||
| } | ||
| return false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,22 +5,22 @@ | |
| # Decode and extract the MachineConfig from the gzipped ConfigMap and move it | ||
inesqyx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # into position. We do this in a separate stage so that we don't have the | ||
| # gzipped MachineConfig laying around. | ||
| FROM {{.BaseImage.Pullspec}} AS extract | ||
| FROM {{.MachineOSConfig.Spec.BuildInputs.BaseOSImagePullspec}} AS extract | ||
| COPY ./machineconfig/machineconfig.json.gz /tmp/machineconfig.json.gz | ||
| RUN mkdir -p /etc/machine-config-daemon && \ | ||
| cat /tmp/machineconfig.json.gz | base64 -d | gunzip - > /etc/machine-config-daemon/currentconfig | ||
|
|
||
| {{if .ExtensionsImage.Pullspec}} | ||
| {{if .MachineOSConfig.Spec.BuildInputs.BaseOSExtensionsImagePullspec}} | ||
| # Pull our extensions image. Not sure yet what / how this should be wired up | ||
| # though. Ideally, I'd like to use some Buildah tricks to have the extensions | ||
| # directory mounted into the container at build-time so that I don't have to | ||
| # copy the RPMs into the container, configure the repo, and do the | ||
| # installation. Alternatively, I'd have to start a pod with an HTTP server. | ||
| FROM {{.ExtensionsImage.Pullspec}} AS extensions | ||
| FROM {{.MachineOSConfig.Spec.BuildInputs.BaseOSExtensionsImagePullspec}} AS extensions | ||
| {{end}} | ||
|
|
||
|
|
||
| FROM {{.BaseImage.Pullspec}} AS configs | ||
| FROM {{.MachineOSConfig.Spec.BuildInputs.BaseOSImagePullspec}} AS configs | ||
| # Copy the extracted MachineConfig into the expected place in the image. | ||
| COPY --from=extract /etc/machine-config-daemon/currentconfig /etc/machine-config-daemon/currentconfig | ||
| # Do the ignition live-apply, extracting the Ignition config from the MachineConfig. | ||
|
|
@@ -29,11 +29,11 @@ COPY --from=extract /etc/machine-config-daemon/currentconfig /etc/machine-config | |
| RUN container="oci" exec -a ignition-apply /usr/lib/dracut/modules.d/30ignition/ignition --ignore-unsupported <(cat /etc/machine-config-daemon/currentconfig | jq '.spec.config') && \ | ||
| ostree container commit | ||
|
|
||
| LABEL machineconfig={{.Pool.Spec.Configuration.Name}} | ||
| LABEL machineconfigpool={{.Pool.Name}} | ||
| LABEL releaseversion={{.ReleaseVersion}} | ||
| LABEL baseOSContainerImage={{.BaseImage.Pullspec}} | ||
| LABEL machineconfig={{.MachineOSBuild.Spec.DesiredConfig.Name}} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought (non-blocking): Buildah can accept additional labels via a CLI argument which could make some of this unnecessary which might help shrink the overall size of the struct. |
||
| LABEL machineconfigpool={{.MachineOSConfig.Spec.MachineConfigPool.Name}} | ||
| LABEL releaseversion={{.MachineOSConfig.Spec.BuildInputs.ReleaseVersion}} | ||
| LABEL baseOSContainerImage={{.MachineOSConfig.Spec.BuildInputs.BaseOSImagePullspec}} | ||
|
|
||
| {{if .CustomDockerfile}} | ||
| {{.CustomDockerfile}} | ||
| {{if .Containerfile}} | ||
| {{.Containerfile}} | ||
| {{end}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.