mirror of
https://github.com/containers/podman.git
synced 2025-06-20 00:51:16 +08:00
@ -346,34 +346,26 @@ func playKube(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readerFromArg(fileName string) (*bytes.Reader, error) {
|
func readerFromArg(fileName string) (*bytes.Reader, error) {
|
||||||
errURL := parse.ValidURL(fileName)
|
var reader io.Reader
|
||||||
if fileName == "-" { // Read from stdin
|
switch {
|
||||||
data, err := io.ReadAll(os.Stdin)
|
case fileName == "-": // Read from stdin
|
||||||
if err != nil {
|
reader = os.Stdin
|
||||||
return nil, err
|
case parse.ValidURL(fileName) == nil:
|
||||||
}
|
|
||||||
return bytes.NewReader(data), nil
|
|
||||||
}
|
|
||||||
if errURL == nil {
|
|
||||||
response, err := http.Get(fileName)
|
response, err := http.Get(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
reader = response.Body
|
||||||
data, err := io.ReadAll(response.Body)
|
default:
|
||||||
|
f, err := os.Open(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return bytes.NewReader(data), nil
|
defer f.Close()
|
||||||
|
reader = f
|
||||||
}
|
}
|
||||||
f, err := os.Open(fileName)
|
data, err := io.ReadAll(reader)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
data, err := io.ReadAll(f)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1848,9 +1848,10 @@ func (c *Container) cleanupStorage() error {
|
|||||||
if c.valid {
|
if c.valid {
|
||||||
if err := c.save(); err != nil {
|
if err := c.save(); err != nil {
|
||||||
if cleanupErr != nil {
|
if cleanupErr != nil {
|
||||||
logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr)
|
logrus.Errorf("Unmounting container %s: %v", c.ID(), err)
|
||||||
|
} else {
|
||||||
|
cleanupErr = err
|
||||||
}
|
}
|
||||||
cleanupErr = err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1861,29 +1862,38 @@ func (c *Container) cleanupStorage() error {
|
|||||||
if err := overlay.Unmount(overlayBasePath); err != nil {
|
if err := overlay.Unmount(overlayBasePath); err != nil {
|
||||||
if cleanupErr != nil {
|
if cleanupErr != nil {
|
||||||
logrus.Errorf("Failed to clean up overlay mounts for %s: %v", c.ID(), err)
|
logrus.Errorf("Failed to clean up overlay mounts for %s: %v", c.ID(), err)
|
||||||
|
} else {
|
||||||
|
cleanupErr = fmt.Errorf("failed to clean up overlay mounts for %s: %w", c.ID(), err)
|
||||||
}
|
}
|
||||||
cleanupErr = err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.config.RootfsMapping != nil {
|
if c.config.RootfsMapping != nil {
|
||||||
if err := unix.Unmount(c.config.Rootfs, 0); err != nil {
|
if err := unix.Unmount(c.config.Rootfs, 0); err != nil && err != unix.EINVAL {
|
||||||
logrus.Errorf("Unmounting idmapped rootfs for container %s after mount error: %v", c.ID(), err)
|
if cleanupErr != nil {
|
||||||
|
logrus.Errorf("Unmounting idmapped rootfs for container %s after mount error: %v", c.ID(), err)
|
||||||
|
} else {
|
||||||
|
cleanupErr = fmt.Errorf("unmounting idmapped rootfs for container %s after mount error: %w", c.ID(), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, containerMount := range c.config.Mounts {
|
for _, containerMount := range c.config.Mounts {
|
||||||
if err := c.unmountSHM(containerMount); err != nil {
|
if err := c.unmountSHM(containerMount); err != nil {
|
||||||
if cleanupErr != nil {
|
if cleanupErr != nil {
|
||||||
logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr)
|
logrus.Errorf("Unmounting container %s: %v", c.ID(), err)
|
||||||
|
} else {
|
||||||
|
cleanupErr = fmt.Errorf("unmounting container %s: %w", c.ID(), err)
|
||||||
}
|
}
|
||||||
cleanupErr = err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.cleanupOverlayMounts(); err != nil {
|
if err := c.cleanupOverlayMounts(); err != nil {
|
||||||
// If the container can't remove content report the error
|
// If the container can't remove content report the error
|
||||||
logrus.Errorf("Failed to clean up overlay mounts for %s: %v", c.ID(), err)
|
if cleanupErr != nil {
|
||||||
cleanupErr = err
|
logrus.Errorf("Failed to clean up overlay mounts for %s: %v", c.ID(), err)
|
||||||
|
} else {
|
||||||
|
cleanupErr = fmt.Errorf("failed to clean up overlay mounts for %s: %w", c.ID(), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.config.Rootfs != "" {
|
if c.config.Rootfs != "" {
|
||||||
@ -1901,8 +1911,9 @@ func (c *Container) cleanupStorage() error {
|
|||||||
} else {
|
} else {
|
||||||
if cleanupErr != nil {
|
if cleanupErr != nil {
|
||||||
logrus.Errorf("Cleaning up container %s storage: %v", c.ID(), cleanupErr)
|
logrus.Errorf("Cleaning up container %s storage: %v", c.ID(), cleanupErr)
|
||||||
|
} else {
|
||||||
|
cleanupErr = fmt.Errorf("cleaning up container %s storage: %w", c.ID(), cleanupErr)
|
||||||
}
|
}
|
||||||
cleanupErr = err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1911,9 +1922,10 @@ func (c *Container) cleanupStorage() error {
|
|||||||
vol, err := c.runtime.state.Volume(v.Name)
|
vol, err := c.runtime.state.Volume(v.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cleanupErr != nil {
|
if cleanupErr != nil {
|
||||||
logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr)
|
logrus.Errorf("Retrieving named volume %s for container %s: %v", v.Name, c.ID(), err)
|
||||||
|
} else {
|
||||||
|
cleanupErr = fmt.Errorf("retrieving named volume %s for container %s: %w", v.Name, c.ID(), err)
|
||||||
}
|
}
|
||||||
cleanupErr = fmt.Errorf("retrieving named volume %s for container %s: %w", v.Name, c.ID(), err)
|
|
||||||
|
|
||||||
// We need to try and unmount every volume, so continue
|
// We need to try and unmount every volume, so continue
|
||||||
// if they fail.
|
// if they fail.
|
||||||
@ -1924,9 +1936,10 @@ func (c *Container) cleanupStorage() error {
|
|||||||
vol.lock.Lock()
|
vol.lock.Lock()
|
||||||
if err := vol.unmount(false); err != nil {
|
if err := vol.unmount(false); err != nil {
|
||||||
if cleanupErr != nil {
|
if cleanupErr != nil {
|
||||||
logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr)
|
logrus.Errorf("Unmounting volume %s for container %s: %v", vol.Name(), c.ID(), err)
|
||||||
|
} else {
|
||||||
|
cleanupErr = fmt.Errorf("unmounting volume %s for container %s: %w", vol.Name(), c.ID(), err)
|
||||||
}
|
}
|
||||||
cleanupErr = fmt.Errorf("unmounting volume %s for container %s: %w", vol.Name(), c.ID(), err)
|
|
||||||
}
|
}
|
||||||
vol.lock.Unlock()
|
vol.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ function teardown() {
|
|||||||
basic_teardown
|
basic_teardown
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "podman systerm service <bad_scheme_uri> returns error" {
|
@test "podman system service <bad_scheme_uri> returns error" {
|
||||||
skip_if_remote "podman system service unavailable over remote"
|
skip_if_remote "podman system service unavailable over remote"
|
||||||
run_podman 125 system service localhost:9292
|
run_podman 125 system service localhost:9292
|
||||||
is "$output" "Error: API Service endpoint scheme \"localhost\" is not supported. Try tcp://localhost:9292 or unix:/localhost:9292"
|
is "$output" "Error: API Service endpoint scheme \"localhost\" is not supported. Try tcp://localhost:9292 or unix:/localhost:9292"
|
||||||
|
@ -480,8 +480,7 @@ _EOF
|
|||||||
is "$output" ".*Error: inspecting object: no such object: \"test_pod-test\""
|
is "$output" ".*Error: inspecting object: no such object: \"test_pod-test\""
|
||||||
|
|
||||||
run_podman pod rm -a -f
|
run_podman pod rm -a -f
|
||||||
run_podman rm -a -f
|
run_podman rm -a -f -t0
|
||||||
run_podman rm -f -t0 myyaml
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "podman play with init container" {
|
@test "podman play with init container" {
|
||||||
|
Reference in New Issue
Block a user