Skip to content

Commit

Permalink
bugfix to add api defaults (#95)
Browse files Browse the repository at this point in the history
* bugfix to add api defaults

Adding default annotations with omitempty for the json to ensure the
Python SDK has the defaults, and we can remove them from the
MIniCluster definitions in Python.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Feb 28, 2023
1 parent a74ea5b commit c0b55a3
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 86 deletions.
64 changes: 42 additions & 22 deletions api/v1alpha1/minicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,28 @@ type MiniClusterSpec struct {

// Cleanup the pods and storage when the index broker pod is complete
// +kubebuilder:default=false
// +default=false
// +optional
Cleanup bool `json:"cleanup"`
Cleanup bool `json:"cleanup,omitempty"`

// Size (number of job pods to run, size of minicluster in pods)
// +kubebuilder:default=1
// +default=1
// +optional
Size int32 `json:"size"`
Size int32 `json:"size,omitempty"`

// Total number of CPUs being run across entire cluster
// +kubebuilder:default=1
// +default=1
// +optional
Tasks int32 `json:"tasks"`
Tasks int32 `json:"tasks,omitempty"`

// Should the job be limited to a particular number of seconds?
// Approximately one year. This cannot be zero or job won't start
// +kubebuilder:default=31500000
// +default=31500000
// +optional
DeadlineSeconds int64 `json:"deadlineSeconds"`
DeadlineSeconds int64 `json:"deadlineSeconds,omitempty"`

// Pod spec details
// +optional
Expand All @@ -89,23 +93,27 @@ type LoggingSpec struct {

// Quiet mode silences all output so the job only shows the test running
// +kubebuilder:default=false
// +default=false
// +optional
Quiet bool `json:"quiet"`
Quiet bool `json:"quiet,omitempty"`

// Strict mode ensures any failure will not continue in the job entrypoint
// +kubebuilder:default=true
// +default=true
// +optional
Strict bool `json:"strict"`
Strict bool `json:"strict,omitempty"`

// Debug mode adds extra verbosity to Flux
// +kubebuilder:default=false
// +default=false
// +optional
Debug bool `json:"debug"`
Debug bool `json:"debug,omitempty"`

// Timed mode adds timing to Flux commands
// +kubebuilder:default=false
// +default=false
// +optional
Timed bool `json:"timed"`
Timed bool `json:"timed,omitempty"`
}

// PodSpec controlls variables for the cluster pod
Expand Down Expand Up @@ -140,13 +148,15 @@ type FluxRestful struct {

// Branch to clone Flux Restful API from
// +kubebuilder:default="main"
// +default="main"
// +optional
Branch string `json:"branch"`
Branch string `json:"branch,omitempty"`

// Port to run Flux Restful Server On
// +kubebuilder:default=5000
// +default=5000
// +optional
Port int32 `json:"port"`
Port int32 `json:"port,omitempty"`

// These two should not actually be set by a user,
// but rather generated by tools and provided
Expand All @@ -171,22 +181,25 @@ type MiniClusterVolume struct {
Annotations map[string]string `json:"annotations"`

// +kubebuilder:default="hostpath"
// +default="hostpath"
// +optional
StorageClass string `json:"storageClass"`
StorageClass string `json:"storageClass,omitempty"`

// Secret reference in Kubernetes with service account role
// +optional
Secret string `json:"secret"`

// Secret namespace
// +kubebuilder:default="default"
// +default="default"
// +optional
SecretNamespace string `json:"secretNamespace"`
SecretNamespace string `json:"secretNamespace,omitempty"`

// Capacity (string) for PVC (storage request) to create PV
// +kubebuilder:default="5Gi"
// +default="5Gi"
// +optional
Capacity string `json:"capacity"`
Capacity string `json:"capacity,omitempty"`
}

// A Container volume must reference one defined for the MiniCluster
Expand All @@ -195,15 +208,17 @@ type ContainerVolume struct {
Path string `json:"path"`

// +kubebuilder:default=false
// +default=false
// +optional
ReadOnly bool `json:"readOnly"`
ReadOnly bool `json:"readOnly,omitempty"`
}

type MiniClusterContainer struct {

// Container image must contain flux and flux-sched install
// +kubebuilder:default="fluxrm/flux-sched:focal"
Image string `json:"image"`
// +kubebuilder:default="ghcr.io/rse-ops/accounting:app-latest"
// +default="ghcr.io/rse-ops/accounting:app-latest"
Image string `json:"image,omitempty"`

// Container name is only required for non flux runners
// +optional
Expand Down Expand Up @@ -254,8 +269,9 @@ type MiniClusterContainer struct {
// By default we pull if not present. Setting
// this to true will indicate to pull always
// +kubebuilder:default=false
// +default=false
// +optional
PullAlways bool `json:"pullAlways"`
PullAlways bool `json:"pullAlways,omitempty"`

// Main container to run flux (only should be one)
// +optional
Expand All @@ -274,8 +290,9 @@ type MiniClusterContainer struct {

// Log level to use for flux logging (only in non TestMode)
// +kubebuilder:default=6
// +default=6
// +optional
FluxLogLevel int32 `json:"fluxLogLevel"`
FluxLogLevel int32 `json:"fluxLogLevel,omitempty"`

// Special command to run at beginning of script, directly after asFlux
// is defined as sudo -u flux -E (so you can change that if desired.)
Expand Down Expand Up @@ -307,21 +324,24 @@ type FluxUser struct {

// Flux user name
// +kubebuilder:default="flux"
// +default="flux"
// +optional
Name string `json:"name"`
Name string `json:"name,omitempty"`

// UID for the FluxUser
// +optional
// +kubebuilder:default=1000
Uid int `json:"uid"`
// +default=1000
// +optional
Uid int `json:"uid,omitempty"`
}

type Commands struct {

// Run flux start as root - required for some storage binds
// +kubebuilder:default=false
// +default=false
// +optional
RunFluxAsRoot bool `json:"runFluxAsRoot"`
RunFluxAsRoot bool `json:"runFluxAsRoot,omitempty"`

// pre command is run after global PreCommand, before anything else
// +optional
Expand Down
29 changes: 13 additions & 16 deletions api/v1alpha1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
"branch": {
"description": "Branch to clone Flux Restful API from",
"type": "string",
"default": ""
"default": "main"
},
"port": {
"description": "Port to run Flux Restful Server On",
"type": "integer",
"format": "int32",
"default": 0
"default": 5000
},
"token": {
"description": "Token to use for RestFul API",
Expand All @@ -91,13 +91,13 @@
"name": {
"description": "Flux user name",
"type": "string",
"default": ""
"default": "flux"
},
"uid": {
"description": "UID for the FluxUser",
"type": "integer",
"format": "int32",
"default": 0
"default": 1000
}
}
},
Expand Down Expand Up @@ -126,7 +126,7 @@
"strict": {
"description": "Strict mode ensures any failure will not continue in the job entrypoint",
"type": "boolean",
"default": false
"default": true
},
"timed": {
"description": "Timed mode adds timing to Flux commands",
Expand Down Expand Up @@ -162,9 +162,6 @@
},
"MiniClusterContainer": {
"type": "object",
"required": [
"image"
],
"properties": {
"command": {
"description": "Single user executable to provide to flux start IMPORTANT: This is left here, but not used in favor of exposing Flux via a Restful API. We Can remove this when that is finalized.",
Expand Down Expand Up @@ -199,7 +196,7 @@
"description": "Log level to use for flux logging (only in non TestMode)",
"type": "integer",
"format": "int32",
"default": 0
"default": 6
},
"fluxOptionFlags": {
"description": "Flux option flags, usually provided with -o optional - if needed, default option flags for the server These can also be set in the user interface to override here. This is only valid for a FluxRunner \"runFlux\" true",
Expand All @@ -214,7 +211,7 @@
"image": {
"description": "Container image must contain flux and flux-sched install",
"type": "string",
"default": ""
"default": "ghcr.io/rse-ops/accounting:app-latest"
},
"imagePullSecret": {
"description": "Allow the user to pull authenticated images By default no secret is selected. Setting this with the name of an already existing imagePullSecret will specify that secret in the pod spec.",
Expand Down Expand Up @@ -328,7 +325,7 @@
"description": "Should the job be limited to a particular number of seconds? Approximately one year. This cannot be zero or job won't start",
"type": "integer",
"format": "int64",
"default": 0
"default": 31500000
},
"fluxRestful": {
"description": "Customization to Flux Restful API There should only be one container to run flux with runFlux",
Expand Down Expand Up @@ -357,13 +354,13 @@
"description": "Size (number of job pods to run, size of minicluster in pods)",
"type": "integer",
"format": "int32",
"default": 0
"default": 1
},
"tasks": {
"description": "Total number of CPUs being run across entire cluster",
"type": "integer",
"format": "int32",
"default": 0
"default": 1
},
"users": {
"description": "Users of the MiniCluster",
Expand Down Expand Up @@ -442,7 +439,7 @@
"capacity": {
"description": "Capacity (string) for PVC (storage request) to create PV",
"type": "string",
"default": ""
"default": "5Gi"
},
"labels": {
"type": "object",
Expand All @@ -463,11 +460,11 @@
"secretNamespace": {
"description": "Secret namespace",
"type": "string",
"default": ""
"default": "default"
},
"storageClass": {
"type": "string",
"default": ""
"default": "hostpath"
}
}
},
Expand Down

0 comments on commit c0b55a3

Please sign in to comment.