Skip to content

Commit 277c693

Browse files
committed
re-enable tests
1 parent fd80300 commit 277c693

16 files changed

+202
-203
lines changed

api/v1alpha2/proxmoxmachine_types.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ type InterfaceConfig struct {
295295
Routing `json:",inline"`
296296

297297
// linkMtu is the network device Maximum Transmission Unit.
298-
// +required
298+
// +optional
299299
LinkMTU MTU `json:"linkMtu,omitempty"`
300300
}
301301

@@ -412,8 +412,9 @@ type NetworkDevice struct {
412412

413413
// name is the network device name.
414414
// +kubebuilder:validation:MinLength=1
415-
// +required
416-
Name string `json:"name,omitempty"`
415+
// +kubebuilder:default=net0
416+
// +optional
417+
Name *string `json:"name,omitempty"`
417418

418419
// InterfaceConfig contains all configurables a network interface can have.
419420
// +optional
@@ -577,7 +578,7 @@ type ProxmoxMachine struct {
577578
Spec *ProxmoxMachineSpec `json:"spec,omitempty"`
578579

579580
// status is the status of the Proxmox machine.
580-
// +required
581+
// +optional
581582
Status ProxmoxMachineStatus `json:"status,omitzero"`
582583
}
583584

api/v1alpha2/proxmoxmachine_types_test.go

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package v1alpha2
1818

1919
import (
2020
"context"
21-
// "strconv"
21+
"strconv"
2222

2323
. "github.com/onsi/ginkgo/v2"
2424
. "github.com/onsi/gomega"
25-
// corev1 "k8s.io/api/core/v1"
25+
corev1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/utils/ptr"
2828
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -60,7 +60,6 @@ var _ = Describe("ProxmoxMachine Test", func() {
6060
})
6161

6262
Context("VirtualMachineCloneSpec", func() {
63-
/* caught by validation
6463
It("Should not allow specifying format if full clone is disabled", func() {
6564
dm := defaultMachine()
6665
dm.Spec.Format = ptr.To(TargetStorageFormatRaw)
@@ -98,16 +97,16 @@ var _ = Describe("ProxmoxMachine Test", func() {
9897
dm := defaultMachine()
9998
dm.Spec.TemplateSelector = &TemplateSelector{MatchTags: []string{"test"}}
10099
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("must define either a SourceNode with a TemplateID or a TemplateSelector")))
101-
})*/
100+
})
102101

103-
/*It("Should not allow specifying TemplateSelector with empty MatchTags", func() {
102+
It("Should not allow specifying TemplateSelector with empty MatchTags", func() {
104103
dm := defaultMachine()
105104
dm.Spec.TemplateSelector = &TemplateSelector{MatchTags: []string{}}
106105

107-
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("should have at least 1 items")))
108-
})*/
106+
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.templateSelector.matchTags: Required value")))
107+
})
109108

110-
/*It("Should only allow valid MatchTags", func() {
109+
It("Should only allow valid MatchTags", func() {
111110
testCases := []struct {
112111
tag string
113112
expectErrror bool
@@ -156,16 +155,16 @@ var _ = Describe("ProxmoxMachine Test", func() {
156155
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring(testCase.errorMessage)))
157156
}
158157
}
159-
})*/
158+
})
160159
})
161160

162161
Context("Disks", func() {
163-
/*It("Should not allow updates to disks", func() {
162+
It("Should not allow updates to disks", func() {
164163
dm := defaultMachine()
165164
Expect(k8sClient.Create(context.Background(), dm)).To(Succeed())
166165
dm.Spec.Disks.BootVolume.SizeGB = 50
167166
Expect(k8sClient.Update(context.Background(), dm)).Should(MatchError(ContainSubstring("is immutable")))
168-
})*/
167+
})
169168

170169
It("Should not allow negative or less than minimum values", func() {
171170
dm := defaultMachine()
@@ -179,7 +178,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
179178
})
180179

181180
Context("Network", func() {
182-
/*It("Should set default bridge", func() {
181+
It("Should set default bridge", func() {
183182
dm := defaultMachine()
184183
dm.Spec.Network = &NetworkSpec{
185184
NetworkDevices: []NetworkDevice{{
@@ -188,15 +187,15 @@ var _ = Describe("ProxmoxMachine Test", func() {
188187
}
189188

190189
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("should be at least 1 chars long")))
191-
})*/
190+
})
192191

