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

MAISTRA-2294 create CRD for federation ServiceExport #324

Merged
merged 4 commits into from May 7, 2021

Conversation

rcernich
Copy link
Contributor

Please provide a description for what this PR is for.

And to help us figure out who should review this PR, please
put an X in all the areas that this PR affects.

[ ] Configuration Infrastructure
[ ] Docs
[ ] Installation
[ ] Networking
[ ] Performance and Scalability
[ ] Policies and Telemetry
[ ] Security
[ ] Test and Release
[ ] User Experience
[ ] Developer Infrastructure

Pull Request Attributes

Please check any characteristics that apply to this pull request.

[ ] Does not have any changes that may affect Istio users.

@rcernich
Copy link
Contributor Author

This iteration of the CRD supports exporting services to specific meshes in the following way:

  • There is a single ServiceExports resource that defines all services exported to a named remote mesh.
  • The name of the ServiceExports resource must match the name of a MeshFederation resource. This is used to identify the remote mesh to which the services are exported
  • There may also be a default named ServiceExports resource, which will be applied to all remote meshes. If a named ServiceExports resource exists, the alias rules in the named resource will take precedence.
  • A ServiceExports resource contains a list of export rules. Each rule defines:
    • A selector, which is used to select a service or set of services
    • An option alias, which defines the name of the service to be exposed to the remote mesh
    • The first rule that matches will be the rule used to export the service

There are two types of export rules:

  • NameSelector allows for selecting a specific service by namespace and name and applying an optional alias for either/both namespace and name, e.g. foo/service-a might be mapped to bar/service-b or bar/service-a or foo/service-b
    • The selector may use * for either namespace or name to select services from any namespace or any name or all services (/)
    • Aliasing when using * will only apply to name or namespace if * is not used, e.g. if */service-a is the selector, only the name may be mapped, so if the alias name were service-b, you'd end up with foo/service-a and bar/service-a being exported as foo/service-b and bar/service-b
  • LabelSelector allows for selecting services from a specific namespace using a label selector. It also specifies a list of name mappings to use for aliasing selected services.
    • If namespace is omitted or specified a *, the label selector will be applied to services in all mesh namespaces.
    • Aliases work in the same manner as NameSelector (i.e. this is really a two tiered selector, with the label selector selecting the service, then matching an alias rule to determine the export name). If no alias rule matches, a selected service is exported as-is.

All services are exported as namespace/name. Any domain suffix will be managed by the importing mesh. The rationale here is that this brings export/import of services more in line with how istio manages services in the service registry, as these map nicely to simple name and namespace fields. (Current thinking is that this would be defined in MeshFederation, or just use some convention like, .svc..local. We probably still need to figure out how the domain suffix bit plays into this, but I think this simplifies export for the user. The issues will show up on the import side anyway.)

Questions:

  1. Is it acceptable that we allow configuration of a default set of export rules?
  2. Is it acceptable that there is a single resource for defining all exports, vs individual export resources for each service?
  3. Is it acceptable that we only export namespace/name, letting the importer deal with domain suffixes, etc.?
  4. Should we support globbing of names? Should we expand it to support name prefix/suffix?
  5. I'm anticipating only the mesh administrator should be able to configure federation, so only the mesh administrator should be able to configure exports. Does this seem reasonable? Using label selectors allows the mesh administrator to delegate some of that configuration, but they can reduce the scope to select namespaces, or not use it at all.

@dgn
Copy link
Contributor

dgn commented Apr 28, 2021

related to maistra/istio-operator#706

@dgn
Copy link
Contributor

dgn commented Apr 28, 2021

This iteration of the CRD supports exporting services to specific meshes in the following way:

* There is a single ServiceExports resource that defines all services exported to a named remote mesh.

The main problem I see with having everything in one resource is lack of RBAC. A system administrator can't really say "you have the right to export services in your namespaces" because it's all handled in one central resource. Some people might find it to be better than having to create individual resources per Service, but I don't really like it. There's no single resource to describe all your Deployments, either. It's a matter of taste, though.

The real question is going to be: do we want the mesh administrator to handle all of it or can Service administrators expose their services themselves? Having individual resources is better for a sort of self-service model.

* The name of the ServiceExports resource must match the name of a MeshFederation resource.  This is used to identify the remote mesh to which the services are exported

Again, this strongly ties in with the 1-to-1 relationship between MeshFederation and ServiceExport. I'd prefer a 1-to-many with an explicit meshFederationRef, but that's very verbose, so maybe this proposal is going to be more popular.

Maybe we could opt for a mix? Have the meshFederationRef instead of matching on name, so that you can have >1 ServiceExport for a single MeshFederation. That way, you can either do it the way you planned here (admin does everything) or the admin can delegate to some power users. If we scope ServiceExport to its own namespace (or the whole mesh, if in control plane namespace), an admin could delegate export permissions for services in specific namespaces via RBAC. Wdyt?

* There may also be a `default` named ServiceExports resource, which will be applied to all remote meshes.  If a named ServiceExports resource exists, the alias rules in the named resource will take precedence.

If we go for meshFederationRef, not specifying one could have this behaviour. Not sure if that's something we'd want

* A ServiceExports resource contains a list of export rules.  Each rule defines:
  
  * A selector, which is used to select a service or set of services
  * An option alias, which defines the name of the service to be exposed to the remote mesh
  * The first rule that matches will be the rule used to export the service

There are two types of export rules:

* NameSelector allows for selecting a specific service by namespace and name and applying an optional alias for either/both namespace and name, e.g. foo/service-a might be mapped to bar/service-b or bar/service-a or foo/service-b
  
  * The selector may use `*` for either namespace or name to select services from any namespace or any name or all services (_/_)
  * Aliasing when using `*` will only apply to name or namespace if `*` is not used, e.g. if */service-a is the selector, only the name may be mapped, so if the alias name were service-b, you'd end up with foo/service-a and bar/service-a being exported as foo/service-b and bar/service-b

