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

Feature/gen 2030 group sources to destination #2112

Open
wants to merge 219 commits into
base: feature/source-crd
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 209 commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
4469aa8
Introduce Instrumentation CRD
damemi Dec 19, 2024
28acc08
Rename to Source, remove omitempty on workload field
damemi Dec 20, 2024
58d208d
Add SourceReconciler and create InstrumentationConfig
damemi Dec 20, 2024
de6df76
Add finalizer for uninstrumentation
damemi Dec 20, 2024
db5f24b
Delete InstrumentationConfig and remove Finalizer when Source is deleted
damemi Dec 20, 2024
8d013b7
Add Sources to Instrumentor ClusterRole
damemi Dec 20, 2024
623f7d3
Add workload labels to Source
damemi Dec 20, 2024
32170a5
Update Uninstall command to delete Source finalizers
damemi Dec 20, 2024
0172989
Add logger to SourceReconciler
damemi Dec 20, 2024
bf67a30
Add Source checks to Instrumentor
damemi Dec 20, 2024
847c9c1
Introduce Instrumentation CRD
damemi Dec 19, 2024
b82625a
Rename to Source, remove omitempty on workload field
damemi Dec 20, 2024
8d72fea
Remove odigos labels
damemi Dec 23, 2024
3f3b9d0
Add SourceReconciler and create InstrumentationConfig
damemi Dec 20, 2024
f498027
Add finalizer for uninstrumentation
damemi Dec 20, 2024
e5dfb90
Delete InstrumentationConfig and remove Finalizer when Source is deleted
damemi Dec 20, 2024
8f5738a
Add Sources to Instrumentor ClusterRole
damemi Dec 20, 2024
3555a0f
Add workload labels to Source
damemi Dec 20, 2024
dfb3946
Update Uninstall command to delete Source finalizers
damemi Dec 20, 2024
596f22c
Add logger to SourceReconciler
damemi Dec 20, 2024
7d3358e
Add Source checks to Instrumentor
damemi Dec 20, 2024
69059b0
Add GetSourceListForWorkload function
damemi Dec 23, 2024
5ecfe41
Add SourceReconciler to deleteinstrumentedapplication controller
damemi Dec 23, 2024
3dd7ed5
Add SourceReconciler and create InstrumentationConfig
damemi Dec 20, 2024
dae2bd9
Add finalizer for uninstrumentation
damemi Dec 20, 2024
9ba9b57
Delete InstrumentationConfig and remove Finalizer when Source is deleted
damemi Dec 20, 2024
df8cc4f
Add Sources to Instrumentor ClusterRole
damemi Dec 20, 2024
6bfeb1d
Add workload labels to Source
damemi Dec 20, 2024
312854c
Update Uninstall command to delete Source finalizers
damemi Dec 20, 2024
9528b4b
Add logger to SourceReconciler
damemi Dec 20, 2024
378d0bf
Add Source checks to Instrumentor
damemi Dec 20, 2024
adfc696
Add GetSourceListForWorkload function
damemi Dec 23, 2024
32c3afe
Add SourceReconciler to deleteinstrumentedapplication controller
damemi Dec 23, 2024
b44f442
Enable build and e2e workflows for feature branch
damemi Dec 23, 2024
ef8f196
Add Instrumentor Sources RBAC to Helm chart
damemi Dec 23, 2024
9d7d46c
chore: init group source to destination
alonbraymok Dec 24, 2024
aecb5f6
chore: merge feature branch
alonbraymok Dec 24, 2024
fc4280d
feat: read & display "conditions" for actions
BenElferink Dec 25, 2024
7f7c2b3
fix: build error
BenElferink Dec 25, 2024
7dd99ab
chore: wip
alonbraymok Dec 25, 2024
5da3b1d
feat: add sources field with spec and status to compute platform
BenElferink Dec 25, 2024
b111f5f
Merge branch 'main' into gen-2111
BenElferink Dec 25, 2024
6b00209
Merge branch 'main' of github.com:odigos-io/odigos into sources-ui
BenElferink Dec 25, 2024
e70dd66
refactor: simplify action data structure by removing nested status
BenElferink Dec 25, 2024
3860467
Merge branch 'gen-2111' of github.com:BenElferink/odigos into sources-ui
BenElferink Dec 25, 2024
09563f1
fix: build error
BenElferink Dec 25, 2024
4016274
Merge branch 'gen-2111' of github.com:BenElferink/odigos into sources-ui
BenElferink Dec 25, 2024
70b1ed0
feat: add source management for workloads and update GraphQL queries
BenElferink Dec 25, 2024
6529165
refactor: remove sources field and related types from GraphQL schema
BenElferink Dec 25, 2024
3b522ba
refactor: simplify workload source creation and deletion logic
BenElferink Dec 25, 2024
2c6a150
fix: validate workload kind in CreateWorkloadSource function
BenElferink Dec 25, 2024
027de43
Merge branch 'source-crd' of github.com:damemi/odigos into sources-ui
BenElferink Dec 25, 2024
b281203
fix: use default namespace for creating and deleting workload sources
BenElferink Dec 25, 2024
d3ccd71
refactor: replace workload source functions with source CRD implement…
BenElferink Dec 25, 2024
762f815
Merge pull request #10 from BenElferink/sources-ui
BenElferink Dec 25, 2024
7af2640
feat: add GetSourceCRD function to retrieve source CRD by workload de…
BenElferink Dec 25, 2024
8dc557d
feat: add GetSourceCRD function to retrieve source CRD by workload de…
BenElferink Dec 25, 2024
2faf712
fix: handle case when source is not found in GetSourceCRD and remove …
BenElferink Dec 25, 2024
1e88ed0
Merge branch 'feature/source-ui' into source-ui-delete
BenElferink Dec 25, 2024
a94c150
feat: update GetSourceCRD to GetSourceCRDs for retrieving multiple so…
BenElferink Dec 26, 2024
89fa6fa
feat: implement SetWorkloadInstrumentationLabel function and update S…
BenElferink Dec 26, 2024
b2d947b
Merge branch 'main' of github.com:odigos-io/odigos into source-ui-delete
BenElferink Dec 26, 2024
746ff64
Merge branch 'main' of github.com:odigos-io/odigos into feature/sourc…
BenElferink Dec 26, 2024
4bbe6fd
Merge branch 'feature/source-ui' of github.com:BenElferink/odigos int…
BenElferink Dec 26, 2024
fe4895d
refactor: rename GetSourceCRDs to GetAllSourceCRDs and update related…
BenElferink Dec 26, 2024
5f6ee0d
Merge pull request #11 from BenElferink/source-ui-delete
BenElferink Dec 26, 2024
9136f3b
Feedback
damemi Dec 27, 2024
3ede2c7
Merge remote-tracking branch 'upstream/main' into source-crd
damemi Dec 27, 2024
bd57147
Add Source chainsaw test
damemi Dec 27, 2024
70533c2
Create common interface for instrumenteationConfig and instrumentedAp…
RonFed Dec 27, 2024
0bdfaa1
rename interface to WorkloadDetailsObject
RonFed Dec 27, 2024
9ee971d
Update comment
damemi Dec 27, 2024
c0c526e
Return SourceList by value in GetSourceListForWorkload
damemi Dec 27, 2024
df543a1
Merge branch 'source-crd' of github.com:damemi/odigos into feature/so…
BenElferink Dec 28, 2024
5036796
Add check for existing Source CRD before creation
BenElferink Dec 28, 2024
f0ad0bc
Enhance error message for existing Source CRD to include workload name
BenElferink Dec 28, 2024
1cfc83d
Add Source chainsaw test
damemi Dec 27, 2024
7bf007c
Update comment
damemi Dec 27, 2024
64cd9f1
Return SourceList by value in GetSourceListForWorkload
damemi Dec 27, 2024
14a0758
Refactor K8sActualSources resolver and clean up unused code; improve …
BenElferink Dec 28, 2024
c65f0ab
Merge branch 'source-crd' of github.com:damemi/odigos into feature/so…
BenElferink Dec 28, 2024
3efc8da
Merge branch 'instConfig_conditions' of github.com:RonFed/odigos_fork…
BenElferink Dec 28, 2024
c9a5e5a
Improve error messages in source retrieval and add workload kind vali…
BenElferink Dec 28, 2024
6bdd683
Add --nowait option to cli-install command in Makefile
BenElferink Dec 28, 2024
b5d6d55
Refactor K8sActualSource and related components to streamline data ha…
BenElferink Dec 28, 2024
086b1c8
Remove 'sources' resource from UIClusterRole permissions to refine ac…
BenElferink Dec 28, 2024
644f117
Merge branch 'feature/source-crd' into source-crd
damemi Dec 28, 2024
98d1a24
Merge branch 'source-crd' of github.com:damemi/odigos into feature/so…
BenElferink Dec 29, 2024
f40fd3c
Merge branch 'feature/source-crd' of github.com:odigos-io/odigos into…
BenElferink Dec 29, 2024
d2fa4ad
fix: build error
BenElferink Dec 29, 2024
1c9e6e9
fix: code review
BenElferink Dec 29, 2024
28fd2ad
Merge branch 'main' of github.com:odigos-io/odigos into feature/sourc…
BenElferink Dec 29, 2024
6cad06c
Merge branch 'main' of github.com:odigos-io/odigos into feature/sourc…
BenElferink Dec 29, 2024
47eebdb
Merge branch 'main' of github.com:odigos-io/odigos into feature/sourc…
BenElferink Dec 29, 2024
f23f5ce
Merge branch 'feature/source-crd' into feature/source-ui
BenElferink Dec 29, 2024
0a6cd62
fix: remove duplicates
BenElferink Dec 29, 2024
154fb4f
feat: add more status to SSE
BenElferink Dec 29, 2024
4c5a84e
feat: replace instru. apps watcher with istru. configs watcher
BenElferink Dec 29, 2024
f2aa2e1
revert pull Ron PR
BenElferink Dec 29, 2024
4ae87c1
fix: empty line
BenElferink Dec 29, 2024
c233f5b
fix: build error
BenElferink Dec 29, 2024
d12c5fc
fix: improve health status determination logic
BenElferink Dec 29, 2024
527ef33
fix: improve error messages in source management functions
BenElferink Dec 29, 2024
bd95122
fix: correct terminology for InstrumentationConfig in watchers and logs
BenElferink Dec 29, 2024
0eb35fe
fix: remove obsolete case for InstrumentedApplication in useClickNoti…
BenElferink Dec 29, 2024
9da1ae5
Merge branch 'feature/source-crd' into feature/source-ui
BenElferink Dec 29, 2024
2cfcb92
chore: init custom processor
alonbraymok Dec 30, 2024
976ad4a
chore: build collector config
alonbraymok Dec 30, 2024
638160e
feat: add CRD types and improve error message formatting
BenElferink Dec 30, 2024
afcf5ba
refactor: improve event handling and message formatting for destinati…
BenElferink Dec 30, 2024
83289a3
fix: correct message formatting in SSEMessage and improve error handl…
BenElferink Dec 30, 2024
01acd83
fix: improve message formatting for destination and instrumentation e…
BenElferink Dec 30, 2024
03de9b6
refactor: streamline error handling and notification messages across …
BenElferink Dec 30, 2024
8a6e845
refactor: rename event batcher variables for instrumentation config a…
BenElferink Dec 30, 2024
fe051d4
feat: implement event batching for destination and instrumentation in…
BenElferink Dec 30, 2024
0d426c6
feat: add hideFromHistory option to notifications and improve error m…
BenElferink Dec 30, 2024
b8374a9
refactor: update role permissions and resource names for clarity and …
BenElferink Dec 30, 2024
8cd2eea
cleanup
BenElferink Dec 30, 2024
dbaec1f
feat: enhance notification messages for action and instrumentation ru…
BenElferink Dec 30, 2024
44e36d3
cleanup
BenElferink Dec 30, 2024
dfac48c
refactor: remove instr. app from describe source
BenElferink Dec 30, 2024
c3a964e
cleanup
BenElferink Dec 30, 2024
3c59040
refactor: remove instrumented application retrieval from source resou…
BenElferink Dec 30, 2024
b62b840
refactor: remove unnecessary refetch calls in destination and source …
BenElferink Dec 30, 2024
2962545
refactor: add loading state for namespaces in sources list components
BenElferink Dec 30, 2024
6b9dabd
refactor: handle potential undefined supportedSignals in destinations…
BenElferink Dec 30, 2024
69a314a
refactor: remove unnecessary delay in redirect after destination crea…
BenElferink Dec 30, 2024
391f76f
fix: UI tests
BenElferink Dec 30, 2024
b87a13a
fix: shorter wait times in cypress test
BenElferink Dec 30, 2024
48c4570
feat: add handling for modified instrumentation configs
BenElferink Dec 30, 2024
0b1b073
fix: UI tests again
BenElferink Dec 30, 2024
9f41850
feat: mark instrumented sources when gettgin namespace
BenElferink Dec 30, 2024
bb3472f
feat: refactor source handling to allow UI to persist sources without…
BenElferink Dec 30, 2024
01ac3bb
feat: add sources field with spec and status to compute platform
BenElferink Dec 25, 2024
4eeda2c
feat: add source management for workloads and update GraphQL queries
BenElferink Dec 25, 2024
3408c18
refactor: remove sources field and related types from GraphQL schema
BenElferink Dec 25, 2024
9ac2374
refactor: simplify workload source creation and deletion logic
BenElferink Dec 25, 2024
cb4695b
fix: validate workload kind in CreateWorkloadSource function
BenElferink Dec 25, 2024
12fbcf7
Add finalizer for uninstrumentation
damemi Dec 20, 2024
056ebae
Add workload labels to Source
damemi Dec 20, 2024
3f1b7ef
Add SourceReconciler to deleteinstrumentedapplication controller
damemi Dec 23, 2024
656914d
Enable build and e2e workflows for feature branch
damemi Dec 23, 2024
2645702
fix: use default namespace for creating and deleting workload sources
BenElferink Dec 25, 2024
1ff33b0
refactor: replace workload source functions with source CRD implement…
BenElferink Dec 25, 2024
aab3fe6
feat: add GetSourceCRD function to retrieve source CRD by workload de…
BenElferink Dec 25, 2024
942da6b
fix: handle case when source is not found in GetSourceCRD and remove …
BenElferink Dec 25, 2024
30e8fa5
feat: update GetSourceCRD to GetSourceCRDs for retrieving multiple so…
BenElferink Dec 26, 2024
de9dfe1
feat: implement SetWorkloadInstrumentationLabel function and update S…
BenElferink Dec 26, 2024
30c2ddc
refactor: rename GetSourceCRDs to GetAllSourceCRDs and update related…
BenElferink Dec 26, 2024
40729dd
Feedback
damemi Dec 27, 2024
013a08e
Add check for existing Source CRD before creation
BenElferink Dec 28, 2024
beee82d
Enhance error message for existing Source CRD to include workload name
BenElferink Dec 28, 2024
40afd7f
Refactor K8sActualSources resolver and clean up unused code; improve …
BenElferink Dec 28, 2024
030534f
Create common interface for instrumenteationConfig and instrumentedAp…
RonFed Dec 27, 2024
2dddc11
rename interface to WorkloadDetailsObject
RonFed Dec 27, 2024
1d1bcba
Improve error messages in source retrieval and add workload kind vali…
BenElferink Dec 28, 2024
fbd6007
Add --nowait option to cli-install command in Makefile
BenElferink Dec 28, 2024
d5fbab8
Refactor K8sActualSource and related components to streamline data ha…
BenElferink Dec 28, 2024
5c9d44c
Remove 'sources' resource from UIClusterRole permissions to refine ac…
BenElferink Dec 28, 2024
b698f57
fix: build error
BenElferink Dec 29, 2024
0293867
fix: code review
BenElferink Dec 29, 2024
d796c4f
feat: add more status to SSE
BenElferink Dec 29, 2024
e230cbc
feat: replace instru. apps watcher with istru. configs watcher
BenElferink Dec 29, 2024
0cf2ce7
revert pull Ron PR
BenElferink Dec 29, 2024
51465e1
fix: empty line
BenElferink Dec 29, 2024
933e5b0
fix: build error
BenElferink Dec 29, 2024
4e5d8ba
fix: improve health status determination logic
BenElferink Dec 29, 2024
f3e4e6d
fix: improve error messages in source management functions
BenElferink Dec 29, 2024
0d0c27b
fix: correct terminology for InstrumentationConfig in watchers and logs
BenElferink Dec 29, 2024
bcdedba
fix: remove obsolete case for InstrumentedApplication in useClickNoti…
BenElferink Dec 29, 2024
9a78b0c
feat: add CRD types and improve error message formatting
BenElferink Dec 30, 2024
0063fd3
refactor: improve event handling and message formatting for destinati…
BenElferink Dec 30, 2024
a146201
fix: correct message formatting in SSEMessage and improve error handl…
BenElferink Dec 30, 2024
640056e
fix: improve message formatting for destination and instrumentation e…
BenElferink Dec 30, 2024
5b2fe60
refactor: streamline error handling and notification messages across …
BenElferink Dec 30, 2024
4bfe4d1
refactor: rename event batcher variables for instrumentation config a…
BenElferink Dec 30, 2024
4a82ec3
feat: implement event batching for destination and instrumentation in…
BenElferink Dec 30, 2024
2400dc9
feat: add hideFromHistory option to notifications and improve error m…
BenElferink Dec 30, 2024
b3d0bbf
refactor: update role permissions and resource names for clarity and …
BenElferink Dec 30, 2024
e5b838b
cleanup
BenElferink Dec 30, 2024
15f8c53
feat: enhance notification messages for action and instrumentation ru…
BenElferink Dec 30, 2024
bcac4b6
cleanup
BenElferink Dec 30, 2024
a103bd7
refactor: remove instr. app from describe source
BenElferink Dec 30, 2024
45b738d
cleanup
BenElferink Dec 30, 2024
da67a71
refactor: remove instrumented application retrieval from source resou…
BenElferink Dec 30, 2024
7534382
refactor: remove unnecessary refetch calls in destination and source …
BenElferink Dec 30, 2024
79293de
refactor: add loading state for namespaces in sources list components
BenElferink Dec 30, 2024
6b8c3f7
refactor: handle potential undefined supportedSignals in destinations…
BenElferink Dec 30, 2024
2f08574
refactor: remove unnecessary delay in redirect after destination crea…
BenElferink Dec 30, 2024
3371116
fix: UI tests
BenElferink Dec 30, 2024
eee8b8a
fix: shorter wait times in cypress test
BenElferink Dec 30, 2024
ed9cfdd
feat: add handling for modified instrumentation configs
BenElferink Dec 30, 2024
0cbe6d1
fix: UI tests again
BenElferink Dec 30, 2024
58431b8
feat: mark instrumented sources when gettgin namespace
BenElferink Dec 30, 2024
28b6bd2
feat: refactor source handling to allow UI to persist sources without…
BenElferink Dec 30, 2024
9a24988
Merge branch 'feature/source-ui' of github.com:BenElferink/odigos int…
BenElferink Dec 30, 2024
9777c64
Revert "Merge branch 'feature/source-ui' of github.com:BenElferink/od…
BenElferink Dec 30, 2024
3bf587a
cleanup
BenElferink Dec 30, 2024
348c308
chore: wip + pl ben fork
alonbraymok Dec 30, 2024
e0d02bd
Merge branch 'feature/source-ui' of https://github.com/BenElferink/od…
alonbraymok Dec 31, 2024
13fda7c
Merge branch 'feature/source-crd' of github.com:keyval-dev/odigos int…
alonbraymok Dec 31, 2024
3f1837c
chore: filter data base on groups and namespaces
alonbraymok Dec 31, 2024
9725d7d
chore: use labels and change mode to array
alonbraymok Jan 1, 2025
a91f4aa
chore: change processor name
alonbraymok Jan 1, 2025
76bd45a
chore: use new processor name
alonbraymok Jan 1, 2025
ba64e37
chore: match logs and metrics
alonbraymok Jan 1, 2025
e4f3a83
chore: gen-2144 performance fixes
alonbraymok Jan 1, 2025
7024a7f
chore: type fix
alonbraymok Jan 1, 2025
8056f3d
chore: add the source reconcailer
alonbraymok Jan 1, 2025
dbc89fe
chore: new labels working e2e
alonbraymok Jan 1, 2025
2fd5379
Merge branch 'feature/source-crd' of github.com:keyval-dev/odigos int…
alonbraymok Jan 1, 2025
18d971e
chore: remove dup code in make file
alonbraymok Jan 1, 2025
e393499
chore: remove dup code in make file
alonbraymok Jan 1, 2025
ff6854b
chore: fix typo
alonbraymok Jan 1, 2025
f76af08
chore: remove overhead comments"
alonbraymok Jan 1, 2025
e5572a6
chore: use util file
alonbraymok Jan 1, 2025
ff8416b
chore: remove line
alonbraymok Jan 1, 2025
fdc320f
chore: wip\
alonbraymok Jan 1, 2025
a9fd8bf
chore: wip
alonbraymok Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ cli-uninstall:
@echo "Uninstalling odigos from source. version: $(ODIGOS_CLI_VERSION)"
cd ./cli ; go run -tags=embed_manifests . uninstall

