Skip to content

Commit 3526abc

Browse files
committed
feat: add protection lease concept for time-limited clone protection
Instead of infinite deletion protection, clones now get protected for a configurable period. Key changes: - Add protectionLeaseDurationMinutes config (default: 7 days) - Add protectionRenewalDurationMinutes config (default: 3 days) - Add protectionExpiryWarningMinutes config for warning notifications - Add ProtectedTill field to Clone model with IsProtected() method - Add background job to check lease expiry and send webhook warnings - Add clone_protection_expiring and clone_protection_expired webhooks - Update UI to show lease duration, expiry time, and renew button - Update API to support renewLease parameter for lease renewal
1 parent 583e4dd commit 3526abc

18 files changed

Lines changed: 422 additions & 47 deletions

File tree

engine/api/swagger-spec/dblab_openapi.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,10 @@ components:
16311631
protected:
16321632
type: boolean
16331633
default: false
1634+
protectedTill:
1635+
type: string
1636+
format: date-time
1637+
description: Time when the protection lease expires
16341638
deleteAt:
16351639
type: string
16361640
format: date-time
@@ -1658,6 +1662,14 @@ components:
16581662
maxIdleMinutes:
16591663
type: integer
16601664
format: int64
1665+
protectionLeaseDurationMinutes:
1666+
type: integer
1667+
format: int64
1668+
description: Protection lease duration in minutes
1669+
protectionRenewalDurationMinutes:
1670+
type: integer
1671+
format: int64
1672+
description: Protection renewal duration in minutes
16611673
CreateClone:
16621674
type: object
16631675
properties:
@@ -1703,6 +1715,10 @@ components:
17031715
protected:
17041716
type: boolean
17051717
default: false
1718+
renewLease:
1719+
type: boolean
1720+
default: false
1721+
description: When true, renews the protection lease for the clone
17061722
StartObservationRequest:
17071723
type: object
17081724
properties:

engine/api/swagger-spec/dblab_server_swagger.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,10 @@ components:
10651065
protected:
10661066
type: "boolean"
10671067
default: false
1068+
protectedTill:
1069+
type: "string"
1070+
format: "date-time"
1071+
description: "Time when the protection lease expires"
10681072
deleteAt:
10691073
type: "string"
10701074
format: "date-time"
@@ -1093,6 +1097,14 @@ components:
10931097
maxIdleMinutes:
10941098
type: "integer"
10951099
format: "int64"
1100+
protectionLeaseDurationMinutes:
1101+
type: "integer"
1102+
format: "int64"
1103+
description: "Protection lease duration in minutes"
1104+
protectionRenewalDurationMinutes:
1105+
type: "integer"
1106+
format: "int64"
1107+
description: "Protection renewal duration in minutes"
10961108

10971109
CreateClone:
10981110
type: "object"
@@ -1136,6 +1148,10 @@ components:
11361148
protected:
11371149
type: "boolean"
11381150
default: false
1151+
renewLease:
1152+
type: "boolean"
1153+
default: false
1154+
description: "When true, renews the protection lease for the clone"
11391155

11401156
StartObservationRequest:
11411157
type: "object"

engine/configs/config.example.logical_generic.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ retrieval: # Data retrieval: initial sync and ongoing updates. Two methods:
146146
cloning:
147147
accessHost: "localhost" # Host that will be specified in database connection info for all clones (only used to inform users)
148148
maxIdleMinutes: 120 # Automatically delete clones after the specified minutes of inactivity; 0 - disable automatic deletion
149+
protectionLeaseDurationMinutes: 10080 # Clone protection lease duration in minutes (default: 7 days); 0 - infinite protection
150+
protectionRenewalDurationMinutes: 4320 # Renewal duration in minutes (default: 3 days); 0 - use initial duration
151+
protectionExpiryWarningMinutes: 1440 # Send warning webhook N minutes before expiry (default: 24 hours)
149152

150153
diagnostic:
151154
logsRetentionDays: 7 # How many days to keep logs

engine/configs/config.example.logical_rds_iam.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ retrieval: # Data retrieval: initial sync and ongoing updates. Two methods:
146146
cloning:
147147
accessHost: "localhost" # Host that will be specified in database connection info for all clones (only used to inform users)
148148
maxIdleMinutes: 120 # Automatically delete clones after the specified minutes of inactivity; 0 - disable automatic deletion
149+
protectionLeaseDurationMinutes: 10080 # Clone protection lease duration in minutes (default: 7 days); 0 - infinite protection
150+
protectionRenewalDurationMinutes: 4320 # Renewal duration in minutes (default: 3 days); 0 - use initial duration
151+
protectionExpiryWarningMinutes: 1440 # Send warning webhook N minutes before expiry (default: 24 hours)
149152

150153
diagnostic:
151154
logsRetentionDays: 7 # How many days to keep logs

engine/configs/config.example.physical_generic.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ retrieval: # Data retrieval: initial sync and ongoing updates. Two methods:
114114
cloning:
115115
accessHost: "localhost" # Host that will be specified in database connection info for all clones (only used to inform users)
116116
maxIdleMinutes: 120 # Automatically delete clones after the specified minutes of inactivity; 0 - disable automatic deletion
117+
protectionLeaseDurationMinutes: 10080 # Clone protection lease duration in minutes (default: 7 days); 0 - infinite protection
118+
protectionRenewalDurationMinutes: 4320 # Renewal duration in minutes (default: 3 days); 0 - use initial duration
119+
protectionExpiryWarningMinutes: 1440 # Send warning webhook N minutes before expiry (default: 24 hours)
117120

118121
diagnostic:
119122
logsRetentionDays: 7 # How many days to keep logs

engine/configs/config.example.physical_pgbackrest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ retrieval: # Data retrieval: initial sync and ongoing updates. Two methods:
144144
cloning:
145145
accessHost: "localhost" # Host that will be specified in database connection info for all clones (only used to inform users)
146146
maxIdleMinutes: 120 # Automatically delete clones after the specified minutes of inactivity; 0 - disable automatic deletion
147+
protectionLeaseDurationMinutes: 10080 # Clone protection lease duration in minutes (default: 7 days); 0 - infinite protection
148+
protectionRenewalDurationMinutes: 4320 # Renewal duration in minutes (default: 3 days); 0 - use initial duration
149+
protectionExpiryWarningMinutes: 1440 # Send warning webhook N minutes before expiry (default: 24 hours)
147150

148151
diagnostic:
149152
logsRetentionDays: 7 # How many days to keep logs

engine/configs/config.example.physical_walg.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ retrieval: # Data retrieval: initial sync and ongoing updates. Two methods:
117117
cloning:
118118
accessHost: "localhost" # Host that will be specified in database connection info for all clones (only used to inform users)
119119
maxIdleMinutes: 120 # Automatically delete clones after the specified minutes of inactivity; 0 - disable automatic deletion
120+
protectionLeaseDurationMinutes: 10080 # Clone protection lease duration in minutes (default: 7 days); 0 - infinite protection
121+
protectionRenewalDurationMinutes: 4320 # Renewal duration in minutes (default: 3 days); 0 - use initial duration
122+
protectionExpiryWarningMinutes: 1440 # Send warning webhook N minutes before expiry (default: 24 hours)
120123

121124
diagnostic:
122125
logsRetentionDays: 7 # How many days to keep logs

0 commit comments

Comments
 (0)