I can see a lot of edge cases with the aliasing. What if services overlap because of the aliasing? Ie we map two services onto the same NamespacedName?

* LabelSelector allows for selecting services from a specific namespace using a label selector.  It also specifies a list of name mappings to use for aliasing selected services.

LabelSelector is kind of delegation through the backdoor, right? If a service admin knows the label, they can export. And we can't use RBAC to control it - because if you own a Service, you can label it. So I'd say we drop LabelSelector

  * If namespace is omitted or specified a `*`, the label selector will be applied to services in all mesh namespaces.
  * Aliases work in the same manner as NameSelector (i.e. this is really a two tiered selector, with the label selector selecting the service, then matching an alias rule to determine the export name).  If no alias rule matches, a selected service is exported as-is.

All services are exported as namespace/name. Any domain suffix will be managed by the importing mesh. The rationale here is that this brings export/import of services more in line with how istio manages services in the service registry, as these map nicely to simple name and namespace fields. (Current thinking is that this would be defined in MeshFederation, or just use some convention like, .svc..local. We probably still need to figure out how the domain suffix bit plays into this, but I think this simplifies export for the user. The issues will show up on the import side anyway.)

+1 on this, I think this makes perfect sense

@rcernich
Copy link
Contributor Author

rcernich commented Apr 28, 2021

@dgn, thanks for the feedback. I went with the 1:1, global model because I thought federation was something that should be restricted to the mesh administrator, as it exposes mesh resources to other parties. Given that, I didn't think it made sense to support delegation.

You're right, that label selector is sort of a back door for self-service exporting, which doesn't provide for any RBAC control, other than namespace scoping.

