Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bmz-UID2-4612 add endpoint to serve operator config #200

Merged
merged 12 commits into from
Jan 9, 2025

Conversation

BehnamMozafari
Copy link
Contributor

  • Added a new endpoint /operator/config
  • Uses vertx FileSystem to serve conf/operator-config.json as a JsonObject
  • operator-config.json currently stores config values "identity_token_expires_after_seconds", "refresh_token_expires_after_seconds", "refresh_identity_token_after_seconds" and "sharing_token_expiry_seconds" from local-config.json in operator

"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"sharing_token_expiry_seconds": 2592000
}

Choose a reason for hiding this comment

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

suggest using an object ;

OperatorRunTimeConfig (or similar) and using that instead of JsonObject

It will improve readability as we know what exactly we need/have to set in config.

Also in followup MRs; Please make sure we remove the unwanted config from operators

Copy link
Contributor

@clarkxuyang clarkxuyang Jan 7, 2025

Choose a reason for hiding this comment

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

@BehnamMozafari Could you give more context why we need to use an additional config file for this? The current config hierarchy - default, local, integ, prod config already covers config for each env. I am not sure where operator-config.config is fit into this hierarchy.
If we want to serve the run time config (config might be changed at start time, as the config can also be taken from/overwrited by env vars), we should read them from the run time system and send in api.

Choose a reason for hiding this comment

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

(I will explain, please correct if I am wrong @BehnamMozafari )

this is the config, core servers to operators. We are adding this new operator-config in core that servers runtime config core sets for operators.

Since it is not core config, we added a new file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Abu, yep that's correct, the operator-config is going to be served to operator and will be mounted to core using a configmap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

suggest using an object ;

OperatorRunTimeConfig (or similar) and using that instead of JsonObject

I agree, this would help in validating any updates to operator-config. I'm considering implementing this in a future MR. However, a concern is that it would require us to redeploy core whenever we want to add a new operator config value to be consumed at run time.

Copy link
Contributor

Choose a reason for hiding this comment

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

How would we add a new operator config value with the JsonObject implementation?

Choose a reason for hiding this comment

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

Stronger typing and validation on config updates can reduce risks.

Adding new config_values without an E2E test offers no guarantee it won't break. If it passes E2E tests, it's safe for release, otherwise, prioritizing and addressing those issues would be essential.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would we add a new operator config value with the JsonObject implementation?

With the current implementation, we would need to add the new value to the configmap in the deployment repo, we would also have to make the changes in operator to apply the new config value.

src/main/java/com/uid2/core/vertx/CoreVerticle.java Outdated Show resolved Hide resolved
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
"sharing_token_expiry_seconds": 2592000
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How would we add a new operator config value with the JsonObject implementation?

- Update tests to use testContext.succeeding to handle failures and exceptions thrown by success case
- Error handling to make sure response is sent when an exception is thrown in handleGetConfig.
- Inject vertx filesystem into CoreVerticle
- Add unit test to cover when operator-config content is invalid JSON

@Test
void getConfigInvalidJson(Vertx vertx, VertxTestContext testContext) {
operatorConfig = "invalid config";
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better if we check json config on startup to make sure it is valid. That will be easier to debug then having it only checked when operator call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the config will be updated at runtime through a configmap, it might not be sufficient to only check it at startup, but checking it whenever it has changed seems like a good idea. I'll implement this in a future mr. Thanks for the feedback!

@BehnamMozafari BehnamMozafari merged commit 4e45a60 into main Jan 9, 2025
4 checks passed
@BehnamMozafari BehnamMozafari deleted the bmz-UID2-4612-operator-config-endpoint branch January 9, 2025 03:33
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.

7 participants