Feat/3.0/TS-7230
Description
Please briefly describe the code changes in this pull request.
Jira: https://jira.taosdata.com:18080/browse/TD-
Checklist
Please check the items in the checklist if applicable.
- [ ] Is the user manual updated?
- [ ] Are the test cases passed and automated?
- [ ] Is there no significant decrease in test coverage?
Summary of Changes
Hello @xiao-77, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a robust multi-layer encryption key management system, primarily targeting enterprise features. It establishes a secure and automated mechanism for dnodes to synchronize their encryption keys with mnodes, ensuring data consistency and security across the cluster. The changes involve defining new communication protocols, implementing client and server-side logic for key exchange, and updating the key loading process to support the new encryption architecture while maintaining compatibility with existing setups.
Highlights
- Multi-Layer Encryption Key Definitions: Introduced a comprehensive set of global variables in
include/common/tglobal.hand initialized insource/common/src/tglobal.cto support multi-layer encryption. These include flags for TAOSK encryption usage, server, database, config, metadata, and data keys, algorithm type, file format version, key update version, creation timestamps, and enabled flags for various key types. - Key Synchronization Messaging: Defined new message types
TDMT_MND_ENCRYPT_KEYandTDMT_MND_KEY_SYNCininclude/common/tmsgdef.h. CorrespondingSKeySyncReqandSKeySyncRspstructures, along with their serialization and deserialization functions, were added ininclude/common/tmsg.hand implemented insource/common/src/msg/tmsg.cto facilitate key exchange between dnodes and mnodes. - Dnode Key Synchronization Logic: Implemented a new
keySyncThreadwithin the dnode management (SDnodeMgmt) insource/dnode/mgmt/mgmt_dnode/inc/dmInt.handsource/dnode/mgmt/mgmt_dnode/src/dmWorker.c. This thread periodically sends key synchronization requests (SKeySyncReq) to the mnode and processes the responses (SKeySyncRsp), updating local encryption keys if necessary. This ensures dnodes have the most current encryption keys from the mnode. - Mnode Key Synchronization Handling: The mnode now includes a handler (
mndProcessKeySyncReqinsource/dnode/mnode/impl/src/mndConfig.c) forTDMT_MND_KEY_SYNCmessages. It loads the mnode's encryption keys and responds to dnodes, providing updated keys if the dnode's local key version is outdated. - Enhanced Encryption Key Loading: Modified the
dmGetEncryptKeyfunction insource/dnode/mgmt/node_util/src/dmFile.cto prioritize loading multi-layer encryption keys from ataosk encrypt.binfile. If this new format is not found or fails to load, it gracefully falls back to the legacyencryptCode.cfgformat, ensuring backward compatibility. - Conditional Enterprise Features: Updated CMakeLists.txt files across
dnode/mgmtanddnode/mnodemodules to conditionally include TAOSK-related headers and functionality only whenTD_ENTERPRISEis defined, ensuring that these encryption features are specific to the enterprise edition.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.