.PHONY: cli-uninstall
Copy link
Contributor

Choose a reason for hiding this comment

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

This carried over as a duplicate, with typo in the "echo" message, please remove :)

cli-uninstall:
@echo "Installing odigos from source. version: $(ODIGOS_CLI_VERSION)"
cd ./cli ; go run -tags=embed_manifests . uninstall

.PHONY: cli-upgrade
cli-upgrade:
@echo "Upgrading odigos from source. version: $(ODIGOS_CLI_VERSION)"
Expand Down
28 changes: 28 additions & 0 deletions api/config/crd/bases/odigos.io_destinations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,34 @@ spec:
- METRICS
type: string
type: array
sourceSelector:
description: |-
SourceSelector defines which sources can send data to this destination.
If not specified, defaults to "all".
properties:
groups:
description: Groups specifies the groups for "groups" mode.
items:
type: string
type: array
modes:
description: |-
Mode can contain a combination of "all", "namespaces", or "groups".
Determines how sources are selected for this destination.
enum:
- all
- namespaces
- groups
items:
type: string
type: array
namespaces:
description: Namespaces specifies the namespaces for "namespaces"
mode.
items:
type: string
type: array
type: object
type:
type: string
required:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/generated/odigos/applyconfiguration/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions api/odigos/v1alpha1/destination_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ type DestinationSpec struct {
Data map[string]string `json:"data"`
SecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
Signals []common.ObservabilitySignal `json:"signals"`

// SourceSelector defines which sources can send data to this destination.
// If not specified, defaults to "all".
// +optional
SourceSelector *SourceSelector `json:"sourceSelector,omitempty"`
}

