Skip to content

Commit

Permalink
fix: orchestration route back off and erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgialelis committed Jul 5, 2024
1 parent b0b56fa commit ac11b31
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions deploy/charts/dutycontroller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: dutycontroller
description: A Pagerduty Operator for Kubernetes
type: application
version: 0.4.0
appVersion: "1.2.0"
version: 0.4.1
appVersion: "1.2.1"
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ func (r *OrchestrationroutesReconciler) Reconcile(ctx context.Context, req ctrl.
for _, route := range orchestrationRoute.Spec.ServiceRoutes {
serviceID, err := r.LookupService(ctx, req.Namespace, route.ServiceRef)
if err != nil {
return ctrl.Result{}, fmt.Errorf("could not find the service: %w", err)
log.Error(err, "could not find the service")
return ctrl.Result{}, nil
}

orhcestrationRoute := pd.ServiceRouteToOrchestrationRoute(serviceID, route)

err = r.PagerClient.DeleteOrchestrationServiceRoute(orhcestrationRoute)
err = r.PagerClient.DeleteOrchestrationServiceRoute(ctx, orhcestrationRoute)
if err != nil {
log.Error(err, "could not delete orchestration route")
return ctrl.Result{}, fmt.Errorf("couldnt delete orchestration route: %w", err)
Expand Down Expand Up @@ -119,10 +120,8 @@ func (r *OrchestrationroutesReconciler) Reconcile(ctx context.Context, req ctrl.
//Lookup Service
serviceID, err := r.LookupService(ctx, req.Namespace, route.ServiceRef)
if err != nil {
return ctrl.Result{
Requeue: true,
RequeueAfter: 30 * time.Second,
}, fmt.Errorf("could not find the service: %w", err)
log.info("could not find the service, Re-queing in 30seconds ", "service", route.ServiceRef)

Check failure on line 123 in pkg/controller/pagerduty/orchestrationroutes/orchestrationroutes_controller.go

View workflow job for this annotation

GitHub Actions / Lint and Test

log.info undefined (type logr.Logger has no field or method info, but does have Info) (typecheck)

Check failure on line 123 in pkg/controller/pagerduty/orchestrationroutes/orchestrationroutes_controller.go

View workflow job for this annotation

GitHub Actions / Lint and Test

log.info undefined (type logr.Logger has no field or method info, but does have Info)) (typecheck)
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
}

//Check if Route exists
Expand All @@ -137,10 +136,7 @@ func (r *OrchestrationroutesReconciler) Reconcile(ctx context.Context, req ctrl.
log.Info("Route does not exist, creating route", "route", orhcestrationRoute)
err := r.PagerClient.AddOrchestrationServiceRoute(orhcestrationRoute)
if err != nil {
return ctrl.Result{
Requeue: true,
RequeueAfter: 30 * time.Second,
}, fmt.Errorf("error creating Orchestration route: %w", err)
return ctrl.Result{}, fmt.Errorf("error creating Orchestration route: %w", err)
}
} else {
// Unmarshal last applied routes
Expand All @@ -161,7 +157,7 @@ func (r *OrchestrationroutesReconciler) Reconcile(ctx context.Context, req ctrl.
return ctrl.Result{}, fmt.Errorf("could not find the service: %w", err)
}

err = r.PagerClient.DeleteOrchestrationServiceRoute(pd.ServiceRouteToOrchestrationRoute(serivceIdToRemove, removedRoute))
err = r.PagerClient.DeleteOrchestrationServiceRoute(ctx, pd.ServiceRouteToOrchestrationRoute(serivceIdToRemove, removedRoute))
if err != nil {
return ctrl.Result{}, fmt.Errorf("could not delete orchestration route: %w", err)
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/providers/pd/eventorchestration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"context"
"errors"
"io"
"log"
"sigs.k8s.io/controller-runtime/pkg/log"

"net/http"
"net/url"

Expand Down Expand Up @@ -168,7 +169,8 @@ func (pd *Pagerduty) UpdateOrchestrationServiceRoute(OrchestrationRoute Orchestr
return nil
}

func (pd *Pagerduty) DeleteOrchestrationServiceRoute(OrchestrationRoute OrchestrationRoute) error {
func (pd *Pagerduty) DeleteOrchestrationServiceRoute(ctx context.Context, OrchestrationRoute OrchestrationRoute) error {
log := log.FromContext(ctx)

orchID, ok, err := pd.GetEventOrchestrationByName(OrchestrationRoute.EventOrchestrationName)
if err != nil {
Expand All @@ -190,7 +192,7 @@ func (pd *Pagerduty) DeleteOrchestrationServiceRoute(OrchestrationRoute Orchestr
if rule.Actions.RouteTo != OrchestrationRoute.RouteTo {
newRules = append(newRules, rule)
} else {
log.Println("Removing route", "route", rule.Actions.RouteTo)
log.Info("Removing route", "route", rule.Actions.RouteTo)
}
}

Expand Down

0 comments on commit ac11b31

Please sign in to comment.