193-
/*It("Should not allow net0 in additional network devices", func() {
192+
It("Should not allow net0 in additional network devices", func() {
194193
dm := defaultMachine()
195194
dm.Spec.Network = &NetworkSpec{
196195
NetworkDevices: []NetworkDevice{{
197196
Bridge: ptr.To("vmbr0"),
198197
}, {
199-
Name: "net0",
198+
Name: ptr.To("net0"),
200199
InterfaceConfig: InterfaceConfig{
201200
IPPoolRef: []corev1.TypedLocalObjectReference{{
202201
APIGroup: ptr.To("ipam.cluster.x-k8s.io"),
@@ -207,15 +206,15 @@ var _ = Describe("ProxmoxMachine Test", func() {
207206
}},
208207
}
209208

210-
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("should be at least 1 chars long")))
211-
})*/
209+
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.network.networkDevices[1]: Duplicate value")))
210+
})
212211

213-
/*It("Should only allow IPAM pool resources in IPPoolRef apiGroup", func() {
212+
It("Should only allow IPAM pool resources in IPPoolRef apiGroup", func() {
214213
dm := defaultMachine()
215214
dm.Spec.Network = &NetworkSpec{
216215
NetworkDevices: []NetworkDevice{{
217216
Bridge: ptr.To("vmbr0"),
218-
Name: "net1",
217+
Name: ptr.To("net1"),
219218
InterfaceConfig: InterfaceConfig{
220219
IPPoolRef: []corev1.TypedLocalObjectReference{{
221220
APIGroup: ptr.To("apps"),
@@ -232,7 +231,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
232231
dm.Spec.Network = &NetworkSpec{
233232
NetworkDevices: []NetworkDevice{{
234233
Bridge: ptr.To("vmbr0"),
235-
Name: "net1",
234+
Name: ptr.To("net1"),
236235
InterfaceConfig: InterfaceConfig{
237236
IPPoolRef: []corev1.TypedLocalObjectReference{{
238237
APIGroup: ptr.To("ipam.cluster.x-k8s.io"),
@@ -269,7 +268,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
269268
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("invalid MTU value")))
270269
})
271270

272-
It("Should only allow VRFS with a non kernel routing table ", func() {
271+
/*It("Should only allow VRFS with a non kernel routing table ", func() {
273272
dm := defaultMachine()
274273
dm.Spec.Network = &NetworkSpec{
275274
VirtualNetworkDevices: VirtualNetworkDevices{
@@ -281,9 +280,9 @@ var _ = Describe("ProxmoxMachine Test", func() {
281280
}
282281
283282
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Cowardly refusing to insert l3mdev rules into kernel tables")))
284-
})
283+
})*/
285284

286-
It("Should only allow non kernel FIB rule priority", func() {
285+
/*It("Should only allow non kernel FIB rule priority", func() {
287286
dm := defaultMachine()
288287
dm.Spec.Network = &NetworkSpec{
289288
VirtualNetworkDevices: VirtualNetworkDevices{
@@ -292,7 +291,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
292291
Table: 100,
293292
Routing: Routing{
294293
RoutingPolicy: []RoutingPolicySpec{{
295-
Priority: ptr.To(uint32(32766)),
294+
Priority: ptr.To(int64(32766)),
296295
}},
297296
},
298297
}},
@@ -342,7 +341,6 @@ var _ = Describe("ProxmoxMachine Test", func() {
342341
}
343342
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("should be greater than or equal to 100")))
344343
})
345-
/* rejected by validation
346344
It("Should only allow spec.vmIDRange.end >= spec.vmIDRange.start", func() {
347345
dm := defaultMachine()
348346
dm.Spec.VMIDRange = &VMIDRange{
@@ -356,15 +354,15 @@ var _ = Describe("ProxmoxMachine Test", func() {
356354
dm.Spec.VMIDRange = &VMIDRange{
357355
Start: 100,
358356
}
359-
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.vmIDRange.end in body should be greater than or equal to 100")))
357+
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.vmIDRange.end: Required value")))
360358
})
361359
It("Should only allow spec.vmIDRange.end if spec.vmIDRange.start is set", func() {
362360
dm := defaultMachine()
363361
dm.Spec.VMIDRange = &VMIDRange{
364362
End: 100,
365363
}
366-
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.vmIDRange.start in body should be greater than or equal to 100")))
367-
})*/
364+
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.vmIDRange.start: Required value")))
365+
})
368366
})
369367

