From d9b2da1eab44f523d4a2987212acb9313401a45b Mon Sep 17 00:00:00 2001 From: junqian Date: Mon, 8 Nov 2021 16:57:15 +0800 Subject: [PATCH] retain pods when pod finnish --- doc/tutorial.md | 4 ++++ pkg/apis/tappcontroller/v1/types.go | 4 ++++ pkg/tapp/controller.go | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 4ec3f07..590c764 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -80,6 +80,10 @@ type TAppSpec struct { // other nodes, otherwise it depends on other conditions(e.g. pod restart policy). NeverMigrate bool `json:"neverMigrate,omitempty"` + // RetainFinishedPod indicates whether to delete pod after pod is failed or success. + // Default values is false. + RetainFinishedPod bool `json:"retainFinishedPod,omitempty"` + // volumeClaimTemplates is a list of claims that pods are allowed to reference. // The TApp controller is responsible for mapping network identities to // claims in a way that maintains the identity of a pod. Every claim in diff --git a/pkg/apis/tappcontroller/v1/types.go b/pkg/apis/tappcontroller/v1/types.go index 840878f..178f8c7 100644 --- a/pkg/apis/tappcontroller/v1/types.go +++ b/pkg/apis/tappcontroller/v1/types.go @@ -94,6 +94,10 @@ type TAppSpec struct { // other nodes, otherwise it depends on other conditions(e.g. pod restart policy). NeverMigrate bool `json:"neverMigrate,omitempty"` + // RetainFinishedPod indicates whether to delete pod after pod is failed or success. + // Default values is false. + RetainFinishedPod bool `json:"retainFinishedPod,omitempty"` + // volumeClaimTemplates is a list of claims that pods are allowed to reference. // The TApp controller is responsible for mapping network identities to // claims in a way that maintains the identity of a pod. Every claim in diff --git a/pkg/tapp/controller.go b/pkg/tapp/controller.go index fb25cce..9910e1a 100644 --- a/pkg/tapp/controller.go +++ b/pkg/tapp/controller.go @@ -609,7 +609,7 @@ func getDesiredInstance(tapp *tappv1.TApp) (running, completed sets.String) { } // If `deletePodAfterAppFinish` is not enabled, pod will be deleted once instance finishes. - if !getDeletePodAfterAppFinish() || isTAppFinished(tapp) { + if (!getDeletePodAfterAppFinish() || isTAppFinished(tapp)) && !tapp.Spec.RetainFinishedPod { for id, status := range tapp.Status.Statuses { // Instance finished if status == tappv1.InstanceFailed || status == tappv1.InstanceSucc {