// SourceSelector defines the criteria for selecting sources.
type SourceSelector struct {
// Mode can contain a combination of "all", "namespaces", or "groups".
// Determines how sources are selected for this destination.
// +kubebuilder:validation:Enum=all;namespaces;groups
Modes []string `json:"modes,omitempty"`

// Namespaces specifies the namespaces for "namespaces" mode.
// +optional
Namespaces []string `json:"namespaces,omitempty"`

// Groups specifies the groups for "groups" mode.
// +optional
Groups []string `json:"groups,omitempty"`
}

// DestinationStatus defines the observed state of Destination
Expand Down
35 changes: 35 additions & 0 deletions api/odigos/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions autoscaler/controllers/common/processors.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package common

import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"

"github.com/go-logr/logr"
odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
)

func FilterAndSortProcessorsByOrderHint(processors *odigosv1.ProcessorList, collectorRole odigosv1.CollectorsGroupRole) []*odigosv1.Processor {
Expand Down Expand Up @@ -70,3 +77,115 @@ func GetGenericBatchProcessor() odigosv1.Processor {
},
}
}

type MatchCondition struct {
Name string `mapstructure:"name"`
Namespace string `mapstructure:"namespace"`
Kind string `mapstructure:"kind"`
}

func AddFilterProcessors(ctx context.Context, kubeClient client.Client, allProcessors *odigosv1.ProcessorList, dests *odigosv1.DestinationList) {
for _, dest := range dests.Items {
logger := log.Log.WithValues("destination", dest.Name)
logger.Info("Processing destination for filter processor")

if dest.Spec.SourceSelector == nil || contains(dest.Spec.SourceSelector.Modes, "all") {
logger.Info("Skipping destination as SourceSelector is nil or set to 'all'")
continue
}

var matchedSources []odigosv1.Source
if contains(dest.Spec.SourceSelector.Modes, "namespaces") {
matchedSources = append(matchedSources, fetchSourcesByNamespaces(ctx, kubeClient, dest.Spec.SourceSelector.Namespaces, logger)...)
}
if contains(dest.Spec.SourceSelector.Modes, "groups") {
matchedSources = append(matchedSources, fetchSourcesByGroups(ctx, kubeClient, dest.Spec.SourceSelector.Groups, logger)...)
}

logger.Info("Matched sources for destination", "matchedSources", matchedSources)

matchConditions := make(map[string]bool)
for _, source := range matchedSources {
logger.Info("Adding match condition for source", "sourceName", source.Spec.Workload.Name, "namespace", source.Spec.Workload.Namespace, "kind", source.Spec.Workload.Kind)

key := fmt.Sprintf("%s/%s/%s", source.Spec.Workload.Namespace, source.Spec.Workload.Name, source.Spec.Workload.Kind)
matchConditions[key] = true
}

if len(matchConditions) == 0 {
logger.Info("No matched sources for destination. Skipping processor creation.")
continue
}

filterConfig := map[string]interface{}{
"match_conditions": matchConditions,
}

allProcessors.Items = append(allProcessors.Items, odigosv1.Processor{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("odigosroutingfilterprocessor-%s", dest.Name),
},
Spec: odigosv1.ProcessorSpec{
Type: "odigosroutingfilterprocessor",
ProcessorConfig: runtime.RawExtension{Raw: marshalConfig(filterConfig)},
CollectorRoles: []odigosv1.CollectorsGroupRole{
odigosv1.CollectorsGroupRoleClusterGateway,
},
OrderHint: len(allProcessors.Items) + 1,
Signals: dest.Spec.Signals,
},
})

}
}

