diff --git a/Makefile b/Makefile
index db7a1e5f1..6c1ccdf44 100644
--- a/Makefile
+++ b/Makefile
@@ -127,7 +127,7 @@ api-doc:
mv bin/tmp/${GROUPVERSION}/*.go $(shell pwd)/pkg/apis/${GROUPVERSION}/
rm -r bin/tmp/${GROUPVERSION}
# Format the docs with pandoc
- docker run -it \
+ docker run -it --rm \
-v $(shell pwd):/data \
-u $(shell id -u):$(shell id -g) \
pandoc/core \
@@ -211,8 +211,8 @@ build-docs: bin/docs/builder-image.tar
docker build -t ignite-docs docs
test-docs: build-docs
- docker run -it ignite-docs /usr/bin/linkchecker _build/html/index.html
+ docker run -it --rm ignite-docs /usr/bin/linkchecker _build/html/index.html
serve-docs: build-docs
@echo Stating docs website on http://localhost:${DOCS_PORT}/_build/html/index.html
- @docker run -i -p ${DOCS_PORT}:8000 -e USER_ID=$$UID ignite-docs
+ @docker run -i --rm -p ${DOCS_PORT}:8000 -e USER_ID=$$UID ignite-docs
diff --git a/cmd/ignite-spawn/ignite-spawn.go b/cmd/ignite-spawn/ignite-spawn.go
index 9ecf8ef1b..4c01a67f7 100644
--- a/cmd/ignite-spawn/ignite-spawn.go
+++ b/cmd/ignite-spawn/ignite-spawn.go
@@ -90,7 +90,7 @@ func serveMetrics(metricsSocket string) {
func patchRunning(vm *api.VM, ipAddrs []net.IP) error {
return patchVM(vm, func(patchVM *api.VM) error {
- patchVM.Status.State = api.VMStateRunning
+ patchVM.Status.Running = true
patchVM.Status.IPAddresses = ipAddrs
return nil
})
@@ -98,7 +98,7 @@ func patchRunning(vm *api.VM, ipAddrs []net.IP) error {
func patchStopped(vm *api.VM) error {
return patchVM(vm, func(patchVM *api.VM) error {
- patchVM.Status.State = api.VMStateStopped
+ patchVM.Status.Running = false
patchVM.Status.IPAddresses = nil
return nil
})
diff --git a/cmd/ignite/run/ps.go b/cmd/ignite/run/ps.go
index 163eae42a..4c7a8f180 100644
--- a/cmd/ignite/run/ps.go
+++ b/cmd/ignite/run/ps.go
@@ -26,10 +26,10 @@ func Ps(po *psOptions) error {
o := util.NewOutput()
defer o.Flush()
- o.Write("VM ID", "IMAGE", "KERNEL", "CREATED", "SIZE", "CPUS", "MEMORY", "STATE", "IPS", "PORTS", "NAME")
+ o.Write("VM ID", "IMAGE", "KERNEL", "CREATED", "SIZE", "CPUS", "MEMORY", "RUNNING", "IPS", "PORTS", "NAME")
for _, vm := range po.allVMs {
o.Write(vm.GetUID(), vm.Spec.Image.OCIClaim.Ref, vm.Spec.Kernel.OCIClaim.Ref, vm.GetCreated(),
- vm.Spec.DiskSize, vm.Spec.CPUs, vm.Spec.Memory, vm.Status.State, vm.Status.IPAddresses,
+ vm.Spec.DiskSize, vm.Spec.CPUs, vm.Spec.Memory, vm.Running(), vm.Status.IPAddresses,
vm.Spec.Network.Ports, vm.GetName())
}
diff --git a/docs/api/ignite_v1alpha1.md b/docs/api/ignite_v1alpha1.md
index ff49bdcc1..d21c4750a 100644
--- a/docs/api/ignite_v1alpha1.md
+++ b/docs/api/ignite_v1alpha1.md
@@ -18,9 +18,15 @@
- [func Convert\_ignite\_VMSpec\_To\_v1alpha1\_VMSpec(in
*ignite.VMSpec, out *VMSpec, s conversion.Scope)
error](#Convert_ignite_VMSpec_To_v1alpha1_VMSpec)
+ - [func Convert\_ignite\_VMStatus\_To\_v1alpha1\_VMStatus(in
+ *ignite.VMStatus, out *VMStatus, s conversion.Scope)
+ error](#Convert_ignite_VMStatus_To_v1alpha1_VMStatus)
- [func Convert\_v1alpha1\_VMSpec\_To\_ignite\_VMSpec(in *VMSpec, out
*ignite.VMSpec, s conversion.Scope)
error](#Convert_v1alpha1_VMSpec_To_ignite_VMSpec)
+ - [func Convert\_v1alpha1\_VMStatus\_To\_ignite\_VMStatus(in
+ *VMStatus, out *ignite.VMStatus, s conversion.Scope)
+ error](#Convert_v1alpha1_VMStatus_To_ignite_VMStatus)
- [func SetDefaults\_OCIImageClaim(obj
\*OCIImageClaim)](#SetDefaults_OCIImageClaim)
- [func SetDefaults\_PoolSpec(obj \*PoolSpec)](#SetDefaults_PoolSpec)
@@ -118,6 +124,15 @@ func Convert_ignite_VMSpec_To_v1alpha1_VMSpec(in *ignite.VMSpec, out *VMSpec, s
Convert\_ignite\_VMSpec\_To\_v1alpha1\_VMSpec calls the autogenerated
conversion function along with custom conversion logic
+## func [Convert\_ignite\_VMStatus\_To\_v1alpha1\_VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=1038:1149#L21)
+
+``` go
+func Convert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error
+```
+
+Convert\_ignite\_VMStatus\_To\_v1alpha1\_VMStatus calls the
+autogenerated conversion function along with custom conversion logic
+
## func [Convert\_v1alpha1\_VMSpec\_To\_ignite\_VMSpec](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=637:740#L15)
``` go
@@ -127,6 +142,15 @@ func Convert_v1alpha1_VMSpec_To_ignite_VMSpec(in *VMSpec, out *ignite.VMSpec, s
Convert\_ignite\_VMSpec\_To\_v1alpha1\_VMSpec calls the autogenerated
conversion function along with custom conversion logic
+## func [Convert\_v1alpha1\_VMStatus\_To\_ignite\_VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/conversion.go?s=1522:1633#L37)
+
+``` go
+func Convert_v1alpha1_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMStatus, s conversion.Scope) error
+```
+
+Convert\_v1alpha1\_VMStatus\_To\_ignite\_VMStatus calls the
+autogenerated conversion function along with custom conversion logic
+
## func [SetDefaults\_OCIImageClaim](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha1/defaults.go?s=263:313#L13)
``` go
diff --git a/docs/api/ignite_v1alpha2.md b/docs/api/ignite_v1alpha2.md
index fb386a366..c26bdbeee 100644
--- a/docs/api/ignite_v1alpha2.md
+++ b/docs/api/ignite_v1alpha2.md
@@ -23,7 +23,6 @@
- [func SetDefaults\_VMNetworkSpec(obj
\*VMNetworkSpec)](#SetDefaults_VMNetworkSpec)
- [func SetDefaults\_VMSpec(obj \*VMSpec)](#SetDefaults_VMSpec)
- - [func SetDefaults\_VMStatus(obj \*VMStatus)](#SetDefaults_VMStatus)
- [type BlockDeviceVolume](#BlockDeviceVolume)
- [type FileMapping](#FileMapping)
- [type Image](#Image)
@@ -52,7 +51,6 @@
- [type VMKernelSpec](#VMKernelSpec)
- [type VMNetworkSpec](#VMNetworkSpec)
- [type VMSpec](#VMSpec)
- - [type VMState](#VMState)
- [type VMStatus](#VMStatus)
- [type VMStorageSpec](#VMStorageSpec)
- [type Volume](#Volume)
@@ -136,12 +134,6 @@ func SetDefaults_VMNetworkSpec(obj *VMNetworkSpec)
func SetDefaults_VMSpec(obj *VMSpec)
```
-## func [SetDefaults\_VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/defaults.go?s=1641:1681#L70)
-
-``` go
-func SetDefaults_VMStatus(obj *VMStatus)
-```
-
## type [BlockDeviceVolume](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8095:8155#L218)
``` go
@@ -493,27 +485,11 @@ type VMSpec struct {
VMSpec describes the configuration of a VM
-## type [VMState](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9336:9355#L261)
-
-``` go
-type VMState string
-```
-
-VMState defines different states a VM can be in
-
-``` go
-const (
- VMStateCreated VMState = "Created"
- VMStateRunning VMState = "Running"
- VMStateStopped VMState = "Stopped"
-)
-```
-
-## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9515:9736#L270)
+## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9324:9547#L261)
``` go
type VMStatus struct {
- State VMState `json:"state"`
+ Running bool `json:"running"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
diff --git a/pkg/apis/ignite/helpers.go b/pkg/apis/ignite/helpers.go
index 043dd87fd..8ab1344f6 100644
--- a/pkg/apis/ignite/helpers.go
+++ b/pkg/apis/ignite/helpers.go
@@ -21,15 +21,6 @@ func GetImageSourceTypes() []ImageSourceType {
}
}
-// GetVMStates gets the list of available VM states
-func GetVMStates() []VMState {
- return []VMState{
- VMStateCreated,
- VMStateRunning,
- VMStateStopped,
- }
-}
-
// SetImage populates relevant fields to an Image on the VM object
func (vm *VM) SetImage(image *Image) {
vm.Spec.Image.OCIClaim = image.Spec.OCIClaim
@@ -50,7 +41,7 @@ func (vm *VM) SnapshotDev() string {
// Running returns true if the VM is running, otherwise false
func (vm *VM) Running() bool {
- return vm.Status.State == VMStateRunning
+ return vm.Status.Running
}
// OverlayFile returns the path to the overlay.dm file for the VM.
diff --git a/pkg/apis/ignite/types.go b/pkg/apis/ignite/types.go
index 05f3c1003..18dd3128f 100644
--- a/pkg/apis/ignite/types.go
+++ b/pkg/apis/ignite/types.go
@@ -257,18 +257,9 @@ const (
// Whenever updating this list, also update GetNetworkModes in helpers.go
)
-// VMState defines different states a VM can be in
-type VMState string
-
-const (
- VMStateCreated VMState = "Created"
- VMStateRunning VMState = "Running"
- VMStateStopped VMState = "Stopped"
-)
-
// VMStatus defines the status of a VM
type VMStatus struct {
- State VMState `json:"state"`
+ Running bool `json:"running"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
diff --git a/pkg/apis/ignite/v1alpha1/conversion.go b/pkg/apis/ignite/v1alpha1/conversion.go
index 59f0191e5..bb9e02cac 100644
--- a/pkg/apis/ignite/v1alpha1/conversion.go
+++ b/pkg/apis/ignite/v1alpha1/conversion.go
@@ -16,3 +16,31 @@ func Convert_v1alpha1_VMSpec_To_ignite_VMSpec(in *VMSpec, out *ignite.VMSpec, s
// VMSpecStorage is not supported by v1alpha1, so just ignore the warning by calling this manually
return autoConvert_v1alpha1_VMSpec_To_ignite_VMSpec(in, out, s)
}
+
+// Convert_ignite_VMStatus_To_v1alpha1_VMStatus calls the autogenerated conversion function along with custom conversion logic
+func Convert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error {
+ if err := autoConvert_ignite_VMStatus_To_v1alpha1_VMStatus(in, out, s); err != nil {
+ return err
+ }
+
+ // Convert in.Running to out.State
+ if in.Running {
+ out.State = VMStateRunning
+ } else {
+ out.State = VMStateStopped
+ }
+
+ return nil
+}
+
+// Convert_v1alpha1_VMStatus_To_ignite_VMStatus calls the autogenerated conversion function along with custom conversion logic
+func Convert_v1alpha1_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMStatus, s conversion.Scope) error {
+ if err := autoConvert_v1alpha1_VMStatus_To_ignite_VMStatus(in, out, s); err != nil {
+ return err
+ }
+
+ // Convert in.State to out.Running
+ out.Running = in.State == VMStateRunning
+
+ return nil
+}
diff --git a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go
index 39fdb7f19..475f32084 100644
--- a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go
+++ b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go
@@ -225,11 +225,21 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
+ if err := s.AddConversionFunc((*ignite.VMStatus)(nil), (*VMStatus)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_ignite_VMStatus_To_v1alpha1_VMStatus(a.(*ignite.VMStatus), b.(*VMStatus), scope)
+ }); err != nil {
+ return err
+ }
if err := s.AddConversionFunc((*VMSpec)(nil), (*ignite.VMSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_VMSpec_To_ignite_VMSpec(a.(*VMSpec), b.(*ignite.VMSpec), scope)
}); err != nil {
return err
}
+ if err := s.AddConversionFunc((*VMStatus)(nil), (*ignite.VMStatus)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_v1alpha1_VMStatus_To_ignite_VMStatus(a.(*VMStatus), b.(*ignite.VMStatus), scope)
+ }); err != nil {
+ return err
+ }
return nil
}
@@ -739,7 +749,7 @@ func autoConvert_ignite_VMSpec_To_v1alpha1_VMSpec(in *ignite.VMSpec, out *VMSpec
}
func autoConvert_v1alpha1_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMStatus, s conversion.Scope) error {
- out.State = ignite.VMState(in.State)
+ // WARNING: in.State requires manual conversion: does not exist in peer-type
out.IPAddresses = *(*metav1alpha1.IPAddresses)(unsafe.Pointer(&in.IPAddresses))
if err := Convert_v1alpha1_OCIImageSource_To_ignite_OCIImageSource(&in.Image, &out.Image, s); err != nil {
return err
@@ -750,13 +760,8 @@ func autoConvert_v1alpha1_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.
return nil
}
-// Convert_v1alpha1_VMStatus_To_ignite_VMStatus is an autogenerated conversion function.
-func Convert_v1alpha1_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMStatus, s conversion.Scope) error {
- return autoConvert_v1alpha1_VMStatus_To_ignite_VMStatus(in, out, s)
-}
-
func autoConvert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error {
- out.State = VMState(in.State)
+ // WARNING: in.Running requires manual conversion: does not exist in peer-type
out.IPAddresses = *(*metav1alpha1.IPAddresses)(unsafe.Pointer(&in.IPAddresses))
if err := Convert_ignite_OCIImageSource_To_v1alpha1_OCIImageSource(&in.Image, &out.Image, s); err != nil {
return err
@@ -766,8 +771,3 @@ func autoConvert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *
}
return nil
}
-
-// Convert_ignite_VMStatus_To_v1alpha1_VMStatus is an autogenerated conversion function.
-func Convert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error {
- return autoConvert_ignite_VMStatus_To_v1alpha1_VMStatus(in, out, s)
-}
diff --git a/pkg/apis/ignite/v1alpha2/defaults.go b/pkg/apis/ignite/v1alpha2/defaults.go
index 4f2f95a3d..e96f85e2e 100644
--- a/pkg/apis/ignite/v1alpha2/defaults.go
+++ b/pkg/apis/ignite/v1alpha2/defaults.go
@@ -67,12 +67,6 @@ func SetDefaults_VMNetworkSpec(obj *VMNetworkSpec) {
}
}
-func SetDefaults_VMStatus(obj *VMStatus) {
- if obj.State == "" {
- obj.State = VMStateCreated
- }
-}
-
func calcMetadataDevSize(obj *PoolSpec) meta.Size {
// The minimum size is 2 MB and the maximum size is 16 GB
minSize := meta.NewSizeFromBytes(2 * constants.MB)
diff --git a/pkg/apis/ignite/v1alpha2/types.go b/pkg/apis/ignite/v1alpha2/types.go
index 73864b604..8a168821d 100644
--- a/pkg/apis/ignite/v1alpha2/types.go
+++ b/pkg/apis/ignite/v1alpha2/types.go
@@ -257,18 +257,9 @@ const (
// Whenever updating this list, also update GetNetworkModes in helpers.go
)
-// VMState defines different states a VM can be in
-type VMState string
-
-const (
- VMStateCreated VMState = "Created"
- VMStateRunning VMState = "Running"
- VMStateStopped VMState = "Stopped"
-)
-
// VMStatus defines the status of a VM
type VMStatus struct {
- State VMState `json:"state"`
+ Running bool `json:"running"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go
index b5284e011..a53f4708e 100644
--- a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go
+++ b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go
@@ -804,7 +804,7 @@ func Convert_ignite_VMSpec_To_v1alpha2_VMSpec(in *ignite.VMSpec, out *VMSpec, s
}
func autoConvert_v1alpha2_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMStatus, s conversion.Scope) error {
- out.State = ignite.VMState(in.State)
+ out.Running = in.Running
out.IPAddresses = *(*v1alpha1.IPAddresses)(unsafe.Pointer(&in.IPAddresses))
if err := Convert_v1alpha2_OCIImageSource_To_ignite_OCIImageSource(&in.Image, &out.Image, s); err != nil {
return err
@@ -821,7 +821,7 @@ func Convert_v1alpha2_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMSt
}
func autoConvert_ignite_VMStatus_To_v1alpha2_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error {
- out.State = VMState(in.State)
+ out.Running = in.Running
out.IPAddresses = *(*v1alpha1.IPAddresses)(unsafe.Pointer(&in.IPAddresses))
if err := Convert_ignite_OCIImageSource_To_v1alpha2_OCIImageSource(&in.Image, &out.Image, s); err != nil {
return err
diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go b/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go
index 61a02be9a..d93a73274 100644
--- a/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go
+++ b/pkg/apis/ignite/v1alpha2/zz_generated.defaults.go
@@ -37,5 +37,4 @@ func SetObjectDefaults_VM(in *VM) {
SetDefaults_VMKernelSpec(&in.Spec.Kernel)
SetDefaults_OCIImageClaim(&in.Spec.Kernel.OCIClaim)
SetDefaults_VMNetworkSpec(&in.Spec.Network)
- SetDefaults_VMStatus(&in.Status)
}
diff --git a/pkg/apis/ignite/validation/validation.go b/pkg/apis/ignite/validation/validation.go
index 619be5e97..5ea530f4d 100644
--- a/pkg/apis/ignite/validation/validation.go
+++ b/pkg/apis/ignite/validation/validation.go
@@ -17,7 +17,6 @@ func ValidateVM(obj *api.VM) (allErrs field.ErrorList) {
allErrs = append(allErrs, ValidateOCIImageClaim(&obj.Spec.Kernel.OCIClaim, field.NewPath(".spec.kernel.ociClaim"))...)
allErrs = append(allErrs, ValidateFileMappings(&obj.Spec.CopyFiles, field.NewPath(".spec.copyFiles"))...)
allErrs = append(allErrs, ValidateVMStorage(&obj.Spec.Storage, field.NewPath(".spec.storage"))...)
- allErrs = append(allErrs, ValidateVMState(obj.Status.State, field.NewPath(".status.state"))...)
// TODO: Add vCPU, memory, disk max and min sizes
return
}
@@ -94,18 +93,3 @@ func ValidateImageSourceType(t api.ImageSourceType, fldPath *field.Path) (allErr
}
return
}
-
-// ValidateVMState validates if an VM state is valid
-func ValidateVMState(s api.VMState, fldPath *field.Path) (allErrs field.ErrorList) {
- found := false
- states := api.GetVMStates()
- for _, state := range states {
- if state == s {
- found = true
- }
- }
- if !found {
- allErrs = append(allErrs, field.Invalid(fldPath, s, fmt.Sprintf("VM state must be one of %v", states)))
- }
- return
-}
diff --git a/pkg/filter/vm.go b/pkg/filter/vm.go
index 3c90ae145..ed3790b18 100644
--- a/pkg/filter/vm.go
+++ b/pkg/filter/vm.go
@@ -38,7 +38,7 @@ func (f *VMFilter) Filter(object meta.Object) (filterer.Match, error) {
return nil, fmt.Errorf("invalid Object type for VMFilter: %T", object)
}
- if vm.Status.State != api.VMStateRunning {
+ if !vm.Running() {
return nil, nil
}
}
diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go
index ab686f44c..d0511d33c 100644
--- a/pkg/openapi/openapi_generated.go
+++ b/pkg/openapi/openapi_generated.go
@@ -1350,9 +1350,9 @@ func schema_pkg_apis_ignite_v1alpha2_VMStatus(ref common.ReferenceCallback) comm
Description: "VMStatus defines the status of a VM",
Type: []string{"object"},
Properties: map[string]spec.Schema{
- "state": {
+ "running": {
SchemaProps: spec.SchemaProps{
- Type: []string{"string"},
+ Type: []string{"boolean"},
Format: "",
},
},
@@ -1380,7 +1380,7 @@ func schema_pkg_apis_ignite_v1alpha2_VMStatus(ref common.ReferenceCallback) comm
},
},
},
- Required: []string{"state", "image", "kernel"},
+ Required: []string{"running", "image", "kernel"},
},
},
Dependencies: []string{
diff --git a/pkg/operations/reconcile/reconcile.go b/pkg/operations/reconcile/reconcile.go
index 747461d6d..67d797da0 100644
--- a/pkg/operations/reconcile/reconcile.go
+++ b/pkg/operations/reconcile/reconcile.go
@@ -39,7 +39,7 @@ func ReconcileManifests(s *manifest.ManifestStorage) {
TypeMeta: *upd.APIType.GetTypeMeta(),
ObjectMeta: *upd.APIType.GetObjectMeta(),
Status: api.VMStatus{
- State: api.VMStateRunning, // TODO: Fix this in StopVM
+ Running: true, // TODO: Fix this in StopVM
},
}
} else {
@@ -61,11 +61,7 @@ func ReconcileManifests(s *manifest.ManifestStorage) {
// TODO: Parallelization
switch upd.Event {
- case update.ObjectEventCreate:
- runHandle(func() error {
- return handleCreate(vm)
- })
- case update.ObjectEventModify:
+ case update.ObjectEventCreate, update.ObjectEventModify:
runHandle(func() error {
return handleChange(vm)
})
@@ -81,45 +77,20 @@ func ReconcileManifests(s *manifest.ManifestStorage) {
}
}
-// TODO: Maybe paralellize these commands?
+// TODO: Maybe parallelize these commands?
func runHandle(fn func() error) {
if err := fn(); err != nil {
log.Errorf("An error occurred when processing a VM update: %v\n", err)
}
}
-func handleCreate(vm *api.VM) error {
- var err error
-
- switch vm.Status.State {
- case api.VMStateCreated:
- err = create(vm)
- case api.VMStateRunning:
- err = start(vm)
- case api.VMStateStopped:
- log.Infof("VM %q was added to git with status Stopped, nothing to do\n", vm.GetUID())
- default:
- log.Infof("Unknown state of VM %q: %s", vm.GetUID().String(), vm.Status.State)
- }
-
- return err
-}
-
func handleChange(vm *api.VM) error {
var err error
- // Newly generated VMs that haven't been started yet are loaded via handleChange
- // with VMStateCreated, so permit changing into the created state for now
- // TODO: Fix this
- switch vm.Status.State {
- case api.VMStateCreated:
- // err = fmt.Errorf("VM %q cannot change into the Created state", vm.GetUID())
- case api.VMStateRunning:
+ if vm.Status.Running {
err = start(vm)
- case api.VMStateStopped:
+ } else {
err = stop(vm)
- default:
- log.Infof("Unknown state of VM %q: %s", vm.GetUID().String(), vm.Status.State)
}
return err