This repository has been archived by the owner on Dec 3, 2021. It is now read-only.
Start endpoint pods in the order provided in the lesson definition #198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #194 we added the ability for lesson authors to specify a subnet for each Connection object, which is passed to the IPAM CNI plugin, and all containers are automatically assigned addresses from that subnet in order of attachment. This isn't quite the same as just being able to pick which IP addresses get assigned to which endpoints, but my assumption was that because endpoints are provided as a YAML list, which is ordered, the endpoints would be spun up in a consistent order, and given the same addresses each time.
I thought I had tested this at the time to validate this assumption, but apparently I didn't, because I was wrong. Turns out that the livelesson API converts these endpoints to an unordered map to make it easier to look up endpoints by name, and this is pretty heavily embedded not only in the API (which impacts antidote-web) but also the internal data models. Since this is unordered by definition, this ensures that the attachment order, and in turn, any addressing assignments, are never consistent. This is obviously not what we want, as lesson guides and configurations will rely on this consistency.
As mentioned in a long comment, I believe this is the only place where endpoint order really matters, so rather than try to change the data type for this field, I added a little logic in this PR to iterate over the map in the original endpoint order from the lesson definition, which means endpoints will always be attached to these networks in a predictable order.
While this PR fixes this immediate issue, if I am proven wrong again, and we do end up requiring order preservation for other use cases, this workaround should be removed and we should just do the work of converting this field to a slice. This will require coordination between antidote-core and antidote-web.