Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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: 0 additions & 2 deletions charts/kthena/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}


Expand Down
4 changes: 2 additions & 2 deletions docs/kthena/docs/reference/helm-chart-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ A Helm chart for deploying Kthena

| Repository | Name | Version |
|------------|------|---------|
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why should you touch here

| | networking | 1.0.0 |
| | workload | 1.0.0 |
| https://ghcr.io/volcano-sh/charts/kthena | networking | 1.0.0 |
| https://ghcr.io/volcano-sh/charts/kthena | workload | 1.0.0 |

## Values

Expand Down
2 changes: 1 addition & 1 deletion pkg/kthena-router/controller/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (c *GatewayController) syncHandler(key string) error {
}

func (c *GatewayController) enqueueGateway(obj interface{}) {
key, err := cache.MetaNamespaceKeyFunc(obj)
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

acceptable(since we also get a DeleteFunc in NewHTTPRouteController or else).

controller.registration, _ = httpRouteInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: controller.enqueueHTTPRoute,
UpdateFunc: func(old, new interface{}) { controller.enqueueHTTPRoute(new) },
DeleteFunc: controller.enqueueHTTPRoute,
})

k8s standard FYI:
https://github.com/kubernetes/client-go/blob/f651faf89451a2a3263d06653561101c26675659/examples/workqueue/main.go#L177-L202

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for confirming

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@WHOIM1205 why not change all the MetaNamespaceKeyFunc to DeletionHandlingMetaNamespaceKeyFunc in kthena?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@YaoZengzeng
i intentionally kept this change scoped to the router controllers where delete events are handled and tombstones are actually observed
other usages of MetaNamespaceKeyFunc are either not wired to delete handlers or are protected by their event flow/
so changing them would be a broader refactor with more risk
for this pr i preferred a minimal targeted fix to address the concrete issue without expanding scope

if err != nil {
utilruntime.HandleError(err)
return
Expand Down
86 changes: 86 additions & 0 deletions pkg/kthena-router/controller/gateway_controller_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
Copyright The Volcano Authors.

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.
*/

package controller

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/volcano-sh/kthena/pkg/kthena-router/datastore"
)

func TestEnqueueGateway(t *testing.T) {
tests := []struct {
name string
obj interface{}
expectedKey string
}{
{
name: "normal Gateway object",
obj: &gatewayv1.Gateway{
ObjectMeta: metav1.ObjectMeta{
Name: "test-gateway",
Namespace: "default",
},
},
expectedKey: "default/test-gateway",
},
{
name: "tombstone with DeletedFinalStateUnknown",
obj: cache.DeletedFinalStateUnknown{
Key: "default/deleted-gateway",
Obj: &gatewayv1.Gateway{
ObjectMeta: metav1.ObjectMeta{
Name: "deleted-gateway",
Namespace: "default",
},
},
},
expectedKey: "default/deleted-gateway",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
queue := workqueue.NewTypedRateLimitingQueue(workqueue.DefaultTypedControllerRateLimiter[any]())
defer queue.ShutDown()

c := &GatewayController{
workqueue: queue,
store: datastore.New(),
}

c.enqueueGateway(tt.obj)

if queue.Len() != 1 {
t.Fatalf("expected 1 item in queue, got %d", queue.Len())
}

item, shutdown := queue.Get()
if shutdown {
t.Fatal("unexpected queue shutdown")
}
if item != tt.expectedKey {
t.Errorf("expected key %q, got %q", tt.expectedKey, item)
}
})
}
}
2 changes: 1 addition & 1 deletion pkg/kthena-router/controller/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *HTTPRouteController) syncHandler(key string) error {
}

