Skip to content

Commit

Permalink
retain pods when pod finnish
Browse files Browse the repository at this point in the history
  • Loading branch information
qianjun1993 committed Nov 8, 2021
1 parent b2799b5 commit d9b2da1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/tappcontroller/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/tapp/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d9b2da1

Please sign in to comment.