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

NSP Target Registry chained server #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

NSP Target Registry chained server #258

wants to merge 1 commit into from

Conversation

LionelJouin
Copy link
Member

@LionelJouin LionelJouin commented Jul 28, 2022

Description

  • New target registry server pattern allowing future feature, e.g.:
    • Logger / Metrics / Trace
    • KeepAlive
    • NSP multi-replicas support
  • Current chain: watch handler -> store (sqlite + keepalive)

note: if this PR get accepted I will implement the same pattern for other APIs (TAPA, IPAM, NSP Configuration manager)

Issue link

/

Checklist

  • Purpose
    • Bug fix
    • New functionality
    • Documentation
    • Refactoring
    • CI
  • Test
    • Unit test
    • E2E Test
    • Tested manually
  • Introduce a breaking change
    • Yes (description required)
    • No
  • Introduce changes in the Operator
    • Yes (description required)
    • No

* New target registry server pattern allowing future feature
* Current chain: watch handler -> store (sqlite + keepalive)
return nil, errors.Wrap(err, "Unable create keepalive registry")
}
return nsp.NewServer(
nspRegistry.NewServer(keepAliveRegistry),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Separation of nspRegistry and watchhandler seems forced to me. They both rely on the same keepAliveRegistry.

@zolug
Copy link
Collaborator

zolug commented Sep 1, 2022

What does "NSP multi-replicas support" stand for?


// Watch will call the Watch function of the next chain element
// If the next element is nil, then nil will be returned.
func (ntrsi *NextTargetRegistryServerImpl) Watch(t *nspAPI.Target, watcher nspAPI.TargetRegistry_WatchServer) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably this is similar to NSM's Monitor thingy, but it seems only one chain entry is allowed to implement a "real" Watch function as it needs to block forever. This is probably not an issue, but easy to make mistakes if the user is not aware :)

(Also, I read somewhere that grpc streams are not thread-safe. So, for example let's say the backend i.e the db was partitioned. Then letting loose multiple go routines wouldn't work properly without synchronization. And probably it would require a special tail chain entry that would wait for the watch routines to keep the stream open.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, only one chain element would be allowed to implement the real watch function.

For the second part, do you mean we should have 1 goroutine to handle all watcher?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just meant that special care should be taken in that case, and the default chaining couldn't be used as is.

@LionelJouin
Copy link
Member Author

What does "NSP multi-replicas support" stand for?

It means we could run multiple NSP instances at the same time. For instance, we could have a leader election system, the non-leaders instances will then redirect their call towards the leader one. I think separating the server into chain elements will simplify the development of this feature.

@zolug
Copy link
Collaborator

zolug commented Sep 5, 2022

What does "NSP multi-replicas support" stand for?

It means we could run multiple NSP instances at the same time. For instance, we could have a leader election system, the non-leaders instances will then redirect their call towards the leader one. I think separating the server into chain elements will simplify the development of this feature.

I see. Not sure about the benefit of sg like that if non-leaders would merely act as proxies and we still had a persistent storage back-end. Anyways, the chaining approach could be added irrespective of any future modifications.

@uablrek uablrek removed their request for review September 7, 2022 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants