Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #294 from twelho/runtime-id
Browse files Browse the repository at this point in the history
Add `runtime.id` for tracking the VM container's ID
  • Loading branch information
luxas committed Aug 8, 2019
2 parents 0657c0c + e883d8f commit 0b216e1
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/ignite-spawn/ignite-spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func patchStopped(vm *api.VM) error {
return patchVM(vm, func(patchVM *api.VM) error {
patchVM.Status.Running = false
patchVM.Status.IPAddresses = nil
patchVM.Status.Runtime = nil
return nil
})
}
Expand Down
14 changes: 13 additions & 1 deletion docs/api/ignite_v1alpha2.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- [type PoolDeviceType](#PoolDeviceType)
- [type PoolSpec](#PoolSpec)
- [type PoolStatus](#PoolStatus)
- [type Runtime](#Runtime)
- [type SSH](#SSH)
- [func (s \*SSH) MarshalJSON() (\[\]byte,
error)](#SSH.MarshalJSON)
Expand Down Expand Up @@ -389,6 +390,16 @@ type PoolStatus struct {

PoolStatus defines the Pool’s current status

## <a name="Runtime">type</a> [Runtime](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9335:9381#L261)

``` go
type Runtime struct {
ID string `json:"id"`
}
```

Runtime specifies the VM’s runtime information

## <a name="SSH">type</a> [SSH](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=8705:8782#L238)

``` go
Expand Down Expand Up @@ -485,11 +496,12 @@ type VMSpec struct {

VMSpec describes the configuration of a VM

## <a name="VMStatus">type</a> [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9324:9547#L261)
## <a name="VMStatus">type</a> [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9422:9702#L266)

``` go
type VMStatus struct {
Running bool `json:"running"`
Runtime *Runtime `json:"runtime,omitempty"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/ignite/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,15 @@ const (
// Whenever updating this list, also update GetNetworkModes in helpers.go
)

// Runtime specifies the VM's runtime information
type Runtime struct {
ID string `json:"id"`
}

// VMStatus defines the status of a VM
type VMStatus struct {
Running bool `json:"running"`
Runtime *Runtime `json:"runtime,omitempty"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/ignite/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/apis/ignite/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,15 @@ const (
// Whenever updating this list, also update GetNetworkModes in helpers.go
)

// Runtime specifies the VM's runtime information
type Runtime struct {
ID string `json:"id"`
}

// VMStatus defines the status of a VM
type VMStatus struct {
Running bool `json:"running"`
Runtime *Runtime `json:"runtime,omitempty"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
Expand Down
32 changes: 32 additions & 0 deletions pkg/apis/ignite/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/apis/ignite/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion pkg/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion pkg/operations/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func StartVM(vm *api.VM, debug bool) error {
return fmt.Errorf("failed to start container for VM %q: %v", vm.GetUID(), err)
}

// Set the container ID for the VM
vm.Status.Runtime = &api.Runtime{ID: containerID}

if vm.Spec.Network.Mode == api.NetworkModeCNI {
if err := providers.NetworkPlugin.SetupContainerNetwork(containerID); err != nil {
return err
Expand All @@ -120,7 +123,16 @@ func StartVM(vm *api.VM, debug bool) error {
// TODO: Follow-up the container here with a defer, or dedicated goroutine. We should output
// if it started successfully or not
// TODO: This is temporary until we have proper communication to the container
return waitForSpawn(vm)
if err := waitForSpawn(vm); err != nil {
return err
}

// TODO: Enable this when ignite-spawn doesn't write to the file anymore
//if err := providers.Client.VMs().Set(vm); err != nil {
// return err
//}

return nil
}

func verifyPulled(image string) error {
Expand Down

0 comments on commit 0b216e1

Please sign in to comment.