Skip to content

Commit 86b57d7

Browse files
committed
feat(api): add new controllers vmmac and vmmaclease
Signed-off-by: Dmitry Lopatin <[email protected]>
1 parent 9d4ce99 commit 86b57d7

File tree

18 files changed

+143
-124
lines changed

18 files changed

+143
-124
lines changed

api/core/v1alpha2/virtual_machine.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ const (
261261
)
262262

263263
type NetworksSpec struct {
264-
Type string `json:"type"`
265-
Name string `json:"name"`
264+
Type string `json:"type"`
265+
Name string `json:"name,omitempty"`
266+
VirtualMachineMACAddressName string `json:"virtualMachineMACAddressName,omitempty"`
266267
}
267268

268269
const (
@@ -422,9 +423,9 @@ type Versions struct {
422423

423424
type NetworksStatus struct {
424425
Type string `json:"type"`
425-
Name string `json:"name"`
426-
MAC string `json:"macAddress"`
427-
VirtualMachineMACAddressName string `json:"virtualMachineMACAddressName"`
426+
Name string `json:"name,omitempty"`
427+
MAC string `json:"macAddress,omitempty"`
428+
VirtualMachineMACAddressName string `json:"virtualMachineMACAddressName,omitempty"`
428429
}
429430

430431
// MachinePhase defines current phase of the virtual machine:

api/core/v1alpha2/vmcondition/condition.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
TypeFirmwareUpToDate Type = "FirmwareUpToDate"
4545
// TypeNeedsEvict indicates that the VirtualMachine should be evicting from node.
4646
TypeNeedsEvict Type = "NeedsEvict"
47-
47+
// TypeNetworkReady indicates the state of additional network interfaces inside the virtual machine pod
4848
TypeNetworkReady Type = "NetworkReady"
4949
)
5050

@@ -126,7 +126,10 @@ const (
126126
// ReasonNeedsEvict indicates that the VirtualMachine should be evicting from node.
127127
ReasonNeedsEvict Reason = "NeedsEvict"
128128

129-
ReasonNetworkReady Reason = "NetworkReady"
130-
ReasonNetworkNotReady Reason = "NetworkNotReady"
129+
// ReasonNetworkReady indicates that the additional network interfaces in the virtual machine pod are ready.
130+
ReasonNetworkReady Reason = "NetworkReady"
131+
// ReasonNetworkNotReady indicates that the additional network interfaces in the virtual machine pod are not ready.
132+
ReasonNetworkNotReady Reason = "NetworkNotReady"
133+
// ReasonSDNModuleDisable indicates that the SDN module is disabled, which may prevent network interfaces from becoming ready.
131134
ReasonSDNModuleDisable Reason = "SDNModuleDisable"
132135
)

crds/doc-ru-virtualmachinemacaddresses.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ spec:
44
schema:
55
openAPIV3Schema:
66
description: |
7-
Ресурс, определяющий MAC-адрес для виртуальной машины.
7+
Ресурс предназначен для генерации MAC-адреса из заданного диапазона и его последующего назначения сетевому интерфейсу виртуальной машины.
88
properties:
99
spec:
1010
description: |
1111
Настройки `VirtualMachineMACAddress`.
1212
properties:
1313
address:
1414
description: |
15-
Запрашиваемый MAC-адрес, который должен быть присвоен виртуальной машине. Если поле пустое, назначается случайный адрес.
15+
Запрашиваемый MAC-адрес, который должен быть присвоен сетевому интерфейсу виртуальной машине. Если поле пустое, назначается случайный адрес из заданного диапазона адресов.
1616
status:
1717
properties:
1818
conditions:

crds/doc-ru-virtualmachinemacaddressleases.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ spec:
44
schema:
55
openAPIV3Schema:
66
description: |
7-
Ресурс, определяющий факт выданной аренды для `VirtualMachineMACAddress`.
7+
Ресурс обеспечивает резервирование MAC-адреса для сетевого интерфейса виртуальной машины, фиксируя факт его аллокации в объекте `VirtualMachineMACAddress` и предотвращая повторное выделение.
88
properties:
99
spec:
1010
description: |

crds/doc-ru-virtualmachines.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,10 @@ spec:
558558
name:
559559
description: |
560560
Имя сетевого интерфейса.
561+
virtualMachineMACAddressName:
562+
type: string
563+
description: |
564+
Имя ресурса `VirtualMachineMACAddress`, связанного с сетевым интерфейсом.
561565
status:
562566
properties:
563567
blockDeviceRefs:

crds/virtualmachinemacaddresses.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
schema:
2424
openAPIV3Schema:
2525
description: |
26-
The resource that defines MAC address for virtual machine.
26+
The requested MAC address to be assigned to the virtual machine's network interface. If the field is empty, a random address from the specified address range is assigned.
2727
properties:
2828
apiVersion:
2929
type: string
@@ -37,7 +37,7 @@ spec:
3737
properties:
3838
address:
3939
description: |
40-
The requested MAC address that should be assigned to the virtual machine. Random address is assigned if empty.
40+
The requested MAC address to be assigned to the virtual machine's network interface. If the field is empty, a random address from the specified address range is assigned.
4141
type: string
4242
type: object
4343
status:

crds/virtualmachinemacaddressleases.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
schema:
2525
openAPIV3Schema:
2626
description: |
27-
The resource that defines fact of issued lease for `VirtualMachineMACAddress`.
27+
The resource reserves a MAC address for a virtual machine's network interface, recording its allocation in the `VirtualMachineMACAddress` object and preventing it from being assigned again.
2828
properties:
2929
apiVersion:
3030
type: string

crds/virtualmachines.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,10 @@ spec:
976976
type: string
977977
description: |
978978
The name of the network interface.
979+
virtualMachineMACAddressName:
980+
type: string
981+
description: |
982+
The name of the `VirtualMachineMACAddress` resource that is associated with the network interface.
979983
status:
980984
type: object
981985
properties:

images/virtualization-artifact/cmd/virtualization-controller/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ func main() {
133133
var virtControllerName string
134134
pflag.StringVar(&virtControllerName, "virt-controller-name", getEnv(VirtControllerNameEnv, "virt-controller"), "Virt controller name")
135135

136-
var clusterUUID string
137-
pflag.StringVar(&clusterUUID, "cluster-uuid", getEnv(clusterUUIDEnv, ""), "Cluster UUID")
138-
139136
var leaderElection bool
140137
pflag.BoolVar(&leaderElection, "leader-election", true, "Leader election")
141138

images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,11 @@ func setNetwork(kvvm *KVVM, networkSpec network.InterfaceSpecList) {
262262
}
263263

264264
func setNetworksAnnotation(kvvm *KVVM, networkSpec network.InterfaceSpecList) error {
265-
if len(networkSpec) > 1 {
266-
networkConfig := networkSpec
267-
networkConfigStr, err := networkConfig.ToString()
268-
if err != nil {
269-
return err
270-
}
271-
kvvm.SetKVVMIAnnotation(annotations.AnnNetworksSpec, networkConfigStr)
265+
networkConfig := networkSpec
266+
networkConfigStr, err := networkConfig.ToString()
267+
if err != nil {
268+
return err
272269
}
270+
kvvm.SetKVVMIAnnotation(annotations.AnnNetworksSpec, networkConfigStr)
273271
return nil
274272
}

0 commit comments

Comments
 (0)