func fetchSourcesByNamespaces(ctx context.Context, kubeClient client.Client, namespaces []string, logger logr.Logger) []odigosv1.Source {
var sources []odigosv1.Source
for _, ns := range namespaces {
sourceList := &odigosv1.SourceList{}
err := kubeClient.List(ctx, sourceList, &client.ListOptions{Namespace: ns})
if err != nil {
logger.Error(err, "Failed to fetch sources by namespace", "namespace", ns)
continue
}
sources = append(sources, sourceList.Items...)
}
return sources
}

func fetchSourcesByGroups(ctx context.Context, kubeClient client.Client, groups []string, logger logr.Logger) []odigosv1.Source {
selectors := make([]string, len(groups))
for i, group := range groups {
selectors[i] = fmt.Sprintf("odigos.io/group-%s=true", group)
}
labelSelector := labels.SelectorFromSet(labels.Set{
strings.Join(selectors, ","): "",
})

sourceList := &odigosv1.SourceList{}
err := kubeClient.List(ctx, sourceList, &client.ListOptions{
LabelSelector: labelSelector,
})
if err != nil {
logger.Error(err, "Failed to fetch sources by groups", "groups", groups)
return nil
}
return sourceList.Items
}

func marshalConfig(config map[string]interface{}) []byte {
data, err := json.Marshal(config)
if err != nil {
log.Log.Error(err, "Failed to marshal processor config")
}
return data
}

