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

multiple instances support for grpc broker. #235

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

morvencao
Copy link
Contributor

@morvencao morvencao commented Dec 18, 2024

@clyang82
Copy link
Contributor

/ok-to-test

@morvencao
Copy link
Contributor Author

morvencao commented Dec 18, 2024

/hold

depends on #232

@morvencao morvencao force-pushed the br_grpc_ha branch 5 times, most recently from 1ce55ab to 580601f Compare December 18, 2024 11:07
// check if all instances have processed the event
if !compareStrings(activeInstances, eventInstances) {
klog.V(10).Infof("Event %s is not processed by all instances, handled by %v, active instances %v", event.ID, eventInstances, activeInstances)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need requeue here (return an error)? or there are some processes can retrigger this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, reconcileDate is not set, the 'SyncEvent' will trigger event be processed again?

If we return an error here, the current instance will process the event again, but the event may not be handled by other instances. so return an error doesn't help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking maybeactiveInstances is_subset_of eventInstances make more sense?

Copy link
Contributor

@skeeey skeeey Dec 19, 2024

Choose a reason for hiding this comment

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

If we return an error here, the current instance will process the event again, but the event may not be handled by other instances. so return an error doesn't help.

so this means the ReconciledDate will be marked finally by the the "last" instance, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I added some comments to explain different cases.

if svcErr != nil {
// if the resource is not found, it indicates the resource has been handled by
// other instances, so we can mark the event as reconciled and ignore it.
if svcErr.Is404() {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a log here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

log added.

@morvencao morvencao force-pushed the br_grpc_ha branch 2 times, most recently from 1c1601c to 1e1e107 Compare December 20, 2024 10:18
@morvencao morvencao force-pushed the br_grpc_ha branch 4 times, most recently from 281ccd4 to acaa814 Compare December 23, 2024 14:19
}

klog.V(4).Infof("send the event to spec subscribers, %s", evt)

// WARNING: don't use "pbEvt, err := pb.ToProto(evt)" to convert cloudevent to protobuf
pbEvt := &pbv1.CloudEvent{}
if err = grpcprotocol.WritePBMessage(context.TODO(), binding.ToMessage(evt), pbEvt); err != nil {
return fmt.Errorf("failed to convert cloudevent to protobuf: %v", err)
klog.Errorf("failed to convert cloudevent to protobuf: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

also record the resource ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants