mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
Merge pull request #17420 from vrothberg/fix-kube-start
kube play: do not teardown unconditionally on error
This commit is contained in:
@ -279,14 +279,19 @@ func play(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if err := kubeplay(reader); err != nil {
|
||||
// FIXME: The cleanup logic below must be fixed to only remove
|
||||
// resources that were created before a failure. Otherwise,
|
||||
// rerunning the same YAML file will cause an error and remove
|
||||
// the previously created workload.
|
||||
//
|
||||
// teardown any containers, pods, and volumes that might have created before we hit the error
|
||||
teardownReader, trErr := readerFromArg(args[0])
|
||||
if trErr != nil {
|
||||
return trErr
|
||||
}
|
||||
if tErr := teardown(teardownReader, entities.PlayKubeDownOptions{Force: true}, true); tErr != nil && !errorhandling.Contains(tErr, define.ErrNoSuchPod) {
|
||||
return fmt.Errorf("error tearing down workloads %q after kube play error %q", tErr, err)
|
||||
}
|
||||
// teardownReader, trErr := readerFromArg(args[0])
|
||||
// if trErr != nil {
|
||||
// return trErr
|
||||
// }
|
||||
// if tErr := teardown(teardownReader, entities.PlayKubeDownOptions{Force: true}, true); tErr != nil && !errorhandling.Contains(tErr, define.ErrNoSuchPod) {
|
||||
// return fmt.Errorf("error tearing down workloads %q after kube play error %q", tErr, err)
|
||||
// }
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,12 @@ RELABEL="system_u:object_r:container_file_t:s0"
|
||||
is "$output" "${RELABEL} $TESTDIR" "selinux relabel should have happened"
|
||||
fi
|
||||
|
||||
# Now rerun twice to make sure nothing gets removed
|
||||
run_podman 125 play kube $PODMAN_TMPDIR/test.yaml
|
||||
is "$output" ".* is in use: pod already exists"
|
||||
run_podman 125 play kube $PODMAN_TMPDIR/test.yaml
|
||||
is "$output" ".* is in use: pod already exists"
|
||||
|
||||
run_podman stop -a -t 0
|
||||
run_podman pod rm -t 0 -f test_pod
|
||||
}
|
||||
|
Reference in New Issue
Block a user