BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
thesasuser
Lapis Lazuli | Level 10

Hello
I see a large number of jobs for example sas-update-checker, sas-deployment-operator-reconcile ,sas-backu-job etc listed when I check for completed jobs using kubectl.
Can these completed jobs be deleted?
I always delete any adhoc start / stop jobs I create.

1 ACCEPTED SOLUTION

Accepted Solutions
gwootton
SAS Super FREQ

You can delete them, or for cronjobs you could change the configuration such that less history is retained.

 

CronJobs have a configurable successfulJobHistoryLimit and failedJobHistoryLimit.

 

https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits

 

The default values are successful: 3 and failed: 1, but some of these the Viya deployment modifies, like for backups.

 

You can run this command to see which cronjobs are active and their JobHistoryLimit settings:

 

 

kubectl -n namespace get cronjob -o custom-columns=Name:.metadata.name,Suspended:.spec.suspend,SuccessLimit:.spec.successfulJobsHistoryLimit,FailLimit:.spec.failedJobsHistoryLimit

 

Here's the output from my environment:

Name                                       Suspended   SuccessLimit   FailLimit
sas-backup-purge-job                       false       7              7
sas-backup-pv-copy-cleanup-job             true        100            1
sas-crunchy-platform-postgres-repo1-full   false       3              1
sas-crunchy-platform-postgres-repo1-incr   false       3              1
sas-import-data-loader                     false       3              1
sas-inventory-collector                    true        3              1
sas-pyconfig                               true        3              1
sas-restore-job                            true        100            1
sas-scheduled-backup-all-sources           true        100            100
sas-scheduled-backup-incr-job              true        100            100
sas-scheduled-backup-job                   false       100            100
sas-start-all                              false       3              1
sas-stop-all                               false       3              1
sas-studio-steps                           true        3              1
sas-update-checker                         false       3              1

To change this configuration and have it persist through updates you could use a patch transformer like this:

apiVersion: builtin
kind: PatchTransformer
metadata:
  name: sas-backup-jobs-change-history-retention
patch: |-
  - op: replace
    path: /spec/successfulJobsHistoryLimit
    value: "10"
  - op: replace
    path: /spec/failedJobsHistoryLimit
    value: "10"
target:
  kind: CronJob
  annotationSelector: sas.com/component-name=sas-backup-job
  version: v1

 

--
Greg Wootton | Principal Systems Technical Support Engineer

View solution in original post

4 REPLIES 4
doug_sas
SAS Employee

I use

kc [-n <namespace>] delete jobs --field-selector='status.successful=1'
gwootton
SAS Super FREQ

You can delete them, or for cronjobs you could change the configuration such that less history is retained.

 

CronJobs have a configurable successfulJobHistoryLimit and failedJobHistoryLimit.

 

https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits

 

The default values are successful: 3 and failed: 1, but some of these the Viya deployment modifies, like for backups.

 

You can run this command to see which cronjobs are active and their JobHistoryLimit settings:

 

 

kubectl -n namespace get cronjob -o custom-columns=Name:.metadata.name,Suspended:.spec.suspend,SuccessLimit:.spec.successfulJobsHistoryLimit,FailLimit:.spec.failedJobsHistoryLimit

 

Here's the output from my environment:

Name                                       Suspended   SuccessLimit   FailLimit
sas-backup-purge-job                       false       7              7
sas-backup-pv-copy-cleanup-job             true        100            1
sas-crunchy-platform-postgres-repo1-full   false       3              1
sas-crunchy-platform-postgres-repo1-incr   false       3              1
sas-import-data-loader                     false       3              1
sas-inventory-collector                    true        3              1
sas-pyconfig                               true        3              1
sas-restore-job                            true        100            1
sas-scheduled-backup-all-sources           true        100            100
sas-scheduled-backup-incr-job              true        100            100
sas-scheduled-backup-job                   false       100            100
sas-start-all                              false       3              1
sas-stop-all                               false       3              1
sas-studio-steps                           true        3              1
sas-update-checker                         false       3              1

To change this configuration and have it persist through updates you could use a patch transformer like this:

apiVersion: builtin
kind: PatchTransformer
metadata:
  name: sas-backup-jobs-change-history-retention
patch: |-
  - op: replace
    path: /spec/successfulJobsHistoryLimit
    value: "10"
  - op: replace
    path: /spec/failedJobsHistoryLimit
    value: "10"
target:
  kind: CronJob
  annotationSelector: sas.com/component-name=sas-backup-job
  version: v1

 

--
Greg Wootton | Principal Systems Technical Support Engineer
thesasuser
Lapis Lazuli | Level 10

In my deployments., looks like the limits are not set.
Do I need to add the patch transformer to kustomization.yaml?

gwootton
SAS Super FREQ
How are you determining the limit is not set? Typically if it's not being set explicitly when we create the cronjob it would return the defaults of 3 for successful and 1 for failed jobs (see my output of the command).
--
Greg Wootton | Principal Systems Technical Support Engineer

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 310 views
  • 1 like
  • 3 in conversation