Skip to content

Commit f75f676

Browse files
committed
add control for auto delete unused template
1 parent c40d314 commit f75f676

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/apis/tappcontroller/v1/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ type TAppSpec struct {
8484
// Default values is false.
8585
ForceDeletePod bool `json:"forceDeletePod,omitempty"`
8686

87+
// AutoDeleteUnusedTemplate indicates whether auto delete templates when it is unused.
88+
// Default values is false.
89+
AutoDeleteUnusedTemplate bool `json:"autoDeleteUnusedTemplate,omitempty"`
90+
8791
// NeverMigrate indicates whether to migrate pods. If it is true, pods will never be migrated to
8892
// other nodes, otherwise it depends on other conditions(e.g. pod restart policy).
8993
NeverMigrate bool `json:"neverMigrate,omitempty"`

pkg/tapp/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ func (c *Controller) setDefaultValue(tapp *tappv1.TApp) {
491491
}
492492

493493
func (c *Controller) removeUnusedTemplate(tapp *tappv1.TApp) error {
494+
if !tapp.Spec.AutoDeleteUnusedTemplate {
495+
return nil
496+
}
494497
templateMap := make(map[string]bool, len(tapp.Spec.TemplatePool))
495498
for k := range tapp.Spec.TemplatePool {
496499
templateMap[k] = true

0 commit comments

Comments
 (0)