370368
Context("Tags", func() {
@@ -386,12 +384,12 @@ var _ = Describe("ProxmoxMachine Test", func() {
386384
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Invalid value")))
387385
})
388386

389-
/*It("Should not allow duplicated tags", func() {
387+
It("Should not allow duplicated tags", func() {
390388
dm := defaultMachine()
391389
dm.Spec.Tags = []string{"foo", "bar", "foo"}
392390
Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Duplicate value")))
393391
dm.Spec.Tags = []string{"foo", "bar"}
394392
Expect(k8sClient.Create(context.Background(), dm)).To(Succeed())
395-
})*/
393+
})
396394
})
397395
})

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ spec:
13021302
rule: self == 1 || ( self >= 576 && self <=
13031303
65520)
13041304
name:
1305+
default: net0
13051306
description: name is the network device name.
13061307
minLength: 1
13071308
type: string
@@ -1373,9 +1374,6 @@ spec:
13731374
maximum: 4094
13741375
minimum: 1
13751376
type: integer
1376-
required:
1377-
- linkMtu
1378-
- name
13791377
type: object
13801378
type: array
13811379
x-kubernetes-list-map-keys:

config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclustertemplates.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ spec:
11861186
rule: self == 1 || ( self >= 576 &&
11871187
self <= 65520)
11881188
name:
1189+
default: net0
11891190
description: name is the network device
11901191
name.
11911192
minLength: 1
@@ -1263,9 +1264,6 @@ spec:
12631264
maximum: 4094
12641265
minimum: 1
12651266
type: integer
1266-
required:
1267-
- linkMtu
1268-
- name
12691267
type: object
12701268
type: array
12711269
x-kubernetes-list-map-keys:

config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ spec:
10961096
- message: invalid MTU value
10971097
rule: self == 1 || ( self >= 576 && self <= 65520)
10981098
name:
1099+
default: net0
10991100
description: name is the network device name.
11001101
minLength: 1
11011102
type: string
@@ -1162,9 +1163,6 @@ spec:
11621163
maximum: 4094
11631164
minimum: 1
11641165
type: integer
1165-
required:
1166-
- linkMtu
1167-
- name
11681166
type: object
11691167
type: array
11701168
x-kubernetes-list-map-keys:
@@ -1595,7 +1593,6 @@ spec:
15951593
type: object
15961594
required:
15971595
- spec
1598-
- status
15991596
type: object
16001597
served: true
16011598
storage: true

config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ spec:
961961
- message: invalid MTU value
962962
rule: self == 1 || ( self >= 576 && self <= 65520)
963963
name:
964+
default: net0
964965
description: name is the network device name.
965966
minLength: 1
966967
type: string
@@ -1031,9 +1032,6 @@ spec:
10311032
maximum: 4094
10321033
minimum: 1
10331034
type: integer
1034-
required:
1035-
- linkMtu
1036-
- name
10371035
type: object
10381036
type: array
10391037
x-kubernetes-list-map-keys:

internal/service/vmservice/bootstrap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ func getNetworkDevices(ctx context.Context, machineScope *scope.MachineScope, ne
328328
var config = ptr.To(types.NetworkConfigData{})
329329

330330
// TODO: Default device IPPool
331-
conf, err := getNetworkConfigDataForDevice(ctx, machineScope, nic.Name, nic.InterfaceConfig.IPPoolRef)
331+
conf, err := getNetworkConfigDataForDevice(ctx, machineScope, *nic.Name, nic.InterfaceConfig.IPPoolRef)
332332
if err != nil {
333-
return nil, errors.Wrapf(err, "unable to get network config data for device=%s", nic.Name)
333+
return nil, errors.Wrapf(err, "unable to get network config data for device=%s", *nic.Name)
334334
}
335335
if len(nic.DNSServers) != 0 {
336336
config.DNSServers = nic.DNSServers
@@ -341,7 +341,7 @@ func getNetworkDevices(ctx context.Context, machineScope *scope.MachineScope, ne
341341

342342
config.Name = fmt.Sprintf("eth%d", i)
343343
config.Type = "ethernet"
344-
config.ProxName = nic.Name
344+
config.ProxName = *nic.Name
345345

346346
// TODO: Figure device names for eth0
347347
if i == 0 {

0 commit comments

Comments
 (0)