Skip to content

Commit da09d57

Browse files
committed
make KeysetKeysFailedShutdownHours configurable, simplify reconvery logic
1 parent 7609538 commit da09d57

10 files changed

Lines changed: 15 additions & 16 deletions

conf/default-config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"optout_inmem_cache": false,
3838
"enclave_platform": null,
3939
"failure_shutdown_wait_hours": 120,
40+
"salts_expired_shutdown_hours": 12,
41+
"keysetkeys_failed_shutdown_hours": 168,
4042
"sharing_token_expiry_seconds": 2592000,
4143
"operator_type": "public",
4244
"enable_remote_config": true,

conf/docker-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"enclave_platform": null,
4141
"failure_shutdown_wait_hours": 120,
4242
"salts_expired_shutdown_hours": 12,
43+
"keysetkeys_failed_shutdown_hours": 168,
4344
"operator_type": "public",
4445
"disable_optout_token": true,
4546
"enable_remote_config": true,

conf/integ-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"cloud_encryption_keys_metadata_path": "http://localhost:8088/cloud_encryption_keys/retrieve",
1717
"runtime_config_metadata_path": "http://localhost:8088/operator/config",
1818
"salts_expired_shutdown_hours": 12,
19+
"keysetkeys_failed_shutdown_hours": 168,
1920
"operator_type": "public",
2021
"disable_optout_token": true,
2122
"enable_remote_config": false,

conf/local-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"key_sharing_endpoint_provide_app_names": true,
3939
"client_side_token_generate_log_invalid_http_origins": true,
4040
"salts_expired_shutdown_hours": 12,
41+
"keysetkeys_failed_shutdown_hours": 168,
4142
"operator_type": "public",
4243
"encrypted_files": false,
4344
"disable_optout_token": true,

conf/local-e2e-docker-private-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"optout_delta_rotate_interval": 60,
3131
"cloud_refresh_interval": 30,
3232
"salts_expired_shutdown_hours": 12,
33+
"keysetkeys_failed_shutdown_hours": 168,
3334
"operator_type": "private",
3435
"enable_remote_config": true,
3536
"uid_instance_id_prefix": "local-private-operator"

conf/local-e2e-docker-public-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"optout_status_api_enabled": true,
3737
"cloud_refresh_interval": 30,
3838
"salts_expired_shutdown_hours": 12,
39+
"keysetkeys_failed_shutdown_hours": 168,
3940
"operator_type": "public",
4041
"disable_optout_token": true,
4142
"enable_remote_config": true,

conf/local-e2e-private-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"client_side_token_generate_domain_name_check_enabled": false,
4242
"client_side_token_generate_log_invalid_http_origins": true,
4343
"salts_expired_shutdown_hours": 12,
44+
"keysetkeys_failed_shutdown_hours": 168,
4445
"operator_type": "private",
4546
"enable_remote_config": true,
4647
"uid_instance_id_prefix": "local-private-operator"

conf/local-e2e-public-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"key_sharing_endpoint_provide_app_names": true,
4343
"client_side_token_generate_log_invalid_http_origins": true,
4444
"salts_expired_shutdown_hours": 12,
45+
"keysetkeys_failed_shutdown_hours": 168,
4546
"operator_type": "public",
4647
"disable_optout_token": true,
4748
"enable_remote_config": true,

src/main/java/com/uid2/operator/Main.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public Main(Vertx vertx, JsonObject config) throws Exception {
116116
this.validateServiceLinks = config.getBoolean(Const.Config.ValidateServiceLinks, false);
117117
this.encryptedCloudFilesEnabled = config.getBoolean(Const.Config.EncryptedFiles, false);
118118
this.shutdownHandler = new OperatorShutdownHandler(Duration.ofHours(12),
119-
Duration.ofHours(config.getInteger(Const.Config.SaltsExpiredShutdownHours, 12)), Duration.ofDays(7),
119+
Duration.ofHours(config.getInteger(Const.Config.SaltsExpiredShutdownHours, 12)),
120+
Duration.ofHours(config.getInteger(Const.Config.KeysetKeysFailedShutdownHours, 168)),
120121
Clock.systemUTC(), new ShutdownService());
121122
this.uidInstanceIdProvider = new UidInstanceIdProvider(config);
122123

src/main/java/com/uid2/operator/vertx/OperatorShutdownHandler.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,17 @@ public void logSaltFailureAtInterval() {
6767

6868
public void handleKeysetKeyRefreshResponse(Boolean success) {
6969
if (success) {
70-
Instant previousFailureTime = keysetKeyFailureStartTime.getAndSet(null);
71-
if (previousFailureTime != null) {
72-
Duration failureDuration = Duration.between(previousFailureTime, clock.instant());
73-
LOGGER.info("keyset keys sync recovered after {} ({}d {}h {}m). shutdown timer reset.",
74-
failureDuration,
75-
failureDuration.toDays(),
76-
failureDuration.toHoursPart(),
77-
failureDuration.toMinutesPart());
78-
} else {
79-
LOGGER.debug("keyset keys sync successful - timer remains null");
80-
}
70+
keysetKeyFailureStartTime.set(null);
71+
LOGGER.debug("keyset keys sync successful");
8172
} else {
8273
logKeysetKeyFailureAtInterval();
8374
Instant t = keysetKeyFailureStartTime.get();
8475
if (t == null) {
8576
keysetKeyFailureStartTime.set(clock.instant());
86-
LOGGER.warn(
87-
"keyset keys sync started failing. shutdown timer started (will shutdown in 7 days if not recovered)");
77+
LOGGER.warn("keyset keys sync started failing. shutdown timer started");
8878
} else {
8979
Duration elapsed = Duration.between(t, clock.instant());
90-
LOGGER.debug("keyset keys sync still failing - timer at {} ({}d {}h {}m) / 7 days",
91-
elapsed,
80+
LOGGER.debug("keyset keys sync still failing - elapsed time: {}d {}h {}m",
9281
elapsed.toDays(),
9382
elapsed.toHoursPart(),
9483
elapsed.toMinutesPart());

0 commit comments

Comments
 (0)