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

refactor: make sure operator upgrade smooth #187

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

zyy17
Copy link
Collaborator

@zyy17 zyy17 commented Sep 25, 2024

What's changed

  1. Update the default values to the spec if it is not set.
  2. Add FileStorageType and don't need to add labels for datanode storage because of the statefulset doesn't support to modify PVC labels;

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new constant for file storage type labels and streamlined PVC handling based on storage types.
    • Added a function to retrieve PVCs based on specified parameters, enhancing flexibility in storage management.
  • Improvements

    • Refactored logic in cluster initialization and updates for better clarity and maintenance.
    • Updated test cases to specify storage types when retrieving PVCs, ensuring precise management of resources.

Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Walkthrough

The changes introduced in this pull request primarily focus on enhancing the management of persistent volume claims (PVCs) based on file storage types within the GreptimeDB controllers. Key modifications include the introduction of a new FileStorageType constant and refactoring of functions to utilize this type for better clarity and maintainability. The GetPVCs function has been added to streamline PVC retrieval, and several existing methods have been updated to align with the new structure, ensuring a consistent approach to handling different storage types across the codebase.

Changes

File Path Change Summary
controllers/common/common.go Introduced FileStorageType and constants for storage types. Refactored FileStorageToPVC to accept FileStorageType. Added GetPVCs for PVC retrieval.
controllers/greptimedbcluster/controller.go Reordered logic in Reconcile function for better clarity in initialization and updating of the cluster object.
controllers/greptimedbcluster/deployers/datanode.go Refactored deleteStorage to accept FileStorageType. Updated calls in CleanUp and generatePVCs methods for consistency.
controllers/greptimedbstandalone/controller.go Similar modifications as in greptimedbcluster for handling standalone object initialization and updates in Reconcile.
controllers/greptimedbstandalone/deployer.go Updated deleteStorage to use FileStorageType. Simplified PVC retrieval logic using common.GetPVCs.
tests/e2e/... Multiple test files updated to reflect changes in GetPVCs calls, specifying FileStorageType instead of using nil or previous label maps.

Possibly related PRs

  • feat: add ,inline tag for toml mapping #183: This PR introduces the k8sutil.GetSecretsData() function for managing secrets related to object storage, which aligns with the main PR's focus on handling persistent volume claims (PVCs) based on file storage types.

Suggested reviewers

  • daviderli614

🐰 In the fields where data flows,
New storage types, as the rabbit knows.
PVCs now clear, with labels neat,
Refactored code, a joyful feat!
Hop along, let’s code and play,
With every change, we brighten the day! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9fc590e and 2ec86f8.

📒 Files selected for processing (11)
  • controllers/common/common.go (3 hunks)
  • controllers/greptimedbcluster/controller.go (2 hunks)
  • controllers/greptimedbcluster/deployers/datanode.go (3 hunks)
  • controllers/greptimedbstandalone/controller.go (2 hunks)
  • controllers/greptimedbstandalone/deployer.go (3 hunks)
  • tests/e2e/greptimedbcluster/test_basic_cluster.go (1 hunks)
  • tests/e2e/greptimedbcluster/test_cluster_enable_flow.go (1 hunks)
  • tests/e2e/greptimedbcluster/test_cluster_enable_remote_wal.go (1 hunks)
  • tests/e2e/greptimedbcluster/test_cluster_standalone_wal.go (1 hunks)
  • tests/e2e/greptimedbstandalone/test_basic_standalone.go (1 hunks)
  • tests/e2e/helper/helper.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • controllers/common/common.go
  • controllers/greptimedbcluster/controller.go
  • controllers/greptimedbcluster/deployers/datanode.go
  • controllers/greptimedbstandalone/controller.go
  • controllers/greptimedbstandalone/deployer.go
  • tests/e2e/greptimedbcluster/test_basic_cluster.go
  • tests/e2e/greptimedbcluster/test_cluster_enable_flow.go
  • tests/e2e/greptimedbcluster/test_cluster_enable_remote_wal.go
  • tests/e2e/greptimedbcluster/test_cluster_standalone_wal.go
  • tests/e2e/greptimedbstandalone/test_basic_standalone.go
  • tests/e2e/helper/helper.go

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (10)
tests/e2e/greptimedbstandalone/test_basic_standalone.go (1)

90-90: Approved: Storage type specification enhances test precision.

The change to include common.FileStorageTypeDatanode as an argument in the h.GetPVCs call aligns with the PR objectives and improves the specificity of the PVC retrieval in the test.

Consider adding a brief comment explaining why we're specifically checking for datanode PVCs here. This would enhance the test's readability and maintainability. For example:

// Verify that the datanode PVC is retained after standalone deletion
dataPVCs, err := h.GetPVCs(ctx, testStandalone.Namespace, testStandalone.Name, greptimev1alpha1.StandaloneKind, common.FileStorageTypeDatanode)
tests/e2e/greptimedbcluster/test_basic_cluster.go (1)

90-90: Approved: Enhanced PVC retrieval with specific storage type.

The addition of common.FileStorageTypeDatanode as an argument to h.GetPVCs aligns well with the PR objectives. It makes the PVC retrieval more specific and consistent with the new FileStorageType parameter introduced in this PR.

Consider adding a brief comment explaining the significance of using common.FileStorageTypeDatanode here. This would enhance code readability and make the intent clearer for future maintainers. For example:

// Retrieve PVCs specifically for datanode storage type
datanodePVCs, err := h.GetPVCs(ctx, testCluster.Namespace, testCluster.Name, greptimev1alpha1.DatanodeComponentKind, common.FileStorageTypeDatanode)
tests/e2e/greptimedbcluster/test_cluster_enable_remote_wal.go (1)

90-90: LGTM! Consider enhancing error handling.

The change from nil to common.FileStorageTypeDatanode in the GetPVCs call aligns well with the PR objective of adding a FileStorageType parameter. This modification improves the specificity of PVC retrieval for datanodes, which is beneficial for storage management during upgrades.

Consider wrapping the GetPVCs call in a separate function that includes more detailed error handling. This could provide more context if the PVC retrieval fails, making debugging easier. For example:

func getDatanodePVCs(ctx context.Context, h *helper.Helper, cluster *greptimev1alpha1.GreptimeDBCluster) ([]corev1.PersistentVolumeClaim, error) {
	pvcs, err := h.GetPVCs(ctx, cluster.Namespace, cluster.Name, greptimev1alpha1.DatanodeComponentKind, common.FileStorageTypeDatanode)
	if err != nil {
		return nil, fmt.Errorf("failed to get datanode PVCs: %w", err)
	}
	return pvcs, nil
}

Then use this function in your test:

datanodePVCs, err := getDatanodePVCs(ctx, h, testCluster)
Expect(err).NotTo(HaveOccurred(), "failed to get datanode PVCs")

This approach would make the test more readable and provide more detailed error information if needed.

tests/e2e/greptimedbcluster/test_cluster_standalone_wal.go (1)

96-96: LGTM: Updated PVC retrieval for WAL

The change from common.WALFileStorageLabels to common.FileStorageTypeWAL is consistent with the previous modification and aligns with the PR objectives.

Consider extracting the FileStorageTypeWAL constant to a variable at the beginning of the function for improved readability:

 func TestClusterStandaloneWAL(ctx context.Context, h *helper.Helper) {
     const (
         testCRFile  = "./testdata/resources/cluster/standalone-wal/cluster.yaml"
         testSQLFile = "./testdata/sql/cluster/partition.sql"
+        walStorageType = common.FileStorageTypeWAL
     )
     
     // ... (rest of the function)
     
     Eventually(func() error {
-        walPVCs, err := h.GetPVCs(ctx, testCluster.Namespace, testCluster.Name, greptimev1alpha1.DatanodeComponentKind, common.FileStorageTypeWAL)
+        walPVCs, err := h.GetPVCs(ctx, testCluster.Namespace, testCluster.Name, greptimev1alpha1.DatanodeComponentKind, walStorageType)
         if err != nil {
             return err
         }
         // ... (rest of the function)
     }, helper.DefaultTimeout, time.Second).ShouldNot(HaveOccurred())
 }

This change would make the code more readable and easier to maintain.

controllers/greptimedbstandalone/controller.go (3)

122-126: LGTM: Proper handling of default values

The changes appropriately create a deep copy of the original object and set default values. The error handling for SetDefaults is good.

Consider wrapping the error returned from SetDefaults to provide more context:

 if err = standalone.SetDefaults(); err != nil {
-		r.Recorder.Event(standalone, corev1.EventTypeWarning, "SetDefaultValuesFailed", fmt.Sprintf("Set default values failed: %v", err))
-		return ctrl.Result{}, err
+		wrappedErr := fmt.Errorf("failed to set default values: %w", err)
+		r.Recorder.Event(standalone, corev1.EventTypeWarning, "SetDefaultValuesFailed", wrappedErr.Error())
+		return ctrl.Result{}, wrappedErr
 }