func contains(arr []string, val string) bool {
for _, item := range arr {
if item == val {
return true
}
}
return false
}
1 change: 1 addition & 0 deletions autoscaler/controllers/destination_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type DestinationReconciler struct {
func (r *DestinationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)
logger.V(0).Info("Reconciling Destination")

err := gateway.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion, r.Config)
if err != nil {
return ctrl.Result{}, err
Expand Down
2 changes: 1 addition & 1 deletion autoscaler/controllers/gateway/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func addSelfTelemetryPipeline(c *config.Config, ownTelemetryPort int32) error {
func syncConfigMap(dests *odigosv1.DestinationList, allProcessors *odigosv1.ProcessorList, gateway *odigosv1.CollectorsGroup, ctx context.Context, c client.Client, scheme *runtime.Scheme) ([]odigoscommon.ObservabilitySignal, error) {
logger := log.FromContext(ctx)
memoryLimiterConfiguration := common.GetMemoryLimiterConfig(gateway.Spec.ResourcesSettings)

common.AddFilterProcessors(ctx, c, allProcessors, dests)
processors := common.FilterAndSortProcessorsByOrderHint(allProcessors, odigosv1.CollectorsGroupRoleClusterGateway)

desiredData, err, status, signals := config.Calculate(
Expand Down
Loading
Loading