Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

add log lines #105

Merged
merged 2 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ go.work.sum

# generated docs
site

.envrc
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ image-build: check-container-tool load-version-json ## Build container image usi
--build-arg TARGETARCH=$(TARGETARCH) \
--build-arg GIT_NM_USER=$(GIT_NM_USER)\
--build-arg NM_TOKEN=$(NM_TOKEN) \
--progress=plain \
-t $(IMG) .

.PHONY: image-push
Expand Down
1 change: 1 addition & 0 deletions pkg/epp/scheduling/local_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ func setPDFilter() {
}

defaultConfig.filters = append(defaultConfig.filters, filter.PDFilter)
loggerDebug.Info("Initialized PDFilter")
}
9 changes: 8 additions & 1 deletion pkg/epp/scheduling/plugins/filter/pd_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import (
"fmt"
"math/rand/v2"

"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend/metrics"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
logutil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/logging"
)

const (
Expand All @@ -42,6 +44,8 @@ var PDFilter = &baseFilter{
// Returns:
// - Filtered slice of pod metrics, could contain one or zerro elements
func prefillDecodeFilterFunc(ctx *types.SchedulingContext, pods []types.Pod) []types.Pod {
logger := log.FromContext(ctx).WithName("p/d filter").V(logutil.DEBUG)

pPods := make([]types.Pod, 0)
dPods := make([]types.Pod, 0)

Expand All @@ -56,7 +60,10 @@ func prefillDecodeFilterFunc(ctx *types.SchedulingContext, pods []types.Pod) []t
if len(pPods) > 0 {
// select a random prefill pod
randomIndex := rand.IntN(len(pPods))
ctx.MutatedHeaders[prefillPodHeader] = fmt.Sprintf("http://%s:%d", pPods[randomIndex].GetPod().Address, ctx.TargetPort)
url := fmt.Sprintf("http://%s:%d", pPods[randomIndex].GetPod().Address, ctx.TargetPort)
logger.Info("prefill pod selected", "url", url)

ctx.MutatedHeaders[prefillPodHeader] = url
}

if len(dPods) > 1 {
Expand Down