-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add ,inline
tag for toml mapping
#183
Conversation
Warning Rate limit exceeded@zyy17 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 53 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes encompass updates across multiple files, primarily focusing on refactoring configuration management in a GreptimeDB cluster context. Key modifications include introducing a new interface for object storage access, replacing utility functions for creating pointers with those from the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
4c3d527
to
5eb94cd
Compare
Signed-off-by: zyy17 <zyylsxm@gmail.com>
5eb94cd
to
d19a29c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (12)
- cmd/initializer/internal/config_generator.go (3 hunks)
- controllers/greptimedbcluster/controller_test.go (2 hunks)
- go.mod (3 hunks)
- pkg/dbconfig/common.go (1 hunks)
- pkg/dbconfig/datanode_config.go (2 hunks)
- pkg/dbconfig/dbconfig.go (5 hunks)
- pkg/dbconfig/meta_config.go (1 hunks)
- pkg/dbconfig/metasrv_config.go (0 hunks)
- pkg/dbconfig/standalone_config.go (2 hunks)
- pkg/util/k8s/k8s.go (2 hunks)
- pkg/util/util.go (0 hunks)
- tests/e2e/greptimedbcluster/test_scale_cluster.go (3 hunks)
Files not reviewed due to no reviewable changes (2)
- pkg/dbconfig/metasrv_config.go
- pkg/util/util.go
Additional comments not posted (38)
pkg/dbconfig/meta_config.go (5)
26-41
: LGTM!The
MetaConfig
struct is well-defined with appropriate fields and types. The use oftomlmapping
tags for TOML configuration mapping is a good practice.
44-63
: LGTM!The
ConfigureByCluster
method correctly sets the meta configuration fields based on the givenGreptimeDBCluster
. The use of thepointer
package for creating pointers is a good practice.
66-68
: LGTM!The empty implementation of
ConfigureByStandalone
is acceptable since it's not needed in cluster mode.
71-73
: LGTM!The
Kind
method correctly returns the component kind of the meta.
76-84
: LGTM!The
GetInputConfig
andSetInputConfig
methods are straightforward and serve their intended purpose of getting and setting the input config of the meta.go.mod (3)
22-22
: LGTM!The addition of the
k8s.io/utils
dependency to the mainrequire
block aligns with the PR objective of utilizing thek8s.io/utils/pointer
package. The specific version being used is clearly specified.
42-42
: Looks good!Moving the
github.com/gogo/protobuf
dependency to the indirect section is a valid change, as it is not being used directly in the code but is required by one of the direct dependencies. This change is consistent with the dependency management updates mentioned in the PR summary.
86-86
: LGTM!Relocating the
google.golang.org/protobuf
dependency to the indirect section is a valid change, as it is not being used directly in the code but is required by one of the direct dependencies. This change aligns with the dependency management updates outlined in the PR summary.pkg/util/k8s/k8s.go (1)
138-159
: LGTM!The
GetSecretsData
function is well-implemented and provides a convenient way to retrieve data associated with specific keys from a Kubernetes secret. Here are some positive aspects of the implementation:
- The function handles error scenarios gracefully by returning an error if the secret is not found, the secret's data is nil, or if any of the specified keys are missing.
- It encapsulates the logic of retrieving the secret and checking for the presence of keys, promoting code reuse and maintainability.
- The function is well-structured and follows a clear logic flow.
- The error messages are informative and provide sufficient context.
- The function name, parameter names, and variable names are descriptive and meaningful.
- The function returns the secret data as a slice of byte slices, allowing flexibility in further processing the data.
Overall, the
GetSecretsData
function is a valuable addition to the codebase and enhances the functionality related to retrieving data from Kubernetes secrets.pkg/dbconfig/common.go (5)
27-39
: LGTM!The
StorageConfig
struct provides a comprehensive set of fields to configure storage settings. The use of pointer fields allows for optional configuration, and thetomlmapping
tags enable mapping the fields to TOML configuration.
42-63
: LGTM!The
ConfigureS3
method correctly maps the S3 storage fields to theStorageConfig
fields. It handles the optional secret name by retrieving the access keys from Kubernetes secrets usingk8sutil.GetSecretsData
, and the error handling for retrieving secrets is appropriate.
66-87
: LGTM!The
ConfigureOSS
method correctly maps the OSS storage fields to theStorageConfig
fields. It handles the optional secret name by retrieving the access keys from Kubernetes secrets usingk8sutil.GetSecretsData
, and the error handling for retrieving secrets is appropriate.
90-114
: LGTM!The
ConfigureGCS
method correctly maps the GCS storage fields to theStorageConfig
fields. It handles the optional secret name by retrieving the service account key from Kubernetes secrets usingk8sutil.GetSecretsData
and encoding it as a base64 string. The error handling for retrieving secrets is appropriate.
117-126
: LGTM!The
WALConfig
struct provides fields to configure the WAL settings, including the directory, provider, and Kafka broker endpoints. The use of pointer fields allows for optional configuration, and thetomlmapping
tags enable mapping the fields to TOML configuration. The comments provide clear descriptions of each field's purpose.pkg/dbconfig/dbconfig.go (4)
27-32
: LGTM!The new constants
TOMLMappingFieldTag
andInlinedFieldTag
provide a clean way to customize the TOML representation of struct fields. TheInlinedFieldTag
is particularly useful for flattening nested struct fields in the TOML.
57-57
: LGTM!The change to return a
MetaConfig
instance for theMetaComponentKind
case aligns with the updated return type of theNewFromComponentKind
function to return aConfig
interface.
78-78
: LGTM!The change to call the
mergeConfig
function instead ofsetConfig
indicates a renaming of the function. ThemergeConfig
function likely merges the input TOML tree with the provided config struct, which is a clearer name for its functionality.
Line range hint
114-178
: LGTM!The
mergeConfig
function is a well-designed and robust implementation for merging the input TOML tree with the provided config struct. The renaming clarifies its purpose, and the handling of inlined fields, various field types, and error cases improves its functionality and reliability.cmd/initializer/internal/config_generator.go (4)
117-117
: LGTM!The change to use
pointer.String
instead ofutil.StringPtr
is consistent with the PR objective and looks good.
124-125
: LGTM!The change to use
pointer.String
instead ofutil.StringPtr
is consistent with the PR objective and looks good. The formatting change to split the string value across two lines is also fine.
160-160
: LGTM!The change to use
pointer.String
is consistent with the PR objective and the similar changes made in thegenerateDatanodeConfig
function. It looks good.
167-168
: LGTM!The change to use
pointer.String
is consistent with the PR objective and the similar changes made in thegenerateDatanodeConfig
function. The formatting change to split the string value across two lines is also fine. It looks good.tests/e2e/greptimedbcluster/test_scale_cluster.go (2)
82-83
: LGTM!The change to use
pointer.Int32
instead ofproto.Int
for setting replica counts is a good improvement. It makes the code more consistent with Kubernetes ecosystem conventions and improves readability.
116-117
: LGTM!Similar to the previous segment, the change to use
pointer.Int32
instead ofproto.Int
for setting replica counts during scale down is a good improvement. It makes the code more consistent with Kubernetes ecosystem conventions and improves readability.controllers/greptimedbcluster/controller_test.go (3)
129-129
: LGTM!The change from
proto.Int32(1)
topointer.Int32(1)
is consistent with the import of thek8s.io/utils/pointer
package and does not alter the functionality.
134-134
: LGTM!The change from
proto.Int32(1)
topointer.Int32(1)
is consistent with the import of thek8s.io/utils/pointer
package and does not alter the functionality.
142-142
: LGTM!The change from
proto.Int32(3)
topointer.Int32(3)
is consistent with the import of thek8s.io/utils/pointer
package and does not alter the functionality.pkg/dbconfig/standalone_config.go (4)
27-31
: Good use of embedded structs with inline TOML mappingEmbedding
StorageConfig
andWALConfig
intoStandaloneConfig
withtomlmapping:",inline"
simplifies the configuration structure and enhances code readability. This approach promotes better modularity and maintainability.
38-40
: Correctly indicating unused parameters using underscoreUsing an underscore
_
for the unusedcluster
parameter in theConfigureByCluster
method clearly communicates that this parameter is intentionally not used. This is a good practice for code clarity.
64-68
: Consistent use ofpointer.String
enhances code consistencyReplacing custom pointer utility functions with
pointer.String
fromk8s.io/utils/pointer
standardizes pointer handling across the codebase. This change improves code consistency and aligns with common Go practices.
77-80
: Proper handling of Kafka WAL configurationThe addition of Kafka WAL configuration is correctly implemented by checking for its presence and setting
WalProvider
andWalBrokerEndpoints
accordingly. This ensures flexibility and proper configuration when Kafka WAL is used.pkg/dbconfig/datanode_config.go (7)
18-18
: Use ofk8s.io/utils/pointer
enhances consistencyReplacing custom pointer utilities with the standard
pointer
package fromk8s.io/utils
improves code consistency and readability across the codebase.
31-32
: EmbeddingStorageConfig
inline improves modularityBy embedding
StorageConfig
inline intoDatanodeConfig
, storage-related configurations are encapsulated within a dedicated struct. This enhances code organization and maintainability.
34-35
: IncludingWALConfig
inline enhances code structureEmbedding
WALConfig
inline intoDatanodeConfig
effectively organizes WAL-related configurations, promoting better modularity and clarity.
63-63
: Consistent use ofpointer.String
for settingWalDir
Using
pointer.String
to setc.WalDir
aligns with the updated pointer utility usage, ensuring consistency across the codebase.
66-67
: Properly settingStorageDataHome
when data home is specifiedThe assignment of
c.StorageDataHome
usingpointer.String(dataHome)
correctly sets the storage data home directory when specified in the cluster configuration.
70-71
: Effective error handling inSetInputConfig
Ensuring that any error returned by
c.SetInputConfig(cfg)
is appropriately handled and returned maintains robust error propagation and reliability.
76-78
: Correct configuration of Kafka WAL providerSuccessfully sets the WAL provider to "kafka" and assigns the broker endpoints when Kafka WAL is enabled, ensuring that the data node is configured correctly for Kafka-based WAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What's changed
,inline
tag for toml mapping;k8sutil.GetSecretsData()
to unify the code logic of configuring object storage credentials;k8s.io/utils/pointer
package to get the pointer of data;Summary by CodeRabbit
Release Notes
New Features
Improvements
StorageConfig
structure.Bug Fixes
Dependency Updates