-
Notifications
You must be signed in to change notification settings - Fork 72
[Feature] [Platform] EventsV1 Integration #1977
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
04386e4
[Feature] [Platform] EventsV1 Integration
ajanikow 973ee98
Fix IT
ajanikow 47517bc
Iter
ajanikow 3ff54f9
Iter
ajanikow 59c58ed
Iter
ajanikow a7e7416
Iter
ajanikow 929dace
Iter
ajanikow 61b951a
Iter
ajanikow 6835a15
Iter
ajanikow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| layout: page | ||
| title: Integration Sidecar Meta V1 | ||
| grand_parent: ArangoDBPlatform | ||
| parent: Integration Sidecars | ||
| --- | ||
|
|
||
| # Events V1 | ||
|
|
||
| Definitions: | ||
|
|
||
| - [Service](https://github.com/arangodb/kube-arangodb/blob/1.3.1/integrations/events/v1/definition/definition.proto) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| layout: page | ||
| title: MinIO | ||
| parent: Storage | ||
| grand_parent: ArangoDBPlatform | ||
| nav_order: 3 | ||
| --- | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| layout: page | ||
| title: AWS S3 | ||
| parent: Storage | ||
| grand_parent: ArangoDBPlatform | ||
| nav_order: 1 | ||
| --- | ||
|
|
||
|
|
||
6 changes: 3 additions & 3 deletions
6
integrations/authentication/v1/definition/definition.pb.gw.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| // | ||
| // DISCLAIMER | ||
| // | ||
| // Copyright 2025 ArangoDB GmbH, Cologne, Germany | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| // Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
| // | ||
|
|
||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| "github.com/pkg/errors" | ||
| "google.golang.org/protobuf/proto" | ||
|
|
||
| "github.com/arangodb/kube-arangodb/pkg/util/globals" | ||
| ) | ||
|
|
||
| func WithAsync[IN proto.Message, H RemoteStore[IN]](in H, size int, timeout time.Duration, delay time.Duration) RemoteStore[IN] { | ||
| return &asyncRemoteWriter[IN, H]{ | ||
| upstream: in, | ||
| cache: make(chan []IN, size), | ||
| timeout: timeout, | ||
| delay: delay, | ||
| } | ||
| } | ||
|
|
||
| type asyncRemoteWriter[IN proto.Message, H RemoteStore[IN]] struct { | ||
| upstream H | ||
|
|
||
| cache chan []IN | ||
|
|
||
| timeout time.Duration | ||
| delay time.Duration | ||
| } | ||
|
|
||
| func (a *asyncRemoteWriter[IN, H]) Init(ctx context.Context) error { | ||
| return a.upstream.Init(ctx) | ||
| } | ||
|
|
||
| func (a *asyncRemoteWriter[IN, H]) Background(ctx context.Context) { | ||
| logger.Info("Async background started") | ||
| defer func() { | ||
| logger.Info("Async background completed") | ||
| }() | ||
|
|
||
| for { | ||
| select { | ||
| case <-ctx.Done(): | ||
| close(a.cache) | ||
| for events := range a.cache { | ||
| // Cleanup the queue | ||
| a.emitEvents(events...) | ||
| } | ||
| return | ||
| case events := <-a.cache: | ||
| a.emitEvents(events...) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func (a *asyncRemoteWriter[IN, H]) emitEvents(events ...IN) { | ||
| if len(events) == 0 { | ||
| return | ||
| } | ||
|
|
||
| timeoutTimer := time.NewTimer(a.timeout) | ||
| defer timeoutTimer.Stop() | ||
|
|
||
| delayTimer := time.NewTicker(a.delay) | ||
| defer delayTimer.Stop() | ||
|
|
||
| for { | ||
| err := globals.GetGlobals().Timeouts().ArangoD().RunWithTimeout(context.Background(), func(ctxChild context.Context) error { | ||
| return a.upstream.Emit(ctxChild, events...) | ||
| }) | ||
| if err != nil { | ||
| logger.Err(err).Warn("Unable to send events batch, retry") | ||
| } else { | ||
| logger.Debug("Batch sent") | ||
| return | ||
| } | ||
|
|
||
| select { | ||
| case <-delayTimer.C: | ||
| continue | ||
| case <-timeoutTimer.C: | ||
| logger.Error("Unable to send events in expected time") | ||
| return | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| func (a *asyncRemoteWriter[IN, H]) Emit(ctx context.Context, events ...IN) error { | ||
| if len(events) == 0 { | ||
| return nil | ||
| } | ||
|
|
||
| timeout := time.NewTimer(time.Second) | ||
| defer timeout.Stop() | ||
|
|
||
| select { | ||
| case a.cache <- events: | ||
| return nil | ||
| case <-timeout.C: | ||
| return errors.Errorf("timeout waiting for events to be scheduled") | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // | ||
| // DISCLAIMER | ||
| // | ||
| // Copyright 2025 ArangoDB GmbH, Cologne, Germany | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| // Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
| // | ||
|
|
||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| "github.com/arangodb/go-driver/v2/arangodb" | ||
|
|
||
| "github.com/arangodb/kube-arangodb/pkg/util/cache" | ||
| ) | ||
|
|
||
| func withTTLIndex(in cache.Object[arangodb.Collection]) cache.Object[arangodb.Collection] { | ||
| return cache.NewObject(func(ctx context.Context) (arangodb.Collection, time.Duration, error) { | ||
| col, err := in.Get(ctx) | ||
| if err != nil { | ||
| return nil, 0, err | ||
| } | ||
|
|
||
| if _, _, err := col.EnsureTTLIndex(ctx, []string{"created"}, int(DefaultTTL/time.Second), &arangodb.CreateTTLIndexOptions{ | ||
| Name: "system_events_created_ttl_index", | ||
| }); err != nil { | ||
| return nil, 0, err | ||
| } | ||
|
|
||
| return col, time.Hour, nil | ||
| }) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Goroutine Leak in Background Method
The Background method has a race condition. When ctx is cancelled, the goroutine (line 61-64) closes a.cache, causing the for-range loop to exit. However, if a.emitEvents() is currently blocked in the select statement (lines 80-94) waiting for a response, it will continue running after Background() returns. This can lead to background goroutines continuing to execute after the context is cancelled and the Background handler has already returned, which is a violation of the Background handler contract. The delay parameter (line 48) is also never used.