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

Order services by name to do not generate CDS when service state in remote has chanfed #159

Merged
merged 7 commits into from
Sep 15, 2020

Conversation

lukidzi
Copy link
Contributor

@lukidzi lukidzi commented Aug 26, 2020

Added ordering of global snapshot to keep CDS version same when the order of services from remote has changed.
Didn't change List<Cluster> to Set` because we would have to do the same operation for the same group. Here we can do this just once in global snapshot.

@slonka slonka temporarily deployed to envoy-control-pr-159 August 26, 2020 14:15 Inactive
@@ -89,6 +89,7 @@ class EnvoySnapshotFactory(
}

return addRemovedClusters(previousClusters, currentClusters)
.toSortedMap(Comparator.naturalOrder())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we need Comparator.naturalOrder()? I think it's a default one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is. I wanted to make it clear that we need naturalOrder and if a default would change we won't break.

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 we won't break if the default changes, because we are not interested in how the entries are sorted, we only require them to be sorted consistently.
Side note: there is really no chance that the default will change. It would be a breaking change and there is really no other candidate to set as a default.

But I see no problem with stating it explicitly, so for me we can keep it.

@slonka slonka temporarily deployed to envoy-control-pr-159 August 31, 2020 06:48 Inactive
@@ -89,6 +89,7 @@ class EnvoySnapshotFactory(
}

return addRemovedClusters(previousClusters, currentClusters)
.toSortedMap(Comparator.naturalOrder())
Copy link
Contributor

Choose a reason for hiding this comment

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

This change may help remove superfluous changes but this code does not communicate intent. I see this toSortedMap and wonder why this needs to be a sorted map and why it's created in this place.

I'd also change return type of clusterConfigurations to SortedMap<String, ClusterConfiguration>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment

@slonka slonka temporarily deployed to envoy-control-pr-159 August 31, 2020 15:03 Inactive
MarcinFalkowski
MarcinFalkowski previously approved these changes Sep 1, 2020
@slonka slonka temporarily deployed to envoy-control-pr-159 September 10, 2020 11:14 Inactive
@@ -51,6 +51,7 @@ import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.function.Consumer

@Suppress("LargeClass")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add an issue to think about extracting some parts of SnapshotUpdater and breaking things up.

slonka
slonka previously approved these changes Sep 10, 2020
@@ -88,7 +89,10 @@ class EnvoySnapshotFactory(
.associateWith { ClusterConfiguration(serviceName = it, http2Enabled = false) }
}

// Clusters need to be sorted because if clusters are in different order to previous snapshot then CDS version
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like something that should belong to the contract in java-control-plane's Snapshot, right?

chemicL
chemicL previously approved these changes Sep 11, 2020
@slonka slonka temporarily deployed to envoy-control-pr-159 September 15, 2020 11:58 Inactive
@slonka slonka temporarily deployed to envoy-control-pr-159 September 15, 2020 12:04 Inactive
@lukidzi lukidzi merged commit 7331077 into master Sep 15, 2020
@pzmi pzmi deleted the fix_service_order branch September 28, 2020 14:45
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.

5 participants