Skip to content

Commit

Permalink
Merge branch 'main' into RAG_secret
Browse files Browse the repository at this point in the history
  • Loading branch information
bangqipropel authored Feb 27, 2025
2 parents 6eecce3 + 80365b0 commit 36a57ba
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
9 changes: 6 additions & 3 deletions cmd/workspace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/k8sclient"
kaitoutils "github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/nodeclaim"
"github.com/kaito-project/kaito/pkg/workspace/controllers"
"github.com/kaito-project/kaito/pkg/workspace/webhooks"
Expand Down Expand Up @@ -161,9 +162,11 @@ func main() {
exitWithErrorFunc()
}

err = nodeclaim.CheckNodeClass(ctx, kClient)
if err != nil {
exitWithErrorFunc()
if featuregates.FeatureGates[consts.FeatureFlagEnsureNodeClass] {
err := nodeclaim.CheckNodeClass(ctx, kClient)
if err != nil {
exitWithErrorFunc()
}
}

klog.InfoS("starting manager")
Expand Down
5 changes: 3 additions & 2 deletions pkg/featuregates/featuregates.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
)

var (
// FeatureGates is a map that holds the feature gates and their default values for Kaito.
// FeatureGates is a map that holds the feature gate names and their default values for Kaito.
FeatureGates = map[string]bool{
consts.FeatureFlagVLLM: true,
consts.FeatureFlagVLLM: true,
consts.FeatureFlagEnsureNodeClass: false,
// Add more feature gates here
}
)
Expand Down
35 changes: 28 additions & 7 deletions pkg/featuregates/featuregates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ func TestParseFeatureGates(t *testing.T) {
name string
featureGates string
expectedError bool
expectedValue string
targetFeature string
expectedValue bool
}{
{
name: "WithValidEnableFeatureGates",
name: "WithValidEnableFeatureGates-vLLM",
featureGates: "vLLM=true",
expectedError: false,
expectedValue: "true",
targetFeature: "vLLM",
expectedValue: true,
},
{
name: "WithDuplicateFeatureGates",
name: "WithDuplicateFeatureGates-vLLM",
featureGates: "vLLM=false,vLLM=true",
expectedError: false,
expectedValue: "true", // Apply the last value.
targetFeature: "vLLM",
expectedValue: true, // Apply the last value.
},
{
name: "WithInvalidFeatureGates",
Expand All @@ -38,10 +41,25 @@ func TestParseFeatureGates(t *testing.T) {
expectedError: true,
},
{
name: "WithValidDisableFeatureGates",
name: "WithValidDisableFeatureGates-vLLM",
featureGates: "vLLM=false",
expectedError: false,
expectedValue: "false",
targetFeature: "vLLM",
expectedValue: false,
},
{
name: "WithValidEnableFeatureGates-ensureNodeClass",
featureGates: "ensureNodeClass=true",
expectedError: false,
targetFeature: "ensureNodeClass",
expectedValue: true,
},
{
name: "WithValidDisableFeatureGates-ensureNodeClass",
featureGates: "ensureNodeClass=false",
expectedError: false,
targetFeature: "ensureNodeClass",
expectedValue: false,
},
{
name: "WithEmptyFeatureGates",
Expand All @@ -57,6 +75,9 @@ func TestParseFeatureGates(t *testing.T) {
assert.Check(t, err != nil, "expected error but got nil")
} else {
assert.NilError(t, err)
if tt.targetFeature != "" && FeatureGates[tt.targetFeature] != tt.expectedValue {
t.Errorf("feature gate test %s fails", tt.name)
}
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const (
NvidiaGPU = "nvidia.com/gpu"

// Feature flags
FeatureFlagVLLM = "vLLM"
FeatureFlagVLLM = "vLLM"
FeatureFlagEnsureNodeClass = "ensureNodeClass"

// Nodeclaim related consts
KaitoNodePoolName = "kaito"
Expand Down

0 comments on commit 36a57ba

Please sign in to comment.