Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/core/v1alpha2/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
// +kubebuilder:printcolumn:name="Migratable",priority=1,type="string",JSONPath=".status.conditions[?(@.type=='Migratable')].status",description="Is it possible to migrate a virtual machine."
// +kubebuilder:printcolumn:name="Node",type="string",JSONPath=".status.nodeName",description="The node where the virtual machine is running."
// +kubebuilder:printcolumn:name="IPAddress",type="string",JSONPath=".status.ipAddress",description="The IP address of the virtual machine."
// +kubebuilder:printcolumn:name="BlockDevicesCount",priority=1,type="integer",JSONPath=".status.blockDevicesCount",description="The number of block devices attached to the virtual machine."
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time of creation resource."
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -298,6 +299,8 @@ type VirtualMachineStatus struct {
Stats *VirtualMachineStats `json:"stats,omitempty"`
// Migration info.
MigrationState *VirtualMachineMigrationState `json:"migrationState,omitempty"`
// The number of block devices attached to the virtual machine.
BlockDevicesCount int `json:"blockDevicesCount,omitempty"`
// Generating a resource that was last processed by the controller.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

Expand Down
8 changes: 8 additions & 0 deletions crds/virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,9 @@ spec:
items:
type: object
x-kubernetes-preserve-unknown-fields: true
blockDevicesCount:
type: integer
description: Number of block devices attached to the virtual machine.
observedGeneration:
type: integer
description: Resource generation last processed by the controller.
Expand Down Expand Up @@ -1460,6 +1463,11 @@ spec:
jsonPath: .status.ipAddress
name: IPAddress
type: string
- description: The number of block devices attached to the virtual machine.
jsonPath: .status.blockDevicesCount
name: BlockDevicesCount
priority: 1
type: integer
- description: Time of resource creation.
jsonPath: .metadata.creationTimestamp
name: Age
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ func (h *BlockDeviceHandler) Handle(ctx context.Context, s state.VirtualMachineS
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to get block device status refs: %w", err)
}
blockDeviceCount := 0
for _, bd := range changed.Status.BlockDeviceRefs {
if bd.Attached {
blockDeviceCount++
}
}
changed.Status.BlockDevicesCount = blockDeviceCount

shouldStop, err = h.handleBlockDeviceConflicts(ctx, s, log)
if err != nil {
Expand Down
Loading