This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
✨ [Add] Coverage dir for unpack pod #884
Merged
Merged
Changes from all commits
Commits
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 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"fmt" | ||
"io" | ||
"io/fs" | ||
"os" | ||
"strings" | ||
|
||
"github.com/nlepage/go-tarfs" | ||
|
@@ -112,6 +113,12 @@ func (i *Image) getDesiredPodApplyConfig(bundle *rukpakv1alpha2.BundleDeployment | |
// this PSA definition either configurable or workable in a restricted namespace. | ||
// | ||
// See https://github.com/operator-framework/rukpak/pull/539 for more detail. | ||
|
||
// This should ideally be a persistent volume that remains even after the | ||
// pod is re-created. Since unpack image process is about to change to use | ||
// a registry client, and the test coverage procedure is to revisited, creating | ||
// a temp solution that uses an empty dir. | ||
gocoverdirEnv := os.Getenv("GOCOVERDIR") | ||
containerSecurityContext := applyconfigurationcorev1.SecurityContext(). | ||
WithAllowPrivilegeEscalation(false). | ||
WithCapabilities(applyconfigurationcorev1.Capabilities(). | ||
|
@@ -150,17 +157,34 @@ func (i *Image) getDesiredPodApplyConfig(bundle *rukpakv1alpha2.BundleDeployment | |
WithName(imageBundleUnpackContainerName). | ||
WithImage(bundle.Spec.Source.Image.Ref). | ||
WithCommand("/bin/unpack", "--bundle-dir", "/"). | ||
WithVolumeMounts(applyconfigurationcorev1.VolumeMount(). | ||
WithName("util"). | ||
WithMountPath("/bin"), | ||
). | ||
WithVolumeMounts(func() []*applyconfigurationcorev1.VolumeMountApplyConfiguration { | ||
var volumeMounts []*applyconfigurationcorev1.VolumeMountApplyConfiguration | ||
if gocoverdirEnv != "" { | ||
volumeMounts = append(volumeMounts, applyconfigurationcorev1.VolumeMount(). | ||
WithName("test-coverage"). | ||
WithMountPath(gocoverdirEnv)) | ||
} | ||
volumeMounts = append(volumeMounts, applyconfigurationcorev1.VolumeMount(). | ||
WithName("util"). | ||
WithMountPath("/bin")) | ||
return volumeMounts | ||
}()...). | ||
WithEnv(applyconfigurationcorev1.EnvVar().WithName("GOCOVERDIR").WithValue(gocoverdirEnv)). | ||
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. Can we only set this if 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. Passing an empty configuration is causing errors. Tried various options, but looks like the only one is to create the entire container spec separately based on whether env var is present or not. Leaving it to be as is for now, if the env is not set it results in an empty string which doesn't cause a problem for now. Also this is just a band aid, and will replaced by direct registry client anyways. |
||
WithSecurityContext(containerSecurityContext.WithRunAsUser(1001)). | ||
WithTerminationMessagePolicy(corev1.TerminationMessageFallbackToLogsOnError), | ||
). | ||
WithVolumes(applyconfigurationcorev1.Volume(). | ||
WithName("util"). | ||
WithEmptyDir(applyconfigurationcorev1.EmptyDirVolumeSource()), | ||
). | ||
WithVolumes(func() []*applyconfigurationcorev1.VolumeApplyConfiguration { | ||
var volumes []*applyconfigurationcorev1.VolumeApplyConfiguration | ||
if gocoverdirEnv != "" { | ||
volumes = append(volumes, applyconfigurationcorev1.Volume(). | ||
WithName("test-coverage"). | ||
WithEmptyDir(applyconfigurationcorev1.EmptyDirVolumeSource())) | ||
} | ||
volumes = append(volumes, applyconfigurationcorev1.Volume(). | ||
WithName("util"). | ||
WithEmptyDir(applyconfigurationcorev1.EmptyDirVolumeSource())) | ||
return volumes | ||
}()...). | ||
WithSecurityContext(applyconfigurationcorev1.PodSecurityContext(). | ||
WithRunAsNonRoot(true). | ||
WithSeccompProfile(applyconfigurationcorev1.SeccompProfile(). | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A temporary fix to get e2e's running in operator controller!