Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit f4d4d33

Browse files
DaishanAlena Prokharchyk
authored andcommitted
Add mount_delete.purge.after.seconds setting
Add mount_delete.purge.after.seconds to control how long a stale secret volume should live in database. Default is 3600 seconds
1 parent 87c57d5 commit f4d4d33

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

code/iaas/model/src/main/java/io/cattle/platform/core/cleanup/TableCleanup.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public class TableCleanup extends AbstractJooqDao implements Task {
118118
public static final DynamicLongProperty EVENT_AGE_LIMIT_SECONDS = ArchaiusUtil.getLong("events.purge.after.seconds");
119119
public static final DynamicLongProperty AUDIT_LOG_AGE_LIMIT_SECONDS = ArchaiusUtil.getLong("audit_log.purge.after.seconds");
120120
public static final DynamicLongProperty SERVICE_LOG_AGE_LIMIT_SECONDS = ArchaiusUtil.getLong("service_log.purge.after.seconds");
121+
public static final DynamicLongProperty MOUNT_DELETE_AGE_LIMIT_SECONDS = ArchaiusUtil.getLong("mount_delete.purge.after.seconds");
121122
public static final String MOUNT_DELETE_QUERY = "delete m " +
122123
" from mount as m " +
123124
" join ( " +
@@ -127,16 +128,16 @@ public class TableCleanup extends AbstractJooqDao implements Task {
127128
" join volume as v on mm.volume_id = v.id " +
128129
" where i.state = 'purged' " +
129130
" and i.removed < ? " +
130-
" and (v.data like '%\"isHostPath\":true%' or v.data like '%\"driver\":\"local\"%')" +
131+
" and (v.data like '%%\"isHostPath\":true%%' or v.data like '%%\"driver\":\"local\"%%')" +
131132
" limit ? " +
132133
" ) mx on m.id = mx.id";
133134
public static final String SECRET_CLEANUP_VSPM_QUERY = "delete s " +
134135
" from volume_storage_pool_map as s " +
135136
" join ( " +
136137
" select vv.id " +
137138
" from volume as vv " +
138-
" where vv.data like '%\\\"driver\\\":\\\"rancher-secrets\\\"%' " +
139-
" and created < date_sub(utc_timestamp(), INTERVAL 1 HOUR) " +
139+
" where vv.data like '%%\\\"driver\\\":\\\"rancher-secrets\\\"%%' " +
140+
" and created < date_sub(utc_timestamp(), INTERVAL %s SECOND) " +
140141
" and vv.state = \"inactive\" " +
141142
" and vv.instance_id is NULL " +
142143
" and id not in(" +
@@ -148,8 +149,8 @@ public class TableCleanup extends AbstractJooqDao implements Task {
148149
" from volume as v " +
149150
" join (" +
150151
" select vv.id from volume as vv " +
151-
" where vv.data like '%\\\"driver\\\":\\\"rancher-secrets\\\"%' " +
152-
" and created < date_sub(utc_timestamp(), INTERVAL 1 HOUR) and " +
152+
" where vv.data like '%%\\\"driver\\\":\\\"rancher-secrets\\\"%%' " +
153+
" and created < date_sub(utc_timestamp(), INTERVAL %s SECOND) and " +
153154
" vv.state = \"inactive\" and " +
154155
" vv.instance_id is NULL and " +
155156
" id not in(" +
@@ -300,7 +301,7 @@ private void cleanupLabelTables(Date cutoff) {
300301

301302
private void cleanupTableByQuery(String query, String tableKind, Date cutoff) {
302303
log.debug("Cleaning up {} table [cutoff={}]", tableKind, cutoff);
303-
Query q = create().query(query, cutoff, QUERY_LIMIT_ROWS.getValue());
304+
Query q = create().query(String.format(query, MOUNT_DELETE_AGE_LIMIT_SECONDS.getValue().toString()), cutoff, QUERY_LIMIT_ROWS.getValue());
304305
int rowsAffected = 0;
305306
int total = 0;
306307

code/packaging/app-config/src/main/resources/META-INF/cattle/core-model/defaults.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ process_instance.purge.after.seconds=3600
3030
audit_log.purge.after.seconds=2592000
3131
# 1 Day
3232
service_log.purge.after.seconds=86400
33+
# 1 Hour
34+
mount_delete.purge.after.seconds=3600

0 commit comments

Comments
 (0)