Skip to content

Commit

Permalink
Remove fields, RAW Capacity, Burst (#130)
Browse files Browse the repository at this point in the history
* WIP Remove burst counts and raw capacity

* Remove legacy id and change it to name

* WIP generate clients

* Fix CRD columns, remove environment status

* Remove environment status in types

* Remove environment status in types

* Fix go.mod

* Better calculation of available VM counts for a given period

* Clean up

* Fix errors where frontend relies on ID

* Keep progress when event is finished - delete when event deleted

* Changing count capacity on environments works

* Remove DynamicBindRequest, Strictly respect limits

* Better support for multiple environments

* Remove TODO comment

* Remove another TODO

* WIP: Delete VMClainms when they can not be fulfilled

* Taint session if VMC can not be fulfilled

* Delete old progresses when there is an error creating the session

* Fix bug where dangling VMs could be produced on odd numbered VMSets
jggoebel authored Feb 6, 2023

Verified

This commit was signed with the committer’s verified signature.
codebytere Shelley Vohr
1 parent b7ff6e9 commit a57c2fa
Showing 41 changed files with 945 additions and 2,153 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ require (
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
115 changes: 1 addition & 114 deletions go.sum

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
@@ -36,7 +36,6 @@ import (
"github.com/hobbyfarm/gargantua/pkg/authserver"
hfClientset "github.com/hobbyfarm/gargantua/pkg/client/clientset/versioned"
hfInformers "github.com/hobbyfarm/gargantua/pkg/client/informers/externalversions"
"github.com/hobbyfarm/gargantua/pkg/controllers/dynamicbindcontroller"
"github.com/hobbyfarm/gargantua/pkg/controllers/scheduledevent"
"github.com/hobbyfarm/gargantua/pkg/controllers/session"
"github.com/hobbyfarm/gargantua/pkg/controllers/tfpcontroller"
@@ -420,10 +419,6 @@ func bootStrapControllers(kubeClient *kubernetes.Clientset, hfClient *hfClientse
if err != nil {
return err
}
dynamicBindController, err := dynamicbindcontroller.NewDynamicBindController(hfClient, hfInformerFactory, gctx)
if err != nil {
return err
}

g.Go(func() error {
return sessionController.Run(stopCh)
@@ -445,10 +440,6 @@ func bootStrapControllers(kubeClient *kubernetes.Clientset, hfClient *hfClientse
return vmSetController.Run(stopCh)
})

g.Go(func() error {
return dynamicBindController.Run(stopCh)
})

g.Go(func() error {
return rbacControllerFactory.Start(ctx, 1)
})
2 changes: 0 additions & 2 deletions pkg/apis/hobbyfarm.io/v1/register.go
Original file line number Diff line number Diff line change
@@ -51,8 +51,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ScheduledEventList{},
&DynamicBindConfiguration{},
&DynamicBindConfigurationList{},
&DynamicBindRequest{},
&DynamicBindRequestList{},
&Progress{},
&ProgressList{},
)
63 changes: 0 additions & 63 deletions pkg/apis/hobbyfarm.io/v1/types.go
Original file line number Diff line number Diff line change
@@ -5,15 +5,12 @@ import (
)

type VmStatus string
type CapacityMode string

const (
VmStatusRFP VmStatus = "readyforprovisioning"
VmStatusProvisioned VmStatus = "provisioned"
VmStatusRunning VmStatus = "running"
VmStatusTerminating VmStatus = "terminating"
CapacityModeRaw CapacityMode = "raw"
CapacityModeCount CapacityMode = "count"
)

// +genclient
@@ -35,7 +32,6 @@ type VirtualMachineList struct {
}

type VirtualMachineSpec struct {
Id string `json:"id"`
VirtualMachineTemplateId string `json:"vm_template_id"`
SshUsername string `json:"ssh_username"`
Protocol string `json:"protocol"`
@@ -77,7 +73,6 @@ type VirtualMachineClaimList struct {
}

type VirtualMachineClaimSpec struct {
Id string `json:"id"`
UserId string `json:"user"`
RestrictedBind bool `json:"restricted_bind"`
RestrictedBindValue string `json:"restricted_bind_value"`
@@ -89,7 +84,6 @@ type VirtualMachineClaimSpec struct {
type VirtualMachineClaimStatus struct {
BindMode string `json:"bind_mode"`
StaticBindAttempts int `json:"static_bind_attempts"`
DynamicBindRequestId string `json:"dynamic_bind_request_id"`
Bound bool `json:"bound"`
Ready bool `json:"ready"`
Tainted bool `json:"tainted"` // If tainted, we should delete the VM's underneath then delete ourself...
@@ -121,10 +115,8 @@ type VirtualMachineTemplateList struct {
// VM type is a genercized collection of information about a VM. this includes things like
// cpu, ram, disk, etc.
type VirtualMachineTemplateSpec struct {
Id string `json:"id"`
Name string `json:"name"` // 2x4, etc.
Image string `json:"image"` // ubuntu-18.04
Resources CMSStruct `json:"resources"`
ConfigMap map[string]string `json:"config_map"`
}

@@ -135,7 +127,6 @@ type Environment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec EnvironmentSpec `json:"spec"`
Status EnvironmentStatus `json:"status"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -157,23 +148,7 @@ type EnvironmentSpec struct {
EnvironmentSpecifics map[string]string `json:"environment_specifics"`
IPTranslationMap map[string]string `json:"ip_translation_map"`
WsEndpoint string `json:"ws_endpoint"`
CapacityMode CapacityMode `json:"capacity_mode"`
BurstCapable bool `json:"burst_capable"`
CountCapacity map[string]int `json:"count_capacity"`
Capacity CMSStruct `json:"capacity"`
BurstCountCapacity map[string]int `json:"burst_count_capacity"`
BurstCapacity CMSStruct `json:"burst_capacity"`
}

type EnvironmentStatus struct {
Used CMSStruct `json:"used"`
AvailableCount map[string]int `json:"available_count"`
}

type CMSStruct struct {
CPU int `json:"cpu"` // cores
Memory int `json:"memory"` // in MB
Storage int `json:"storage"` // in GB
}

// +genclient
@@ -234,7 +209,6 @@ type CourseList struct {
}

type CourseSpec struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Scenarios []string `json:"scenarios"`
@@ -265,7 +239,6 @@ type ScenarioList struct {
}

type ScenarioSpec struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Steps []ScenarioStep `json:"steps"`
@@ -301,7 +274,6 @@ type SessionList struct {
}

type SessionSpec struct {
Id string `json:"id"`
ScenarioId string `json:"scenario"`
CourseId string `json:"course"`
KeepCourseVM bool `json:"keep_course_vm"`
@@ -338,7 +310,6 @@ type ProgressList struct {
}

type ProgressSpec struct {
Id string `json:"id"`
CurrentStep int `json:"current_step"`
MaxStep int `json:"max_step"`
TotalStep int `json:"total_step"`
@@ -479,43 +450,9 @@ type DynamicBindConfigurationList struct {
// that there is adequate vm capacity, it will always choose the environment with the highest capacity before creating a dynamic VM.

type DynamicBindConfigurationSpec struct {
Id string `json:"id"`
Environment string `json:"environment"`
BaseName string `json:"base_name"`
RestrictedBind bool `json:"restricted_bind"`
RestrictedBindValue string `json:"restricted_bind_value"`
BurstCountCapacity map[string]int `json:"burst_count_capacity"`
BurstCapacity CMSStruct `json:"burst_capacity"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type DynamicBindRequest struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec DynamicBindRequestSpec `json:"spec"`
Status DynamicBindRequestStatus `json:"status"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type DynamicBindRequestList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []DynamicBindRequest `json:"items"`
}

type DynamicBindRequestSpec struct {
Id string `json:"id"`
VirtualMachineClaim string `json:"vm_claim"`
Attempts int `json:"attempts"`
}

type DynamicBindRequestStatus struct {
CurrentAttempts int `json:"current_attempts"`
Expired bool `json:"expired"`
Fulfilled bool `json:"fulfilled"`
DynamicBindConfigurationId string `json:"dynamic_bind_configuration_id"`
VirtualMachineIds map[string]string `json:"virtual_machines_id"`
}
Loading

0 comments on commit a57c2fa

Please sign in to comment.