func (c *HTTPRouteController) enqueueHTTPRoute(obj interface{}) {
key, err := cache.MetaNamespaceKeyFunc(obj)
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
if err != nil {
utilruntime.HandleError(err)
return
Expand Down
86 changes: 86 additions & 0 deletions pkg/kthena-router/controller/httproute_controller_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
Copyright The Volcano Authors.

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.
*/

package controller

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/volcano-sh/kthena/pkg/kthena-router/datastore"
)

func TestEnqueueHTTPRoute(t *testing.T) {
tests := []struct {
name string
obj interface{}
expectedKey string
}{
{
name: "normal HTTPRoute object",
obj: &gatewayv1.HTTPRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "test-httproute",
Namespace: "default",
},
},
expectedKey: "default/test-httproute",
},
{
name: "tombstone with DeletedFinalStateUnknown",
obj: cache.DeletedFinalStateUnknown{
Key: "default/deleted-httproute",
Obj: &gatewayv1.HTTPRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "deleted-httproute",
Namespace: "default",
},
},
},
expectedKey: "default/deleted-httproute",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
queue := workqueue.NewTypedRateLimitingQueue(workqueue.DefaultTypedControllerRateLimiter[any]())
defer queue.ShutDown()

c := &HTTPRouteController{
workqueue: queue,
store: datastore.New(),
}

c.enqueueHTTPRoute(tt.obj)

if queue.Len() != 1 {
t.Fatalf("expected 1 item in queue, got %d", queue.Len())
}

item, shutdown := queue.Get()
if shutdown {
t.Fatal("unexpected queue shutdown")
}
if item != tt.expectedKey {
t.Errorf("expected key %q, got %q", tt.expectedKey, item)
}
})
}
}
2 changes: 1 addition & 1 deletion pkg/kthena-router/controller/inferencepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (c *InferencePoolController) syncHandler(key string) error {
}

func (c *InferencePoolController) enqueueInferencePool(obj interface{}) {
key, err := cache.MetaNamespaceKeyFunc(obj)
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
if err != nil {
utilruntime.HandleError(err)
return
Expand Down
86 changes: 86 additions & 0 deletions pkg/kthena-router/controller/inferencepool_controller_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
Copyright The Volcano Authors.

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.
*/

package controller

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
inferencev1 "sigs.k8s.io/gateway-api-inference-extension/api/v1"

"github.com/volcano-sh/kthena/pkg/kthena-router/datastore"
)

func TestEnqueueInferencePool(t *testing.T) {
tests := []struct {
name string
obj interface{}
expectedKey string
}{
{
name: "normal InferencePool object",
obj: &inferencev1.InferencePool{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pool",
Namespace: "default",
},
},
expectedKey: "default/test-pool",
},
{
name: "tombstone with DeletedFinalStateUnknown",
obj: cache.DeletedFinalStateUnknown{
Key: "default/deleted-pool",
Obj: &inferencev1.InferencePool{
ObjectMeta: metav1.ObjectMeta{
Name: "deleted-pool",
Namespace: "default",
},
},
},
expectedKey: "default/deleted-pool",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
queue := workqueue.NewTypedRateLimitingQueue(workqueue.DefaultTypedControllerRateLimiter[any]())
defer queue.ShutDown()

c := &InferencePoolController{
workqueue: queue,
store: datastore.New(),
}

c.enqueueInferencePool(tt.obj)

if queue.Len() != 1 {
t.Fatalf("expected 1 item in queue, got %d", queue.Len())
}

item, shutdown := queue.Get()
if shutdown {
t.Fatal("unexpected queue shutdown")
}
if item != tt.expectedKey {
t.Errorf("expected key %q, got %q", tt.expectedKey, item)
}
})
}
}
2 changes: 1 addition & 1 deletion pkg/kthena-router/controller/modelroute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (c *ModelRouteController) syncHandler(key string) error {
}

func (c *ModelRouteController) enqueueModelRoute(obj interface{}) {
key, err := cache.MetaNamespaceKeyFunc(obj)
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
if err != nil {
utilruntime.HandleError(err)
return
Expand Down
Loading
Loading