mirror of
https://github.com/containers/podman.git
synced 2026-02-05 06:45:31 +01:00
artifact: Skip AddLocal optimization on WSL
The local API path optimization is ineffective on WSL because of NTFS mounting overhead. Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
@@ -237,22 +237,34 @@ func CheckIfImageBuildPathsOnRunningMachine(ctx context.Context, containerFiles
|
||||
return translatedContainerFiles, options, true
|
||||
}
|
||||
|
||||
// IsHyperVProvider checks if the current machine provider is Hyper-V.
|
||||
// It returns true if the provider is Hyper-V, false otherwise, or an error if the check fails.
|
||||
func IsHyperVProvider(ctx context.Context) (bool, error) {
|
||||
func getVmProviderType(ctx context.Context) (define.VMType, error) {
|
||||
conn, err := bindings.GetClient(ctx)
|
||||
if err != nil {
|
||||
logrus.Debugf("Failed to get client connection: %v", err)
|
||||
return false, err
|
||||
return define.UnknownVirt, err
|
||||
}
|
||||
|
||||
_, vmProvider, err := FindMachineByPort(conn.URI.String(), conn.URI)
|
||||
if err != nil {
|
||||
logrus.Debugf("Failed to get machine hypervisor type: %v", err)
|
||||
return false, err
|
||||
return define.UnknownVirt, err
|
||||
}
|
||||
|
||||
return vmProvider.VMType() == define.HyperVVirt, nil
|
||||
return vmProvider.VMType(), nil
|
||||
}
|
||||
|
||||
// IsHyperVProvider checks if the current machine provider is Hyper-V.
|
||||
// It returns true if the provider is Hyper-V, false otherwise, or an error if the check fails.
|
||||
func IsHyperVProvider(ctx context.Context) (bool, error) {
|
||||
providerType, err := getVmProviderType(ctx)
|
||||
return providerType == define.HyperVVirt, err
|
||||
}
|
||||
|
||||
// IsWSLProvider checks if the current machine provider is WSL.
|
||||
// It returns true if the provider is WSL, false otherwise, or an error if the check fails.
|
||||
func IsWSLProvider(ctx context.Context) (bool, error) {
|
||||
providerType, err := getVmProviderType(ctx)
|
||||
return providerType == define.WSLVirt, err
|
||||
}
|
||||
|
||||
// ValidatePathForLocalAPI checks if the provided path satisfies requirements for local API usage.
|
||||
|
||||
@@ -24,6 +24,11 @@ func IsHyperVProvider(ctx context.Context) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func IsWSLProvider(ctx context.Context) (bool, error) {
|
||||
logrus.Debug("IsWSLProvider is not supported")
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func ValidatePathForLocalAPI(path string) error {
|
||||
logrus.Debug("ValidatePathForLocalAPI is not supported")
|
||||
return nil
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/containers/podman/v6/pkg/bindings/artifacts"
|
||||
"github.com/containers/podman/v6/pkg/domain/entities"
|
||||
"github.com/containers/podman/v6/pkg/errorhandling"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.podman.io/image/v5/types"
|
||||
)
|
||||
|
||||
@@ -107,21 +108,26 @@ func (ir *ImageEngine) ArtifactAdd(_ context.Context, name string, artifactBlob
|
||||
options.WithAppend(true)
|
||||
}
|
||||
|
||||
var err error
|
||||
if localMap, ok := localapi.CheckPathOnRunningMachine(ir.ClientCtx, blob.BlobFilePath); ok {
|
||||
artifactAddReport, err = artifacts.AddLocal(ir.ClientCtx, name, blob.FileName, localMap.RemotePath, &options)
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
var errModel *errorhandling.ErrorModel
|
||||
if errors.As(err, &errModel) {
|
||||
switch errModel.ResponseCode {
|
||||
case http.StatusNotFound, http.StatusMethodNotAllowed:
|
||||
default:
|
||||
isWSL, err := localapi.IsWSLProvider(ir.ClientCtx)
|
||||
if err != nil {
|
||||
logrus.Debugf("IsWSLProvider check failed: %v", err)
|
||||
}
|
||||
if !isWSL {
|
||||
if localMap, ok := localapi.CheckPathOnRunningMachine(ir.ClientCtx, blob.BlobFilePath); ok {
|
||||
artifactAddReport, err = artifacts.AddLocal(ir.ClientCtx, name, blob.FileName, localMap.RemotePath, &options)
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
var errModel *errorhandling.ErrorModel
|
||||
if errors.As(err, &errModel) {
|
||||
switch errModel.ResponseCode {
|
||||
case http.StatusNotFound, http.StatusMethodNotAllowed:
|
||||
default:
|
||||
return nil, artifactAddErrorCleanup(ir.ClientCtx, i, name, err)
|
||||
}
|
||||
} else {
|
||||
return nil, artifactAddErrorCleanup(ir.ClientCtx, i, name, err)
|
||||
}
|
||||
} else {
|
||||
return nil, artifactAddErrorCleanup(ir.ClientCtx, i, name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user