Skip to content

Conversation

@sophia-chen-ttd
Copy link
Contributor

@sophia-chen-ttd sophia-chen-ttd commented Jul 14, 2025

  • Added ENABLE_SALT_ROTATION_CUSTOM_AGE_THRESHOLDS feature switch to Admin, default to false
  • Wrapped default age sequence (i.e. 90 days, 120 days, ... 390 days) behind feature switch

Tests:

  • ENABLE_SALT_ROTATION_CUSTOM_AGE_THRESHOLDS == true means that we will use the custom min_ages given in the URL parameter
  • ENABLE_SALT_ROTATION_CUSTOM_AGE_THRESHOLDS == false means that we use the default age sequence (i.e. 90 days, 120 days, ... 390 days)
  • If ENABLE_SALT_ROTATION_CUSTOM_AGE_THRESHOLDS == true but there is no parameter defined in the URL, we return an error.

this.storageManager = storageManager;
this.saltProvider = saltProvider;
this.saltRotation = saltRotation;
this.defaultSaltRotationAgeThresholds = generateThresholds(30, 390, 30);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I think having this calculated may be an overkill, we can just have the array hardcoded here or in generateThresholds. It would be both clearer, easier to change and require less tests.

final Duration[] minAges = RequestUtil.getDurations(rc, "min_ages_in_seconds");
if (minAges == null) return;

final Duration[] ageThresholds;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's log what thresholds we ended up using

private final SaltStoreWriter storageManager;
private final RotatingSaltProvider saltProvider;
private final SaltRotation saltRotation;
private final Duration[] defaultSaltRotationAgeThresholds;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly just set this variable to be a static final

e.g.

private static final Duration[] SALT_ROTATION_AGE_THRESHOLDS = generateThresholds(30, 390, 30);

or

private static final Duration[] SALT_ROTATION_AGE_THRESHOLDS = new Duration[] { ... };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do the former, remember to make generateThresholds() a static function

@sophia-chen-ttd sophia-chen-ttd merged commit 3d9dbe2 into main Jul 17, 2025
1 check passed
@sophia-chen-ttd sophia-chen-ttd deleted the sch-UID2-5444-hardcode-salt-rotation-min-ages branch July 17, 2025 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants