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

Sort availability zones for db cluster #662

Merged
merged 5 commits into from
Oct 1, 2024

Conversation

Russsnizza
Copy link
Contributor

@Russsnizza Russsnizza commented Sep 19, 2024

Fixes: #669

Description

This pull request addresses the need to maintain a consistently sorted order of 'availability zones' in our code.

Changes

The setter method now takes the input list of availability zones, creates a new modifiable list from it, sorts this list, and assigns it back to the availabilityZones field.

@Russsnizza Russsnizza marked this pull request as ready for review September 19, 2024 16:31
@harjain99 harjain99 changed the title INFRA-619: Sort availability zones for db cluster Sort availability zones for db cluster Sep 25, 2024
@@ -182,7 +183,9 @@ public List<String> getAvailabilityZones() {
}

public void setAvailabilityZones(List<String> availabilityZones) {
this.availabilityZones = availabilityZones;
List<String> modifiableList = new ArrayList<>(availabilityZones); // creates a new modifiable list
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably shouldn't blindly create a new list every time.
We should handle the conversion in the copyFrom.

    @Override
    public void copyFrom(DBCluster cluster) {
        setAvailabilityZones(new ArrayList<>(cluster.availabilityZones()));

@@ -182,7 +183,9 @@ public List<String> getAvailabilityZones() {
}

public void setAvailabilityZones(List<String> availabilityZones) {
this.availabilityZones = availabilityZones;
List<String> modifiableList = new ArrayList<>(availabilityZones); // creates a new modifiable list
Collections.sort(modifiableList);
Copy link
Contributor

Choose a reason for hiding this comment

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

The sort should take place on the getter instead.

Copy link
Contributor

@harjain99 harjain99 left a comment

Choose a reason for hiding this comment

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

Added comments

@Russsnizza
Copy link
Contributor Author

Updated

@harjain99 harjain99 merged commit 531412e into master Oct 1, 2024
1 check passed
@harjain99 harjain99 deleted the bugfix/sort-availability-zones-for-db-cluster branch October 1, 2024 19:07
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.

Order of availability zones in db-cluster resource should not matter
2 participants