This change would provide more context in the error message, making debugging easier.


128-138: LGTM: Proper handling of spec updates and logging

The changes correctly compare the original and updated specs, update the cluster state when necessary, and log the creation of a new standalone at the appropriate time.

Consider adding a retry mechanism for the update operation to handle potential conflicts:

 if !cmp.Equal(originalObject.Spec, standalone.Spec) {
-		if err = r.Update(ctx, standalone); err != nil {
-			r.Recorder.Event(standalone, corev1.EventTypeWarning, "UpdateStandaloneFailed", fmt.Sprintf("Update standalone failed: %v", err))
-			return ctrl.Result{}, err
-		}
+		err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
+			if err := r.Get(ctx, types.NamespacedName{Name: standalone.Name, Namespace: standalone.Namespace}, standalone); err != nil {
+				return err
+			}
+			standalone.Spec = originalObject.Spec
+			return r.Update(ctx, standalone)
+		})
+		if err != nil {
+			r.Recorder.Event(standalone, corev1.EventTypeWarning, "UpdateStandaloneFailed", fmt.Sprintf("Update standalone failed: %v", err))
+			return ctrl.Result{}, err
+		}
 }

This change would make the update operation more resilient to conflicts that may occur in a concurrent environment.


122-138: Overall assessment: Improved standalone object handling

The changes in this file enhance the Reconcile function by:

  1. Properly setting default values for the standalone object.
  2. Efficiently detecting and applying updates to the standalone spec.
  3. Improving the timing of logging for new standalone creation.

These modifications contribute to more robust and consistent handling of the GreptimeDBStandalone custom resource. The use of deep copying and comparison ensures that updates are applied only when necessary, potentially reducing unnecessary API calls to the Kubernetes cluster.

Consider implementing a unit test for the Reconcile function to verify the new behavior, especially around setting defaults and updating the standalone object. This would help ensure the correctness of these critical operations and make the code more maintainable in the long run.

controllers/greptimedbcluster/deployers/datanode.go (1)

237-240: Improved storage deletion with FileStorageType

The deleteStorage method has been refactored to use FileStorageType, which is consistent with the changes in the CleanUp method. The use of GetPVCs function simplifies PVC retrieval.

Consider adding more detailed error logging when PVC deletion fails. For example:

 for _, pvc := range claims {
 	klog.Infof("Deleting datanode PVC: %s", pvc.Name)
 	if err := d.Delete(ctx, &pvc); err != nil {
+		klog.Errorf("Failed to delete PVC %s: %v", pvc.Name, err)
 		return err
 	}
 }

Also applies to: 245-249

controllers/greptimedbstandalone/deployer.go (2)

154-155: Enhance log message to include the storage type

The current log message in deleteStorage is generic and doesn't specify which storage type is being deleted. For better clarity in logs, consider including the fsType in the message.

Suggested change:

- klog.Infof("Deleting standalone storage...")
+ klog.Infof("Deleting standalone storage of type: %s", fsType)

Line range hint 162-166: Handle errors when deleting PVCs to avoid partial deletions

If an error occurs while deleting a PVC, the function returns immediately, which might leave subsequent PVCs undeleted. To ensure all PVCs are attempted for deletion, consider logging the error and continuing the loop or aggregating errors.

Suggested modification:

