Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add custom template #168

Merged
merged 11 commits into from
Nov 15, 2023
1 change: 1 addition & 0 deletions pkg/controllers/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (c *WorkspaceReconciler) addOrUpdateWorkspace(ctx context.Context, wObj *ka
if wObj.Inference.Preset != nil && strings.Contains(string(wObj.Inference.Preset.Name), "llama") {
useHeadlessService = true
}

if err := c.ensureService(ctx, wObj, useHeadlessService); err != nil {
if updateErr := c.updateStatusConditionIfNotMatch(ctx, wObj, kaitov1alpha1.WorkspaceConditionTypeReady, metav1.ConditionFalse,
"workspaceFailed", err.Error()); updateErr != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func GenerateDeploymentManifestWithPodTemplate(ctx context.Context, workspaceObj
}

templateCopy := workspaceObj.Inference.Template.DeepCopy()

if templateCopy.ObjectMeta.Labels == nil {
templateCopy.ObjectMeta.Labels = make(map[string]string)
}
Expand Down
32 changes: 32 additions & 0 deletions test/e2e/preset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ func createLlama13BWorkspaceWithPresetPrivateMode(registry, registrySecret, imag
return workspaceObj
}

func createCustomWorkspaceWithPresetCustomMode(imageName string, numOfNode int) *kaitov1alpha1.Workspace {
workspaceObj := &kaitov1alpha1.Workspace{}
By("Creating a workspace CR with custom workspace mode", func() {
uniqueID := fmt.Sprint("preset-", rand.Intn(1000))
workspaceObj = utils.GenerateWorkspaceManifest(uniqueID, namespaceName, "",
numOfNode, "Standard_D4s_v3", &metav1.LabelSelector{
MatchLabels: map[string]string{"kaito-workspace": "private-preset-e2e-test"},
}, nil, "", utils.InferenceModeCustomTemplate, nil, utils.GeneratePodTemplate(uniqueID, namespaceName, imageName, nil))

createAndValidateWorkspace(workspaceObj)
})
return workspaceObj
}

func createAndValidateWorkspace(workspaceObj *kaitov1alpha1.Workspace) {
By("Creating workspace", func() {
Eventually(func() error {
Expand Down Expand Up @@ -363,4 +377,22 @@ var _ = Describe("Workspace Preset", func() {
validateWorkspaceReadiness(workspaceObj)
})

It("should create a custom template workspace successfully", func() {
numOfNode := 1
imageName := "nginx:latest"
workspaceObj := createCustomWorkspaceWithPresetCustomMode(imageName, numOfNode)

defer cleanupResources(workspaceObj)

time.Sleep(30 * time.Second)
validateMachineCreation(workspaceObj, numOfNode)
validateResourceStatus(workspaceObj)

time.Sleep(30 * time.Second)

validateInferenceResource(workspaceObj, int32(numOfNode), false)

validateWorkspaceReadiness(workspaceObj)
})

})
Loading