Skip to content

Commit 6d35640

Browse files
committed
Various fixes after 3rd review:
- Simply handlers by removing unused parameters - Adjust copyright header newline - Remove occurence of `oc` in README - Remove incorrect description fields in yaml examples
1 parent d86e34b commit 6d35640

17 files changed

+44
-35
lines changed

cmd/experimental/kueue-viz/OWNERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See the OWNERS docs at https://go.k8s.io/owners
2+
3+
approvers:
4+
- akram
5+
- mbobrovskyi
6+
- mimowo
7+
8+
reviewers:
9+
- akram
10+
- mbobrovskyi
11+
- mimowo
12+

cmd/experimental/kueue-viz/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ cd frontend && make debug
7070
Create test data using the resources in `examples/` directory.
7171

7272
```
73-
oc create -f examples/
73+
kubectl create -f examples/
7474
```
7575
And check that you have some data on the dashboard.
7676

cmd/experimental/kueue-viz/backend/handlers/cluster_queues.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (
@@ -27,7 +28,7 @@ import (
2728

2829
// ClusterQueuesWebSocketHandler streams all cluster queues
2930
func ClusterQueuesWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerFunc {
30-
return GenericWebSocketHandler(dynamicClient, ClusterQueuesGVR(), "", func() (interface{}, error) {
31+
return GenericWebSocketHandler(func() (interface{}, error) {
3132
return fetchClusterQueues(dynamicClient)
3233
})
3334
}
@@ -36,7 +37,7 @@ func ClusterQueuesWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerF
3637
func ClusterQueueDetailsWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerFunc {
3738
return func(c *gin.Context) {
3839
clusterQueueName := c.Param("cluster_queue_name")
39-
GenericWebSocketHandler(dynamicClient, ClusterQueuesGVR(), "", func() (interface{}, error) {
40+
GenericWebSocketHandler(func() (interface{}, error) {
4041
return fetchClusterQueueDetails(dynamicClient, clusterQueueName)
4142
})(c)
4243
}

cmd/experimental/kueue-viz/backend/handlers/cohorts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (
@@ -24,7 +25,7 @@ import (
2425

2526
// CohortsWebSocketHandler streams all cohorts
2627
func CohortsWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerFunc {
27-
return GenericWebSocketHandler(dynamicClient, CohortsGVR(), "", func() (interface{}, error) {
28+
return GenericWebSocketHandler(func() (interface{}, error) {
2829
return fetchCohorts(dynamicClient)
2930
})
3031
}
@@ -34,7 +35,7 @@ func CohortDetailsWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerF
3435
return func(c *gin.Context) {
3536
cohortName := c.Param("cohort_name")
3637

37-
GenericWebSocketHandler(dynamicClient, CohortsGVR(), "", func() (interface{}, error) {
38+
GenericWebSocketHandler(func() (interface{}, error) {
3839
return fetchCohortDetails(dynamicClient, cohortName)
3940
})(c)
4041
}

cmd/experimental/kueue-viz/backend/handlers/gvr.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (

cmd/experimental/kueue-viz/backend/handlers/handlers.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (
@@ -24,8 +25,8 @@ import (
2425
func InitializeWebSocketRoutes(router *gin.Engine, dynamicClient dynamic.Interface, k8sClient *kubernetes.Clientset) {
2526

2627
// Workloads
27-
router.GET("/ws/workloads", WorkloadsWebSocketHandler(dynamicClient, k8sClient))
28-
router.GET("/ws/workloads/dashboard", WorkloadsDashboardWebSocketHandler(dynamicClient, k8sClient))
28+
router.GET("/ws/workloads", WorkloadsWebSocketHandler(dynamicClient))
29+
router.GET("/ws/workloads/dashboard", WorkloadsDashboardWebSocketHandler(dynamicClient))
2930

3031
router.GET("/ws/workload/:namespace/:workload_name", WorkloadDetailsWebSocketHandler(dynamicClient))
3132
router.GET("/ws/workload/:namespace/:workload_name/events", WorkloadEventsWebSocketHandler(dynamicClient))

cmd/experimental/kueue-viz/backend/handlers/local_queue_workloads.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (
@@ -28,7 +29,7 @@ func LocalQueueWorkloadsWebSocketHandler(dynamicClient dynamic.Interface) gin.Ha
2829
return func(c *gin.Context) {
2930
namespace := c.Param("namespace")
3031
queueName := c.Param("queue_name")
31-
GenericWebSocketHandler(dynamicClient, WorkloadsGVR(), namespace, func() (interface{}, error) {
32+
GenericWebSocketHandler(func() (interface{}, error) {
3233
return fetchLocalQueueWorkloads(dynamicClient, namespace, queueName)
3334
})(c)
3435
}

cmd/experimental/kueue-viz/backend/handlers/local_queues.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (
@@ -26,7 +27,7 @@ import (
2627

2728
// LocalQueuesWebSocketHandler streams all local queues
2829
func LocalQueuesWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerFunc {
29-
return GenericWebSocketHandler(dynamicClient, LocalQueuesGVR(), "", func() (interface{}, error) {
30+
return GenericWebSocketHandler(func() (interface{}, error) {
3031
return fetchLocalQueues(dynamicClient)
3132
})
3233
}
@@ -36,7 +37,7 @@ func LocalQueueDetailsWebSocketHandler(dynamicClient dynamic.Interface) gin.Hand
3637
return func(c *gin.Context) {
3738
namespace := c.Param("namespace")
3839
queueName := c.Param("queue_name")
39-
GenericWebSocketHandler(dynamicClient, LocalQueuesGVR(), namespace, func() (interface{}, error) {
40+
GenericWebSocketHandler(func() (interface{}, error) {
4041
return fetchLocalQueueDetails(dynamicClient, namespace, queueName)
4142
})(c)
4243
}

cmd/experimental/kueue-viz/backend/handlers/resource_flavors.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (
@@ -31,7 +32,7 @@ import (
3132
// ResourceFlavorsWebSocketHandler streams all resource flavors
3233
func ResourceFlavorsWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerFunc {
3334

34-
return GenericWebSocketHandler(dynamicClient, ResourceFlavorsGVR(), "", func() (interface{}, error) {
35+
return GenericWebSocketHandler(func() (interface{}, error) {
3536
return fetchResourceFlavors(dynamicClient)
3637
})
3738
}
@@ -40,7 +41,7 @@ func ResourceFlavorsWebSocketHandler(dynamicClient dynamic.Interface) gin.Handle
4041
func ResourceFlavorDetailsWebSocketHandler(dynamicClient dynamic.Interface) gin.HandlerFunc {
4142
return func(c *gin.Context) {
4243
flavorName := c.Param("flavor_name")
43-
GenericWebSocketHandler(dynamicClient, ResourceFlavorsGVR(), "", func() (interface{}, error) {
44+
GenericWebSocketHandler(func() (interface{}, error) {
4445
return fetchResourceFlavorDetails(dynamicClient, flavorName)
4546
})(c)
4647
}

cmd/experimental/kueue-viz/backend/handlers/websocket_handler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package handlers
1718

1819
import (
@@ -23,8 +24,6 @@ import (
2324

2425
"github.com/gin-gonic/gin"
2526
"github.com/gorilla/websocket"
26-
"k8s.io/apimachinery/pkg/runtime/schema"
27-
"k8s.io/client-go/dynamic"
2827
)
2928

3029
// WebSocket upgrader
@@ -35,7 +34,7 @@ var upgrader = websocket.Upgrader{
3534
}
3635

3736
// GenericWebSocketHandler creates a WebSocket endpoint with periodic data updates
38-
func GenericWebSocketHandler(dynamicClient dynamic.Interface, resource schema.GroupVersionResource, namespace string, dataFetcher func() (interface{}, error)) gin.HandlerFunc {
37+
func GenericWebSocketHandler(dataFetcher func() (interface{}, error)) gin.HandlerFunc {
3938
return func(c *gin.Context) {
4039
startTime := time.Now()
4140
log.Debug("WebSocket handler started")

0 commit comments

Comments
 (0)