var deleteErrors []error
for _, pvc := range claims {
    klog.Infof("Deleting standalone PVC: %s", pvc.Name)
    if err := d.Delete(ctx, &pvc); err != nil {
        klog.Errorf("Failed to delete PVC %s: %v", pvc.Name, err)
        deleteErrors = append(deleteErrors, err)
    }
}
if len(deleteErrors) > 0 {
    return fmt.Errorf("failed to delete one or more PVCs")
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 25ddd65 and 9fc590e.

🔇 Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (12)
  • controllers/common/common.go (3 hunks)
  • controllers/greptimedbcluster/controller.go (2 hunks)
  • controllers/greptimedbcluster/deployers/datanode.go (3 hunks)
  • controllers/greptimedbstandalone/controller.go (2 hunks)
  • controllers/greptimedbstandalone/deployer.go (3 hunks)
  • go.mod (1 hunks)
  • tests/e2e/greptimedbcluster/test_basic_cluster.go (1 hunks)
  • tests/e2e/greptimedbcluster/test_cluster_enable_flow.go (1 hunks)
  • tests/e2e/greptimedbcluster/test_cluster_enable_remote_wal.go (1 hunks)
  • tests/e2e/greptimedbcluster/test_cluster_standalone_wal.go (1 hunks)
  • tests/e2e/greptimedbstandalone/test_basic_standalone.go (1 hunks)
  • tests/e2e/helper/helper.go (1 hunks)
🔇 Additional comments not posted (19)
tests/e2e/greptimedbcluster/test_basic_cluster.go (1)

Line range hint 1-101: Summary: Improved specificity in PVC retrieval for datanode storage.

The change made to the TestBasicCluster function enhances the test by specifying the storage type when retrieving Persistent Volume Claims (PVCs) for datanodes. This modification aligns well with the PR objectives of refactoring the operator for smoother upgrades and introducing the FileStorageType parameter.

The test's overall structure and logic remain intact, maintaining its effectiveness in verifying the basic cluster functionality while now being more precise in its PVC management. This change contributes to a more robust and specific testing process for the GreptimeDB operator.

tests/e2e/greptimedbcluster/test_cluster_enable_flow.go (1)

90-90: LGTM: Improved PVC retrieval specificity

The addition of common.FileStorageTypeDatanode as a parameter to h.GetPVCs aligns well with the PR objectives. This change enhances the precision of PVC retrieval by specifically targeting datanode storage, which is consistent with the introduction of the new FileStorageType parameter mentioned in the PR summary.

This modification improves the test's ability to accurately verify PVC retention for datanodes after cluster deletion, without altering the overall logic of the test.

tests/e2e/greptimedbcluster/test_cluster_standalone_wal.go (2)

90-96: Overall assessment: Improved PVC retrieval consistency

The changes in this file successfully implement the new FileStorageType parameter for both datanode and WAL PVC retrievals. This update enhances code clarity and maintains consistency with the PR objectives. The modifications contribute to a more streamlined upgrade process for the operator by standardizing how different storage types are handled.


90-90: LGTM: Updated PVC retrieval for datanodes

The change from common.DatanodeFileStorageLabels to common.FileStorageTypeDatanode aligns with the PR objectives and improves clarity in specifying the storage type.

Let's verify the consistency of this change across the codebase:

✅ Verification successful

Verified: Consistent usage of FileStorageTypeDatanode across the codebase

The update successfully replaces DatanodeFileStorageLabels with FileStorageTypeDatanode, ensuring consistency throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of DatanodeFileStorageLabels and ensure FileStorageTypeDatanode is used consistently.

# Test 1: Search for any remaining usage of DatanodeFileStorageLabels
echo "Searching for any remaining usage of DatanodeFileStorageLabels:"
rg --type go "DatanodeFileStorageLabels"

# Test 2: Verify consistent usage of FileStorageTypeDatanode
echo "Verifying consistent usage of FileStorageTypeDatanode:"
rg --type go "FileStorageTypeDatanode"

Length of output: 2106

go.mod (1)

7-7: Dependency update looks good, but verify its impact.

The update of github.com/google/go-cmp from v0.5.9 to v0.6.0 is a minor version change, which typically includes new features and bug fixes without breaking changes. This change also moves the dependency from indirect to direct, suggesting intentional use in the project.

To ensure this update doesn't introduce any unexpected behavior, please:

  1. Review the changelog for go-cmp v0.6.0 to understand the changes.
  2. Run the project's test suite to verify that the update doesn't break any existing functionality.
  3. Check if any new features in v0.6.0 could be beneficial for the project.
tests/e2e/helper/helper.go (1)

125-126: Approve changes with verification suggestions.

The refactoring of GetPVCs function aligns well with the PR objectives. The implementation is now more concise and leverages a common utility function, which should improve maintainability and consistency across the codebase.

However, this change has some potential impacts:

  1. Any existing calls to this method using additionalLabels will need to be updated to provide the appropriate FileStorageType.
  2. The behavior of PVC retrieval might have changed, depending on how common.GetPVCs handles filtering compared to the previous implementation.

To ensure the changes don't introduce regressions:

  1. Update all calls to this method in the e2e tests to use the new signature.
  2. Verify that all e2e tests using this method still pass with the new implementation.
  3. Check if there are any edge cases in the e2e tests that relied on custom label filtering, and adjust the tests if necessary.

You can use the following script to find all occurrences of GetPVCs in the e2e test files:

✅ Verification successful

Verification Successful.

All calls to the GetPVCs method in the e2e tests have been updated to use the new FileStorageType parameter. No instances of the old additionalLabels parameter remain, ensuring consistency and reducing potential errors.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all occurrences of GetPVCs in e2e test files
rg --type go 'GetPVCs' tests/e2e

Length of output: 1646

controllers/greptimedbstandalone/controller.go (1)

24-24: LGTM: Import addition for object comparison

The addition of the github.com/google/go-cmp/cmp import is appropriate for the new functionality in the Reconcile function, where object comparison is performed.

controllers/greptimedbcluster/deployers/datanode.go (3)

85-85: Improved storage cleanup with FileStorageType constants

The changes in the CleanUp method enhance code clarity and maintainability by using FileStorageType constants instead of label maps. This aligns well with the PR objectives of streamlining the upgrade process.

Also applies to: 91-91, 97-97


473-473: Consistent use of FileStorageType in PVC generation

The generatePVCs method has been updated to use FileStorageType constants, which is consistent with the changes in other parts of the file. This improves code consistency and readability.

Also applies to: 478-478, 483-483


Line range hint 1-624: Overall improvement in storage management and code consistency

The changes introduced in this file significantly enhance the storage management process by consistently using FileStorageType constants. This aligns well with the PR objectives of streamlining the upgrade process and improving maintainability. The modifications are consistent throughout the file, from the CleanUp method to PVC generation, resulting in more readable and maintainable code.

controllers/common/common.go (4)

31-34: Definition of FileStorageTypeLabelKey is appropriate

The constant FileStorageTypeLabelKey is correctly defined and well-documented. It provides a clear key for PVC labels indicating the type of file storage.


36-41: Proper declaration of FileStorageType and its constants

The type FileStorageType and its associated constants (FileStorageTypeDatanode, FileStorageTypeWAL, FileStorageTypeCache) are appropriately defined, enhancing code clarity and maintainability.


175-189: Validation of label assignment in FileStorageToPVC

The function FileStorageToPVC correctly assigns labels based on the FileStorageType. Setting labels to nil for FileStorageTypeDatanode is appropriate due to limitations with modifying PVC labels in StatefulSets.


209-259: Verify that GetPVCs correctly filters PVCs based on FileStorageType labels

The GetPVCs function constructs label selectors to retrieve PVCs according to the FileStorageType. The use of MatchExpressions and MatchLabels seems appropriate. However, to ensure that PVCs are correctly retrieved, please verify that PVCs have the expected labels in the cluster.

Run the following script to list PVCs and their labels:

Check the output to ensure that the labels align with the expectations, confirming that the GetPVCs function will accurately filter the PVCs based on their storage type.

controllers/greptimedbstandalone/deployer.go (2)

322-334: Confirm PVCs are generated correctly for each storage type

In the generatePVCs method, PVCs are created for different storage types using common.FileStorageToPVC. Ensure that this function correctly handles each FileStorageType and that the resulting PVCs have the appropriate configurations.

To verify, review the PVC definitions generated for each storage type:

#!/bin/bash
# Description: Display generated PVC YAML for inspection.

# Test: Output PVC definitions. Expect: Correct configurations per storage type.
kubectl get pvc -n <namespace> -o yaml

Replace <namespace> with the appropriate namespace to inspect the PVCs.


100-105: Verify all calls to deleteStorage use the new signature

The deleteStorage function now accepts fsType common.FileStorageType instead of additionalLabels map[string]string. Please ensure that all invocations of deleteStorage have been updated accordingly to prevent any potential issues.

Run the following script to check for any remaining calls using the old signature:

Also applies to: 106-110, 112-116

controllers/greptimedbcluster/controller.go (3)

24-24: Adding "github.com/google/go-cmp/cmp" for deep comparison is appropriate

The inclusion of the cmp package allows for accurate comparison of complex structs like Spec. This is suitable for detecting changes after setting default values.


142-146: Use of DeepCopy and SetDefaults

Creating a deep copy of the cluster before applying defaults is a good practice to preserve the original state for comparison. Error handling is properly implemented.


Line range hint 156-162: Validation of cluster creation detection logic

By moving the check for cluster creation after setting defaults and potential updates, you ensure that the cluster status reflects the most accurate state. The logic is sound.

controllers/greptimedbcluster/controller.go Outdated Show resolved Hide resolved
Copy link
Member

@daviderli614 daviderli614 left a comment

Choose a reason for hiding this comment

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

LGTM

@zyy17 zyy17 merged commit abf79b4 into GreptimeTeam:develop Sep 26, 2024
5 checks passed
@zyy17 zyy17 deleted the refactor/legacy-upgrade branch September 26, 2024 11:36
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.

2 participants