My thoughts on this were:

  • If you're really uptight, only the mesh administrator should be exporting services. They are responsible for the mesh and are most likely the one to get called if services disappear (e.g. somebody unexported them, or a gateway goes down), or if a service that shouldn't have been exported gets exported.
  • If you're not so uptight, you can use label selector, appropriated to select namespaces, essentially delegating responsibility to any user who can create/update services in those namespaces.
  • If you're primarily concerned about HA/FO, you probably have some very simple glob rules that don't require much maintenance (e.g. export */*, no aliasing, as a default rule).

Regarding conflicts, for now I was just going to log errors if a duplicate occurs (first match wins), eventually providing status in a status resource. I agree there are going to be issues here. Originally, I was thinking about 1:1 with service, but that doesn't help with aliasing. I was anticipating that most cases of aliasing would be namespace-a -> namespace-b, so rules like namespace-a/* aliased to namespace-b/*. The other option is to require an explicit mapping for every export, which I thought was burdensome. It is a fallback solution though, as that is supported.

Using something like meshFederationRef is probably a good idea. One concern I had with supporting multiple export resources was how to manage the rule ordering, which is part of the reason I went with a single export resource (e.g. if there are overlapping rules in two export resources, which one takes precedence).

@rcernich
Copy link
Contributor Author

I guess one thing I didn't touch on was whether or not globbing should be supported at all. I thought it made sense for things like ha/fo, e.g. export all services, or export all services from a specific namespace. Another side effect with globbing is that the set of services exported changes with the set of services in the mesh. I don't know if this is really an issue though.

@rcernich rcernich force-pushed the MAISTRA-2294 branch 10 times, most recently from e58b607 to 3e7b396 Compare May 5, 2021 17:23
@rcernich rcernich changed the title WIP: MAISTRA-2294 create CRD for federation ServiceExport MAISTRA-2294 create CRD for federation ServiceExport May 5, 2021
@longmuir
Copy link

longmuir commented May 5, 2021

Finally going through this - some good discussion points here...

The real question is going to be: do we want the mesh administrator to handle all of it or can Service administrators expose their services themselves? Having individual resources is better for a sort of self-service model.

This is a great question...and one I had to think about... we often talk about "clusters admins" and "mesh admins" as being the two levels of administration, with the assumption being that the "mesh admin" is also the admin for all of the services. That is not always the case though - sometimes customers do want to divide an individual mesh into different "zones", often based on namespaces. I think the idea of being able to have multiple ServiceExport resources makes a lot of sense, as that would allow each resource to have different RBAC scoping (or other config differences). That said, if this gets complicated, I think it's ok if "service admins" have to ask "mesh admins" for permission to export services.

The label selector option offhand doesn't bother me too much - a lot of things work this way in K8s land. Choosing to use this or not will be in the hands of the mesh admin, so they need to be aware of the risks. A "mesh admin" should be aware that if they use a label selector, services will be able to export themselves. If we support "globbing" (There's strong demand for the HA use case, and I can see there being a desire for "export all"), that would be even higher risk, and they should be aware that they're "leaving the door open" for services to automatically be exported. If we do provide these different options, I think this is something we should definitely document these risks as a call out/warning with ServiceExport (cc @JStickler).

In general, I'll favour the simpler paths while meeting the two use cases of sharing distinct services and HA/FO, with us adding additional options/flexibility as requested by customers later. That is, start with one set of options that can be expanded on later. No doubt there will be a lot of requests that we'll have to tweak over time, and those can be hard to predict.

Signed-off-by: rcernich <rcernich@redhat.com>
@dgn
Copy link
Contributor

dgn commented May 6, 2021

/retest

@rcernich
Copy link
Contributor Author

rcernich commented May 6, 2021

@dgn, @knrc, @jwendell, @brian-avery, this should be ready to merge. just needs some reviews.

maistra-bot pushed a commit that referenced this pull request Mar 1, 2022
* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (#333)
jewertow pushed a commit to jewertow/istio that referenced this pull request Jul 14, 2022
* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)
@jewertow jewertow mentioned this pull request Jul 14, 2022
jewertow pushed a commit to jewertow/istio that referenced this pull request Jul 14, 2022
* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)
jewertow pushed a commit to jewertow/istio that referenced this pull request Aug 8, 2022
* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)
jewertow pushed a commit to jewertow/istio that referenced this pull request Aug 17, 2022
* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)
jewertow pushed a commit to jewertow/istio that referenced this pull request Aug 22, 2022
* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)
maistra-bot added a commit that referenced this pull request Aug 22, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (#422)

MAISTRA-2297 Support updates of federation resources (#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (#440)

Log actual error returned by pollServices() (#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (#521)

* OSSM-1529 Improve federation example script (#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 22, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 22, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
maistra-bot added a commit that referenced this pull request Aug 23, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (#422)

MAISTRA-2297 Support updates of federation resources (#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (#440)

Log actual error returned by pollServices() (#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (#521)

* OSSM-1529 Improve federation example script (#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 24, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 25, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 25, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 25, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 29, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 29, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 29, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 29, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 29, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
maistra-bot added a commit that referenced this pull request Aug 30, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (#422)

MAISTRA-2297 Support updates of federation resources (#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (#440)

Log actual error returned by pollServices() (#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (#521)

* OSSM-1529 Improve federation example script (#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
bartoszmajsak pushed a commit to bartoszmajsak/istio that referenced this pull request Dec 1, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
bartoszmajsak pushed a commit to bartoszmajsak/istio that referenced this pull request Dec 20, 2022
* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
maistra-bot added a commit that referenced this pull request Dec 20, 2022
* [federation] Introduces federation deployment (#585)

* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (#422)

MAISTRA-2297 Support updates of federation resources (#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (#440)

Log actual error returned by pollServices() (#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (#521)

* OSSM-1529 Improve federation example script (#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>

* fix: removes deprecated gogo protobuf conversion

* fix: goimport format

* fix(lint): removes unused funcs

* fix(lint): removes deprecated io/ioutil

* fix(lint): disables staticcheck for federation tests

it requires at least two clusters to make sense

* fix(lint): use anypb.UnmarshalTo instead of ptypes

* fix: no need to exclude grpcgen_test.go

it seems to be fixed in v1.39

see: grpc/grpc-go#4476

* chore(backoff): aligns backoff dependency with v4 used by upstream

* chore: reverts removed blank line - irrelevant for merge

* chore(revive): adds explanation why json:inline is skipped from linting

* OSSM-1962: Use EndpointSlices instead of Endpoints in federation controller (#614)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2049: Fix handling ServiceAccounts in federation controller (#627)

* Fix collecting empty or repeated ServiceAccounts in federation controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Collect ServiceAccounts in sorted order

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1093 Shorten exported resource name (#653)

* Shorten exported resource name

* Fix import createResourceName + unit tests

* Rearrange unit tests + renaming function

* Gen and lint

* Rearrange unit tests + renaming function

Gen and lint

* Fix minor changes

* Error message RFC 1123

* Reorganize structs in TestStatusManager

Instead of having three arrays (events, expectedStatuses, and assertions), we now only have a single array, where each entry is a triplet containing the event, the expected status and the assertion. This allows you to see the event and its expected effects together and not have to scroll up and down, matching the indexes of the three arrays.

* OSSM-2193 Fix flaky TestStatusManager

See comment in https://issues.redhat.com/browse/OSSM-2193 to understand why this change fixes the test.

* fix: runs make gen

* chore: explains why staticcheck linter is disabled for federation_test

* OSSM-728 Configuration scripts for Federation on Z and P, and bare metal (#670)

* add config example scripts for IBM Systems Z and P

* update multi-arch bookinfo deployment README, remove src

* Update README.md

* these are provided in the IBM repo

* so README.md passes mdlinter

* so README.md passes mdlinter

* so README.md passes mdlinter

* Update README.md

* Move federation examples to samples/ directory

* Rename template YAMLs to .yaml.template

This makes the linter happy

Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

* chore: removes obsolute TODO

* chore: simplifies bool return expression

* chore: removes redundant kubeClient check

if initialization fails this func will not be reached anyway

* chore(pkg): moves kube ctrl under servicemesh pkg folder

* OSSM-2338: Remove env ISTIO_META_ROUTER_MODE from federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2338: Remove "routerMode: sni-dnat" from federation samples

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fix: adds operator.go customizations to kube.go

clearly with cherry-pick we lost information about the file rename and thus
the changes we made specificually for testing federation got lost

* fix(test/operator): checks if east-west gw needs to be deployed

* fix(federation): uses Unwrap to get instance of Federation registry

* fix(tests): sets istiod-less remote flag to false

that was the behaviour for maistra-2.3 and we need istiod to be present in order to have federation working

* chore: gets registry just before it is needed

* chore: explains why istiodlessremotes is needed to be set to false

* chore: removes redundant import aliases

* chore: removes name collisions

* chore: removes redundant type conversion

* fix: disables staticcheck linter for cluster req tests.

* fix(tests): reverts timeout to original (but in minutes)

* fix(tests): removes extra logging

* chore: removes unnecessary logging

* fix: uses existing CRD file references in charts

* chore: removes multicluster label

* chore: uses built-in namespace.NewOrFail instead of our impl

* chore: introduces defaultTimeout const for federation tests

* fix(lint): fixes go imports

* fix(lint): removes unused variable

* fix: naively wait 5s hoping that kind network will show up

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Jacek Ewertowski <jewertow@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
Co-authored-by: bmangoen <bmangoen@redhat.com>
Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>
jewertow added a commit to jewertow/istio that referenced this pull request Aug 30, 2023
maistra#699)

* [federation] Introduces federation deployment (maistra#585)

* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>

* fix: removes deprecated gogo protobuf conversion

* fix: goimport format

* fix(lint): removes unused funcs

* fix(lint): removes deprecated io/ioutil

* fix(lint): disables staticcheck for federation tests

it requires at least two clusters to make sense

* fix(lint): use anypb.UnmarshalTo instead of ptypes

* fix: no need to exclude grpcgen_test.go

it seems to be fixed in v1.39

see: grpc/grpc-go#4476

* chore(backoff): aligns backoff dependency with v4 used by upstream

* chore: reverts removed blank line - irrelevant for merge

* chore(revive): adds explanation why json:inline is skipped from linting

* OSSM-1962: Use EndpointSlices instead of Endpoints in federation controller (maistra#614)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2049: Fix handling ServiceAccounts in federation controller (maistra#627)

* Fix collecting empty or repeated ServiceAccounts in federation controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Collect ServiceAccounts in sorted order

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1093 Shorten exported resource name (maistra#653)

* Shorten exported resource name

* Fix import createResourceName + unit tests

* Rearrange unit tests + renaming function

* Gen and lint

* Rearrange unit tests + renaming function

Gen and lint

* Fix minor changes

* Error message RFC 1123

* Reorganize structs in TestStatusManager

Instead of having three arrays (events, expectedStatuses, and assertions), we now only have a single array, where each entry is a triplet containing the event, the expected status and the assertion. This allows you to see the event and its expected effects together and not have to scroll up and down, matching the indexes of the three arrays.

* OSSM-2193 Fix flaky TestStatusManager

See comment in https://issues.redhat.com/browse/OSSM-2193 to understand why this change fixes the test.

* fix: runs make gen

* chore: explains why staticcheck linter is disabled for federation_test

* OSSM-728 Configuration scripts for Federation on Z and P, and bare metal (maistra#670)

* add config example scripts for IBM Systems Z and P

* update multi-arch bookinfo deployment README, remove src

* Update README.md

* these are provided in the IBM repo

* so README.md passes mdlinter

* so README.md passes mdlinter

* so README.md passes mdlinter

* Update README.md

* Move federation examples to samples/ directory

* Rename template YAMLs to .yaml.template

This makes the linter happy

Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

* chore: removes obsolute TODO

* chore: simplifies bool return expression

* chore: removes redundant kubeClient check

if initialization fails this func will not be reached anyway

* chore(pkg): moves kube ctrl under servicemesh pkg folder

* OSSM-2338: Remove env ISTIO_META_ROUTER_MODE from federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2338: Remove "routerMode: sni-dnat" from federation samples

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fix: adds operator.go customizations to kube.go

clearly with cherry-pick we lost information about the file rename and thus
the changes we made specificually for testing federation got lost

* fix(test/operator): checks if east-west gw needs to be deployed

* fix(federation): uses Unwrap to get instance of Federation registry

* fix(tests): sets istiod-less remote flag to false

that was the behaviour for maistra-2.3 and we need istiod to be present in order to have federation working

* chore: gets registry just before it is needed

* chore: explains why istiodlessremotes is needed to be set to false

* chore: removes redundant import aliases

* chore: removes name collisions

* chore: removes redundant type conversion

* fix: disables staticcheck linter for cluster req tests.

* fix(tests): reverts timeout to original (but in minutes)

* fix(tests): removes extra logging

* chore: removes unnecessary logging

* fix: uses existing CRD file references in charts

* chore: removes multicluster label

* chore: uses built-in namespace.NewOrFail instead of our impl

* chore: introduces defaultTimeout const for federation tests

* fix(lint): fixes go imports

* fix(lint): removes unused variable

* fix: naively wait 5s hoping that kind network will show up

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Jacek Ewertowski <jewertow@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
Co-authored-by: bmangoen <bmangoen@redhat.com>
Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>
jewertow added a commit to jewertow/istio that referenced this pull request Sep 7, 2023
maistra#699)

* [federation] Introduces federation deployment (maistra#585)

* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>

* fix: removes deprecated gogo protobuf conversion

* fix: goimport format

* fix(lint): removes unused funcs

* fix(lint): removes deprecated io/ioutil

* fix(lint): disables staticcheck for federation tests

it requires at least two clusters to make sense

* fix(lint): use anypb.UnmarshalTo instead of ptypes

* fix: no need to exclude grpcgen_test.go

it seems to be fixed in v1.39

see: grpc/grpc-go#4476

* chore(backoff): aligns backoff dependency with v4 used by upstream

* chore: reverts removed blank line - irrelevant for merge

* chore(revive): adds explanation why json:inline is skipped from linting

* OSSM-1962: Use EndpointSlices instead of Endpoints in federation controller (maistra#614)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2049: Fix handling ServiceAccounts in federation controller (maistra#627)

* Fix collecting empty or repeated ServiceAccounts in federation controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Collect ServiceAccounts in sorted order

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1093 Shorten exported resource name (maistra#653)

* Shorten exported resource name

* Fix import createResourceName + unit tests

* Rearrange unit tests + renaming function

* Gen and lint

* Rearrange unit tests + renaming function

Gen and lint

* Fix minor changes

* Error message RFC 1123

* Reorganize structs in TestStatusManager

Instead of having three arrays (events, expectedStatuses, and assertions), we now only have a single array, where each entry is a triplet containing the event, the expected status and the assertion. This allows you to see the event and its expected effects together and not have to scroll up and down, matching the indexes of the three arrays.

* OSSM-2193 Fix flaky TestStatusManager

See comment in https://issues.redhat.com/browse/OSSM-2193 to understand why this change fixes the test.

* fix: runs make gen

* chore: explains why staticcheck linter is disabled for federation_test

* OSSM-728 Configuration scripts for Federation on Z and P, and bare metal (maistra#670)

* add config example scripts for IBM Systems Z and P

* update multi-arch bookinfo deployment README, remove src

* Update README.md

* these are provided in the IBM repo

* so README.md passes mdlinter

* so README.md passes mdlinter

* so README.md passes mdlinter

* Update README.md

* Move federation examples to samples/ directory

* Rename template YAMLs to .yaml.template

This makes the linter happy

Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

* chore: removes obsolute TODO

* chore: simplifies bool return expression

* chore: removes redundant kubeClient check

if initialization fails this func will not be reached anyway

* chore(pkg): moves kube ctrl under servicemesh pkg folder

* OSSM-2338: Remove env ISTIO_META_ROUTER_MODE from federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2338: Remove "routerMode: sni-dnat" from federation samples

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fix: adds operator.go customizations to kube.go

clearly with cherry-pick we lost information about the file rename and thus
the changes we made specificually for testing federation got lost

* fix(test/operator): checks if east-west gw needs to be deployed

* fix(federation): uses Unwrap to get instance of Federation registry

* fix(tests): sets istiod-less remote flag to false

that was the behaviour for maistra-2.3 and we need istiod to be present in order to have federation working

* chore: gets registry just before it is needed

* chore: explains why istiodlessremotes is needed to be set to false

* chore: removes redundant import aliases

* chore: removes name collisions

* chore: removes redundant type conversion

* fix: disables staticcheck linter for cluster req tests.

* fix(tests): reverts timeout to original (but in minutes)

* fix(tests): removes extra logging

* chore: removes unnecessary logging

* fix: uses existing CRD file references in charts

* chore: removes multicluster label

* chore: uses built-in namespace.NewOrFail instead of our impl

* chore: introduces defaultTimeout const for federation tests

* fix(lint): fixes go imports

* fix(lint): removes unused variable

* fix: naively wait 5s hoping that kind network will show up

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Jacek Ewertowski <jewertow@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
Co-authored-by: bmangoen <bmangoen@redhat.com>
Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>
jewertow added a commit to jewertow/istio that referenced this pull request Sep 7, 2023
maistra#699)

* [federation] Introduces federation deployment (maistra#585)

* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>

* fix: removes deprecated gogo protobuf conversion

* fix: goimport format

* fix(lint): removes unused funcs

* fix(lint): removes deprecated io/ioutil

* fix(lint): disables staticcheck for federation tests

it requires at least two clusters to make sense

* fix(lint): use anypb.UnmarshalTo instead of ptypes

* fix: no need to exclude grpcgen_test.go

it seems to be fixed in v1.39

see: grpc/grpc-go#4476

* chore(backoff): aligns backoff dependency with v4 used by upstream

* chore: reverts removed blank line - irrelevant for merge

* chore(revive): adds explanation why json:inline is skipped from linting

* OSSM-1962: Use EndpointSlices instead of Endpoints in federation controller (maistra#614)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2049: Fix handling ServiceAccounts in federation controller (maistra#627)

* Fix collecting empty or repeated ServiceAccounts in federation controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Collect ServiceAccounts in sorted order

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1093 Shorten exported resource name (maistra#653)

* Shorten exported resource name

* Fix import createResourceName + unit tests

* Rearrange unit tests + renaming function

* Gen and lint

* Rearrange unit tests + renaming function

Gen and lint

* Fix minor changes

* Error message RFC 1123

* Reorganize structs in TestStatusManager

Instead of having three arrays (events, expectedStatuses, and assertions), we now only have a single array, where each entry is a triplet containing the event, the expected status and the assertion. This allows you to see the event and its expected effects together and not have to scroll up and down, matching the indexes of the three arrays.

* OSSM-2193 Fix flaky TestStatusManager

See comment in https://issues.redhat.com/browse/OSSM-2193 to understand why this change fixes the test.

* fix: runs make gen

* chore: explains why staticcheck linter is disabled for federation_test

* OSSM-728 Configuration scripts for Federation on Z and P, and bare metal (maistra#670)

* add config example scripts for IBM Systems Z and P

* update multi-arch bookinfo deployment README, remove src

* Update README.md

* these are provided in the IBM repo

* so README.md passes mdlinter

* so README.md passes mdlinter

* so README.md passes mdlinter

* Update README.md

* Move federation examples to samples/ directory

* Rename template YAMLs to .yaml.template

This makes the linter happy

Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

* chore: removes obsolute TODO

* chore: simplifies bool return expression

* chore: removes redundant kubeClient check

if initialization fails this func will not be reached anyway

* chore(pkg): moves kube ctrl under servicemesh pkg folder

* OSSM-2338: Remove env ISTIO_META_ROUTER_MODE from federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2338: Remove "routerMode: sni-dnat" from federation samples

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fix: adds operator.go customizations to kube.go

clearly with cherry-pick we lost information about the file rename and thus
the changes we made specificually for testing federation got lost

* fix(test/operator): checks if east-west gw needs to be deployed

* fix(federation): uses Unwrap to get instance of Federation registry

* fix(tests): sets istiod-less remote flag to false

that was the behaviour for maistra-2.3 and we need istiod to be present in order to have federation working

* chore: gets registry just before it is needed

* chore: explains why istiodlessremotes is needed to be set to false

* chore: removes redundant import aliases

* chore: removes name collisions

* chore: removes redundant type conversion

* fix: disables staticcheck linter for cluster req tests.

* fix(tests): reverts timeout to original (but in minutes)

* fix(tests): removes extra logging

* chore: removes unnecessary logging

* fix: uses existing CRD file references in charts

* chore: removes multicluster label

* chore: uses built-in namespace.NewOrFail instead of our impl

* chore: introduces defaultTimeout const for federation tests

* fix(lint): fixes go imports

* fix(lint): removes unused variable

* fix: naively wait 5s hoping that kind network will show up

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Jacek Ewertowski <jewertow@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
Co-authored-by: bmangoen <bmangoen@redhat.com>
Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>
jewertow pushed a commit to jewertow/istio that referenced this pull request Sep 11, 2023
maistra#699)

* [federation] Introduces federation deployment (maistra#585)

* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (maistra#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (maistra#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (maistra#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (maistra#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (maistra#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (maistra#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (maistra#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (maistra#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (maistra#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (maistra#422)

MAISTRA-2297 Support updates of federation resources (maistra#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (maistra#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (maistra#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (maistra#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (maistra#440)

Log actual error returned by pollServices() (maistra#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (maistra#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (maistra#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (maistra#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (maistra#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (maistra#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (maistra#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (maistra#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (maistra#521)

* OSSM-1529 Improve federation example script (maistra#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (maistra#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>

* fix: removes deprecated gogo protobuf conversion

* fix: goimport format

* fix(lint): removes unused funcs

* fix(lint): removes deprecated io/ioutil

* fix(lint): disables staticcheck for federation tests

it requires at least two clusters to make sense

* fix(lint): use anypb.UnmarshalTo instead of ptypes

* fix: no need to exclude grpcgen_test.go

it seems to be fixed in v1.39

see: grpc/grpc-go#4476

* chore(backoff): aligns backoff dependency with v4 used by upstream

* chore: reverts removed blank line - irrelevant for merge

* chore(revive): adds explanation why json:inline is skipped from linting

* OSSM-1962: Use EndpointSlices instead of Endpoints in federation controller (maistra#614)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2049: Fix handling ServiceAccounts in federation controller (maistra#627)

* Fix collecting empty or repeated ServiceAccounts in federation controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Collect ServiceAccounts in sorted order

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1093 Shorten exported resource name (maistra#653)

* Shorten exported resource name

* Fix import createResourceName + unit tests

* Rearrange unit tests + renaming function

* Gen and lint

* Rearrange unit tests + renaming function

Gen and lint

* Fix minor changes

* Error message RFC 1123

* Reorganize structs in TestStatusManager

Instead of having three arrays (events, expectedStatuses, and assertions), we now only have a single array, where each entry is a triplet containing the event, the expected status and the assertion. This allows you to see the event and its expected effects together and not have to scroll up and down, matching the indexes of the three arrays.

* OSSM-2193 Fix flaky TestStatusManager

See comment in https://issues.redhat.com/browse/OSSM-2193 to understand why this change fixes the test.

* fix: runs make gen

* chore: explains why staticcheck linter is disabled for federation_test

* OSSM-728 Configuration scripts for Federation on Z and P, and bare metal (maistra#670)

* add config example scripts for IBM Systems Z and P

* update multi-arch bookinfo deployment README, remove src

* Update README.md

* these are provided in the IBM repo

* so README.md passes mdlinter

* so README.md passes mdlinter

* so README.md passes mdlinter

* Update README.md

* Move federation examples to samples/ directory

* Rename template YAMLs to .yaml.template

This makes the linter happy

Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

* chore: removes obsolute TODO

* chore: simplifies bool return expression

* chore: removes redundant kubeClient check

if initialization fails this func will not be reached anyway

* chore(pkg): moves kube ctrl under servicemesh pkg folder

* OSSM-2338: Remove env ISTIO_META_ROUTER_MODE from federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2338: Remove "routerMode: sni-dnat" from federation samples

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fix: adds operator.go customizations to kube.go

clearly with cherry-pick we lost information about the file rename and thus
the changes we made specificually for testing federation got lost

* fix(test/operator): checks if east-west gw needs to be deployed

* fix(federation): uses Unwrap to get instance of Federation registry

* fix(tests): sets istiod-less remote flag to false

that was the behaviour for maistra-2.3 and we need istiod to be present in order to have federation working

* chore: gets registry just before it is needed

* chore: explains why istiodlessremotes is needed to be set to false

* chore: removes redundant import aliases

* chore: removes name collisions

* chore: removes redundant type conversion

* fix: disables staticcheck linter for cluster req tests.

* fix(tests): reverts timeout to original (but in minutes)

* fix(tests): removes extra logging

* chore: removes unnecessary logging

* fix: uses existing CRD file references in charts

* chore: removes multicluster label

* chore: uses built-in namespace.NewOrFail instead of our impl

* chore: introduces defaultTimeout const for federation tests

* fix(lint): fixes go imports

* fix(lint): removes unused variable

* fix: naively wait 5s hoping that kind network will show up

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Jacek Ewertowski <jewertow@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
Co-authored-by: bmangoen <bmangoen@redhat.com>
Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

OSSM-2376: Move kube controller to the federation package (maistra#718)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

OSSM-2376: Don't start federation controllers until informers have synced (maistra#717) (maistra#720)

* OSSM-2376: Don't start federation-discovery-controller until kube informer has synced

Federation discovery controller fetches config map with remote CA root
cert, so if the controller started before the informer has synced, it
would fail to fetch the config map.

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Store ConfigMap informer in a field of the discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Refactor ResourceManager and don't start federation controller until informers has synced

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Simplify Start and HasSynced functions in federation controllers

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Move kube controller to the federation package

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Federation example fixes (maistra#758)

* Use default version in federation example SMCPs

* Fix paths in federation example

OSSM-3599 Federation egress-gateway gets wrong network gateway endpoints (maistra#775)

* OSSM-3599 Federation egress-gateway gets wrong update of network gateway endpoints

* Deprecate GatewayEndpoints on server side

* Remove resyncNetworkGateways in unit tests

* Fix lint

* Deprecate NetworkGatewayEndpoints and fix tests

Refactor federation tests (maistra#841)

* Refactor federation tests

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add more test cases

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

---------

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
openshift-merge-robot pushed a commit that referenced this pull request Sep 11, 2023
* [federation] Introduces federation deployment (#585)

* [federation] Initial federation implementation

* MAISTRA-2194 Add server/client code for Federation Service Discovery v1

* MAISTRA-2195 Implement /watch endpoint

* MAISTRA-2293 add CRD and controller for federating meshes

* MAISTRA-2294 create CRD for federation ServiceExport (#324)

* MAISTRA-2294 update example VirtualService resources for ratings and mongodb (#333)

* [federation] MAISTRA-2295 create CRD for federation ServiceImport (#336)

Signed-off-by: rcernich <rcernich@redhat.com>

* [misc] Use objects and clients from maistra/api repo

- Remove local objects and clients
- Update Makefile

* [federation] MAISTRA-2309 create CRD for FederationStatus (#348)

Signed-off-by: rcernich <rcernich@redhat.com>

* [federation] Federation fixes and improvements

MAISTRA-2423 update federation api to v1

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2424 minor updates to federation api

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2427 configure locality info on imported services

Signed-off-by: rcernich <rcernich@redhat.com>

Cherry-pick multi-root support (#387)

* Update go-control-plane to v0.9.9

* Support multiple roots

Squashed commit, contains:
- MAISTRA-2325 Distribute trust bundles over SDS
- MAISTRA-2390 Push trust bundle updates through xDS (#357)

MAISTRA-2425 move spec.security.certificateChain to ConfigMap reference; add ability to specify ports for service and discovery (#392)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2426 move FederationStatus into MeshFederation (#393)

Signed-off-by: rcernich <rcernich@redhat.com>

MAISTRA-2513 federation API refinements

Signed-off-by: rcernich <rcernich@redhat.com>

[federation] MAISTRA-2237 Encrypt service discovery traffic (#411)

MAISTRA-2610 Prefix federation discovery endpoints with /v1/ (#422)

MAISTRA-2297 Support updates of federation resources (#417)

MAISTRA-2375: Do not create automatic routes for Federation Gateways

Remove a redundant call

`setHostname()` is already being called within `NameForService()`

see
https://github.com/maistra/istio/blob/21ee900cf8825711f70d88dc97afcf6862ed2626/pkg/servicemesh/federation/common/namemapping.go
lines 83, 120, 129

Remove techPreview.meshConfig from PoC example

It's set by default now.

MAISTRA-2611 Fix deletion of service exports to federated mesh (#421)

Fix test

MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil (#437)

* MAISTRA-2658 Ensure ImportedServiceSet.status.importedServices is never nil

* Fix test

MAISTRA-2682 Fix watch mechanism in federation (#439)

Previously, no events were read from the watch response, because the read started with an endless loop that waited for data to be available in the decoder's buffer. This never happened, because the buffer is only written to when you call decoder.Decode(); this function was never called because the code waited for the buffer to have data.

MAISTRA-2683 Properly close incoming watch connections when shutting down (#440)

Log actual error returned by pollServices() (#441)

Previously, instead of the actual error, only the following error message was logged: "expected condition not met".

MAISTRA-2439: Prevent federation from exporting services that are not visible to the federation gateway (#432)

By taking into consideration the service annotation
`networking.istio.io/exportTo`.

This annotation restricts where this service is visible: https://istio.io/latest/docs/reference/config/annotations/

If a service is not reachable from the federation gateway namespace due
to this annotation, it should not be exported.

MAISTRA-2617: Do not watch all namespaces in Extensions controller (#425)

When using MemberRoll, we should rely on it to provide the list
of namespaces to watch. If not using it, defaults to command line
arguments.

This fixes an istiod startup error as seen in the logs:
```
github.com/maistra/xns-informer/pkg/informers/informer.go:204: Failed to watch *v1.ServiceMeshExtension: failed to list *v1.ServiceMeshExtension: servicemeshextensions.maistra.io is forbidden: User "system:serviceaccount:i1:istiod-service-account-basic" cannot list resource "servicemeshextensions" in API group "maistra.io" at the cluster scope
```

* Remove package export and extensions

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix creating discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix calling nil ResourceManager

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove panicing from AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [misc] OSSM-774 Fix flaky TestStatusManager (#456)

This adds a little sleep to our unit tests for the StatusManager,
because without it, we're running into the issue that we're updating
a ServiceMeshPeer's status very quickly, and in some cases it might be
that the last change has not been propagated when we're generating
the patch for the next status change, which can lead to failures.

This can happen in the real world, but you would need to change a
ServiceMeshPeer's status within a few milliseconds, I doubt that it
affects users. It would also be fixed with the next status update.
For those reasons, I'm only fixing it in the test, with a Sleep()
call.

* Refactor manager_test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1150 Fix flaky TestStatusManager unit test (#478)

Co-authored-by: Marko Lukša <marko.luksa@gmail.com>

* OSSM-1252 Fix federation status updates (#512)

* Copy federation privileges from base to istio-discovery

* Remove unnecessary ServiceMeshExtensions CRD

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add model.NetworkGatewaysHandler to federation controller to implement AppendNetworkGatewayHandler

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] MAISTRA-2640 Add federation integration test (#447)

* Fix building federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add package gogo from maistra-2.2 to temporarily fix TbdsGenerator

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable configuring remote cluster in federation deployment

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* [federation] OSSM-1128 Fix federation (#480)

* Fix SecretCacheClient

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Send initial XDS request for trust bundle from proxy

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Disable using EndpointSlices to fix error on getting federation-egress endpoints

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Remove unused serviceMeshExtensionController

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Fix lint errors

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Update maistra CRDs

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fedration_cp_version_update (#521)

* OSSM-1529 Improve federation example script (#522)

* OSSM-1529 Improve federation example install.sh

Previously, the script would fall back to using nodeports when the load balancer IP wasn't set. This meant that if the provision of the load balancer took too long, the SMCPs would be misconfigured and you had to run the install script again.

With this change, the script now waits for the load balancer IP to appear. It never falls back to using node ports, because they never really worked (the nodes' hostnames typically aren't FQDN and the node ports are typically protected by firewalls).

If the user wants to expose the federation ingresses in a different way, they can now set the environment variables MESH1_ADDRESS, MESH1_DISCOVERY_PORT, and MESH2_SERVICE_PORT (likewise for MESH2) and run the script.

* Update Federation example README

* Better "Waiting for load balancer" message

* OSSM-1211 Fix federation locality failover issues (#561)

Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>

* fix: removes deprecated gogo protobuf conversion

* fix: goimport format

* fix(lint): removes unused funcs

* fix(lint): removes deprecated io/ioutil

* fix(lint): disables staticcheck for federation tests

it requires at least two clusters to make sense

* fix(lint): use anypb.UnmarshalTo instead of ptypes

* fix: no need to exclude grpcgen_test.go

it seems to be fixed in v1.39

see: grpc/grpc-go#4476

* chore(backoff): aligns backoff dependency with v4 used by upstream

* chore: reverts removed blank line - irrelevant for merge

* chore(revive): adds explanation why json:inline is skipped from linting

* OSSM-1962: Use EndpointSlices instead of Endpoints in federation controller (#614)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2049: Fix handling ServiceAccounts in federation controller (#627)

* Fix collecting empty or repeated ServiceAccounts in federation controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Collect ServiceAccounts in sorted order

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-1093 Shorten exported resource name (#653)

* Shorten exported resource name

* Fix import createResourceName + unit tests

* Rearrange unit tests + renaming function

* Gen and lint

* Rearrange unit tests + renaming function

Gen and lint

* Fix minor changes

* Error message RFC 1123

* Reorganize structs in TestStatusManager

Instead of having three arrays (events, expectedStatuses, and assertions), we now only have a single array, where each entry is a triplet containing the event, the expected status and the assertion. This allows you to see the event and its expected effects together and not have to scroll up and down, matching the indexes of the three arrays.

* OSSM-2193 Fix flaky TestStatusManager

See comment in https://issues.redhat.com/browse/OSSM-2193 to understand why this change fixes the test.

* fix: runs make gen

* chore: explains why staticcheck linter is disabled for federation_test

* OSSM-728 Configuration scripts for Federation on Z and P, and bare metal (#670)

* add config example scripts for IBM Systems Z and P

* update multi-arch bookinfo deployment README, remove src

* Update README.md

* these are provided in the IBM repo

* so README.md passes mdlinter

* so README.md passes mdlinter

* so README.md passes mdlinter

* Update README.md

* Move federation examples to samples/ directory

* Rename template YAMLs to .yaml.template

This makes the linter happy

Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

* chore: removes obsolute TODO

* chore: simplifies bool return expression

* chore: removes redundant kubeClient check

if initialization fails this func will not be reached anyway

* chore(pkg): moves kube ctrl under servicemesh pkg folder

* OSSM-2338: Remove env ISTIO_META_ROUTER_MODE from federation test

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* OSSM-2338: Remove "routerMode: sni-dnat" from federation samples

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* fix: adds operator.go customizations to kube.go

clearly with cherry-pick we lost information about the file rename and thus
the changes we made specificually for testing federation got lost

* fix(test/operator): checks if east-west gw needs to be deployed

* fix(federation): uses Unwrap to get instance of Federation registry

* fix(tests): sets istiod-less remote flag to false

that was the behaviour for maistra-2.3 and we need istiod to be present in order to have federation working

* chore: gets registry just before it is needed

* chore: explains why istiodlessremotes is needed to be set to false

* chore: removes redundant import aliases

* chore: removes name collisions

* chore: removes redundant type conversion

* fix: disables staticcheck linter for cluster req tests.

* fix(tests): reverts timeout to original (but in minutes)

* fix(tests): removes extra logging

* chore: removes unnecessary logging

* fix: uses existing CRD file references in charts

* chore: removes multicluster label

* chore: uses built-in namespace.NewOrFail instead of our impl

* chore: introduces defaultTimeout const for federation tests

* fix(lint): fixes go imports

* fix(lint): removes unused variable

* fix: naively wait 5s hoping that kind network will show up

Signed-off-by: rcernich <rcernich@redhat.com>
Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Signed-off-by: Yuanlin <yuanlin.xu@redhat.com>
Co-authored-by: Jacek Ewertowski <jewertow@redhat.com>
Co-authored-by: Daniel Grimm <dgrimm@redhat.com>
Co-authored-by: Rob Cernich <rcernich@redhat.com>
Co-authored-by: Jonh Wendell <jonh.wendell@redhat.com>
Co-authored-by: maistra-bot <57098434+maistra-bot@users.noreply.github.com>
Co-authored-by: Marko Lukša <marko.luksa@gmail.com>
Co-authored-by: Praneeth Bajjuri <pbajjuri@redhat.com>
Co-authored-by: Yuanlin Xu <xuyuanlin_00@hotmail.com>
Co-authored-by: bmangoen <bmangoen@redhat.com>
Co-authored-by: cfillekes <cfilleke@redhat.com>
Co-authored-by: Cheryl Fillekes <cfillekes@ibm.com>

OSSM-2376: Move kube controller to the federation package (#718)

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

OSSM-2376: Don't start federation controllers until informers have synced (#717) (#720)

* OSSM-2376: Don't start federation-discovery-controller until kube informer has synced

Federation discovery controller fetches config map with remote CA root
cert, so if the controller started before the informer has synced, it
would fail to fetch the config map.

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Store ConfigMap informer in a field of the discovery.Controller

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Refactor ResourceManager and don't start federation controller until informers has synced

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Simplify Start and HasSynced functions in federation controllers

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Move kube controller to the federation package

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

Federation example fixes (#758)

* Use default version in federation example SMCPs

* Fix paths in federation example

OSSM-3599 Federation egress-gateway gets wrong network gateway endpoints (#775)

* OSSM-3599 Federation egress-gateway gets wrong update of network gateway endpoints

* Deprecate GatewayEndpoints on server side

* Remove resyncNetworkGateways in unit tests

* Fix lint

* Deprecate NetworkGatewayEndpoints and fix tests

Refactor federation tests (#841)

* Refactor federation tests

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

* Add more test cases

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>

---------

Signed-off-by: Jacek Ewertowski <jewertow@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants