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

fix(resourcerules): add own mesh to the MeshContext, so it could be successfully resolved #11525

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lobkovilya
Copy link
Contributor

Checklist prior to review

@lobkovilya lobkovilya requested a review from a team as a code owner September 23, 2024 20:18
@lobkovilya lobkovilya requested review from jijiechen and lukidzi and removed request for a team September 23, 2024 20:18
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

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

The code looks good but if I understand #11512 the really basic case seems to be broken. We've got here because we missed the test. Can we add it?

// Expand with crossMesh info
otherMeshesByName := map[string]*core_mesh.MeshResource{}
for _, m := range resources.OtherMeshes().GetItems() {
for _, m := range resources.Meshes().GetItems() {
if m.GetMeta().GetName() == meshName {
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment to explain we're skipping self

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this code to use OtherMeshes(localMesh), probably the comment now is less needed.

@@ -146,7 +146,7 @@ func (r Resources) VirtualOutbounds() *core_mesh.VirtualOutboundResourceList {
return r.ListOrEmpty(core_mesh.VirtualOutboundType).(*core_mesh.VirtualOutboundResourceList)
}

func (r Resources) OtherMeshes() *core_mesh.MeshResourceList {
func (r Resources) Meshes() *core_mesh.MeshResourceList {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not keep the OtherMeshes method? That could make code less error prone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That'd require adding another field like LocalMeshName string to the Resources struct:

type Resources struct {
    MeshLocalResources ResourceMap
    CrossMeshResources map[xds.MeshName]ResourceMap
}

Given the fact at this moment we don't have constructor for Resources it increases the scope of this PR.

I can maybe add method:

func (r Resources) OtherMeshes(localMesh string) *core_mesh.MeshResourceList {
    ...
}

@lahabana @michaelbeaumont wdyt?

Copy link
Contributor

@lahabana lahabana left a comment

Choose a reason for hiding this comment

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

I'd strongly argue for keeping the OtherMeshes method and adding a new Meshes method as it would make the change simpler but also makes the API less error prone

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.

3 participants