Skip to content

Commit

Permalink
fix: add event filter to prevent cg status from being reconciled inde…
Browse files Browse the repository at this point in the history
…finitely (#1616)

1. add event filter for reconciler of collector group - to prevent
endless reconcile loops
2. remove unused property from collector group CRD
3. pin version of java base image in tests for deterministic test result
  • Loading branch information
blumamir authored Oct 24, 2024
1 parent b302071 commit 5ded5ee
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 18 deletions.
2 changes: 0 additions & 2 deletions api/config/crd/bases/odigos.io_collectorsgroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ spec:
spec:
description: CollectorsGroupSpec defines the desired state of Collector
properties:
inputSvc:
type: string
role:
enum:
- CLUSTER_GATEWAY
Expand Down

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

3 changes: 1 addition & 2 deletions api/odigos/v1alpha1/collectorsgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ const (

// CollectorsGroupSpec defines the desired state of Collector
type CollectorsGroupSpec struct {
InputSvc string `json:"inputSvc,omitempty"`
Role CollectorsGroupRole `json:"role"`
Role CollectorsGroupRole `json:"role"`
}

// CollectorsGroupStatus defines the observed state of Collector
Expand Down
25 changes: 25 additions & 0 deletions autoscaler/controllers/collectorsgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/autoscaler/controllers/datacollection"
"github.com/odigos-io/odigos/autoscaler/controllers/gateway"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"sigs.k8s.io/controller-runtime/pkg/log"

Expand All @@ -30,6 +32,28 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

type onlyCreatePredicate struct {
predicate.Funcs
}

func (i *onlyCreatePredicate) Create(e event.CreateEvent) bool {
return true
}

func (i *onlyCreatePredicate) Update(e event.UpdateEvent) bool {
return false
}

func (i *onlyCreatePredicate) Delete(e event.DeleteEvent) bool {
return false
}

func (i *onlyCreatePredicate) Generic(e event.GenericEvent) bool {
return false
}

var _ predicate.Predicate = &onlyCreatePredicate{}

// CollectorsGroupReconciler reconciles a CollectorsGroup object
type CollectorsGroupReconciler struct {
client.Client
Expand Down Expand Up @@ -78,5 +102,6 @@ func (r *CollectorsGroupReconciler) Reconcile(ctx context.Context, req ctrl.Requ
func (r *CollectorsGroupReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&odigosv1.CollectorsGroup{}).
WithEventFilter(&onlyCreatePredicate{}).
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package

FROM azul/zulu-openjdk-alpine:17-jre
FROM azul/zulu-openjdk-alpine:17.0.12-jre-headless
COPY --from=build /home/app/target/*.jar /app/java-azul.jar
USER 15000
CMD ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseZGC", "-jar", "/app/java-azul.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package

FROM eclipse-temurin:17-jre-jammy
FROM eclipse-temurin:17.0.12_7-jre-jammy
ENV JAVA_OPTS="-Dthis.does.not.exist=true"
COPY --from=build /home/app/target/*.jar /app/java-supported-docker-env.jar
USER 15000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package

FROM eclipse-temurin:17-jre-jammy
FROM eclipse-temurin:17.0.12_7-jre-jammy
COPY --from=build /home/app/target/*.jar /app/java-supported-manifest-env.jar
USER 15000
CMD ["java","-jar", "/app/java-supported-manifest-env.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package

FROM eclipse-temurin:17-jre-jammy
FROM eclipse-temurin:17.0.12_7-jre-jammy
COPY --from=build /home/app/target/*.jar /app/java-supported-version.jar
USER 15000
CMD ["java","-jar", "/app/java-supported-version.jar"]

0 comments on commit 5ded5ee

Please sign in to comment.