Skip to content

Commit bcd0002

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/678-implement-gpu-passthrough
2 parents d4f6410 + 171102e commit bcd0002

11 files changed

+698
-7
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.1
55
require (
66
github.com/blang/semver/v4 v4.0.0
77
github.com/digitalocean/go-libvirt v0.0.0-20250616175656-5843751af96c
8-
github.com/go-chi/chi/v5 v5.2.3
8+
github.com/go-chi/chi/v5 v5.2.4
99
github.com/go-logr/logr v1.4.3
1010
github.com/google/uuid v1.6.0
1111
github.com/ironcore-dev/controller-utils v0.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZ
9797
github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk=
9898
github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE=
9999
github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc=
100-
github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE=
101-
github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
100+
github.com/go-chi/chi/v5 v5.2.4 h1:WtFKPHwlywe8Srng8j2BhOD9312j9cGUxG1SP4V2cR4=
101+
github.com/go-chi/chi/v5 v5.2.4/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=
102102
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
103103
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
104104
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package server_test
5+
6+
import (
7+
iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
8+
irimeta "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
9+
"github.com/ironcore-dev/libvirt-provider/api"
10+
. "github.com/onsi/ginkgo/v2"
11+
. "github.com/onsi/gomega"
12+
)
13+
14+
var _ = Describe("MachineAnnotationUpdate", func() {
15+
It("should update machine annotation", func(ctx SpecContext) {
16+
By("creating a machine")
17+
createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{
18+
Machine: &iri.Machine{
19+
Metadata: &irimeta.ObjectMetadata{
20+
Labels: map[string]string{
21+
"machinepoolletv1alpha1.MachineUIDLabel": "foobar",
22+
},
23+
},
24+
Spec: &iri.MachineSpec{
25+
Power: iri.Power_POWER_ON,
26+
Class: machineClassx3xlarge,
27+
Volumes: []*iri.Volume{
28+
{
29+
Name: "disk-1",
30+
LocalDisk: &iri.LocalDisk{
31+
SizeBytes: emptyDiskSize,
32+
},
33+
Device: "oda",
34+
},
35+
},
36+
NetworkInterfaces: []*iri.NetworkInterface{
37+
{
38+
Name: "nic-1",
39+
},
40+
},
41+
},
42+
},
43+
})
44+
Expect(err).NotTo(HaveOccurred())
45+
Expect(createResp).NotTo(BeNil())
46+
DeferCleanup(cleanupMachine(createResp.Machine.Metadata.Id))
47+
48+
By("ensuring the machine gets created in the store")
49+
Eventually(func(g Gomega) *api.Machine {
50+
msList, err := machineStore.List(ctx)
51+
g.Expect(err).NotTo(HaveOccurred())
52+
g.Expect(msList).NotTo(BeEmpty())
53+
g.Expect(msList).To(HaveLen(1))
54+
return msList[0]
55+
}).Should(SatisfyAll(
56+
HaveField("Spec.MemoryBytes", int64(8589934592)),
57+
HaveField("Spec.Cpu", int64(4)),
58+
HaveField("Spec.Volumes", ContainElement(SatisfyAll(
59+
HaveField("Name", "disk-1"),
60+
HaveField("Device", "oda"),
61+
))),
62+
HaveField("Spec.NetworkInterfaces", ContainElement(SatisfyAll(
63+
HaveField("Name", "nic-1"),
64+
))),
65+
))
66+
67+
By("updating machine annotations")
68+
_, err = machineClient.UpdateMachineAnnotations(ctx, &iri.UpdateMachineAnnotationsRequest{
69+
MachineId: createResp.Machine.Metadata.Id,
70+
Annotations: map[string]string{
71+
"machinepoolletv1alpha1.MachineUIDLabel": "fooUpdatedAnnotation",
72+
},
73+
})
74+
Expect(err).NotTo(HaveOccurred())
75+
76+
By("ensuring correct annotations updated in store")
77+
Eventually(func(g Gomega) *api.Machine {
78+
msList, err := machineStore.List(ctx)
79+
g.Expect(err).NotTo(HaveOccurred())
80+
g.Expect(msList).NotTo(BeEmpty())
81+
g.Expect(msList).To(HaveLen(1))
82+
return msList[0]
83+
}).Should(SatisfyAll(
84+
HaveField("Metadata.Annotations", HaveKeyWithValue(
85+
api.AnnotationsAnnotation, ContainSubstring("fooUpdatedAnnotation")),
86+
)))
87+
})
88+
})

internal/server/machine_create_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ var _ = Describe("CreateMachine", func() {
2929
})
3030
Expect(err).NotTo(HaveOccurred())
3131
Expect(createResp).NotTo(BeNil())
32-
DeferCleanup(func() {
33-
err := machineStore.Delete(ctx, createResp.Machine.Metadata.Id)
34-
Expect(err).NotTo(HaveOccurred())
35-
})
32+
DeferCleanup(cleanupMachine(createResp.Machine.Metadata.Id))
3633

3734
By("ensuring the correct creation response")
3835
Expect(createResp).Should(SatisfyAll(
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package server_test
5+
6+
import (
7+
iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
8+
irimeta "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
9+
"github.com/ironcore-dev/libvirt-provider/api"
10+
. "github.com/onsi/ginkgo/v2"
11+
. "github.com/onsi/gomega"
12+
)
13+
14+
var _ = Describe("DeleteMachine", func() {
15+
It("should delete a machine", func(ctx SpecContext) {
16+
By("creating a machine")
17+
createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{
18+
Machine: &iri.Machine{
19+
Metadata: &irimeta.ObjectMetadata{
20+
Labels: map[string]string{
21+
"machinepoolletv1alpha1.MachineUIDLabel": "foobar",
22+
},
23+
},
24+
Spec: &iri.MachineSpec{
25+
Power: iri.Power_POWER_ON,
26+
Class: machineClassx3xlarge,
27+
Volumes: []*iri.Volume{
28+
{
29+
Name: "disk-1",
30+
LocalDisk: &iri.LocalDisk{
31+
SizeBytes: emptyDiskSize,
32+
},
33+
Device: "oda",
34+
},
35+
},
36+
NetworkInterfaces: []*iri.NetworkInterface{
37+
{
38+
Name: "nic-1",
39+
},
40+
},
41+
},
42+
},
43+
})
44+
Expect(err).NotTo(HaveOccurred())
45+
Expect(createResp).NotTo(BeNil())
46+
47+
By("ensuring the machine gets created in the store")
48+
Eventually(func(g Gomega) *api.Machine {
49+
msList, err := machineStore.List(ctx)
50+
g.Expect(err).NotTo(HaveOccurred())
51+
g.Expect(msList).NotTo(BeEmpty())
52+
g.Expect(msList).To(HaveLen(1))
53+
return msList[0]
54+
}).Should(SatisfyAll(
55+
HaveField("Spec.MemoryBytes", int64(8589934592)),
56+
HaveField("Spec.Cpu", int64(4)),
57+
))
58+
59+
deleteResp, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{
60+
MachineId: createResp.Machine.Metadata.Id,
61+
})
62+
Expect(err).NotTo(HaveOccurred())
63+
Expect(deleteResp).NotTo(BeNil())
64+
65+
By("ensuring the machine gets deleted from the store")
66+
Eventually(func(g Gomega) []*api.Machine {
67+
msList, err := machineStore.List(ctx)
68+
g.Expect(err).NotTo(HaveOccurred())
69+
return msList
70+
}).Should(BeEmpty())
71+
})
72+
})
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package server_test
5+
6+
import (
7+
iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
8+
irimeta "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
9+
. "github.com/onsi/ginkgo/v2"
10+
. "github.com/onsi/gomega"
11+
)
12+
13+
var _ = Describe("ListMachine", func() {
14+
It("should list machines", func(ctx SpecContext) {
15+
By("creating machines")
16+
createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{
17+
Machine: &iri.Machine{
18+
Metadata: &irimeta.ObjectMetadata{
19+
Labels: map[string]string{
20+
"machinepoolletv1alpha1.MachineUIDLabel": "foo",
21+
},
22+
},
23+
Spec: &iri.MachineSpec{
24+
Power: iri.Power_POWER_ON,
25+
Class: machineClassx3xlarge,
26+
},
27+
},
28+
})
29+
Expect(err).NotTo(HaveOccurred())
30+
Expect(createResp).NotTo(BeNil())
31+
DeferCleanup(cleanupMachine(createResp.Machine.Metadata.Id))
32+
33+
createMachineResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{
34+
Machine: &iri.Machine{
35+
Metadata: &irimeta.ObjectMetadata{
36+
Labels: map[string]string{
37+
"machinepoolletv1alpha1.MachineUIDLabel": "bar",
38+
},
39+
},
40+
Spec: &iri.MachineSpec{
41+
Power: iri.Power_POWER_ON,
42+
Class: machineClassx3xlarge,
43+
},
44+
},
45+
})
46+
Expect(err).NotTo(HaveOccurred())
47+
Expect(createMachineResp).NotTo(BeNil())
48+
DeferCleanup(cleanupMachine(createMachineResp.Machine.Metadata.Id))
49+
50+
By("ensuring the machines gets created in the store")
51+
Eventually(func(g Gomega) {
52+
msList, err := machineStore.List(ctx)
53+
g.Expect(err).NotTo(HaveOccurred())
54+
g.Expect(msList).NotTo(BeEmpty())
55+
g.Expect(msList).To(HaveLen(2))
56+
}).Should(Succeed())
57+
58+
By("listing machines using machine Id")
59+
listResp, err := machineClient.ListMachines(ctx, &iri.ListMachinesRequest{
60+
Filter: &iri.MachineFilter{
61+
Id: createResp.Machine.Metadata.Id,
62+
},
63+
})
64+
Expect(err).NotTo(HaveOccurred())
65+
Expect(listResp.Machines).NotTo(BeEmpty())
66+
Expect(listResp.Machines).Should(HaveLen(1))
67+
68+
By("listing machines using correct Label selector")
69+
listResp, err = machineClient.ListMachines(ctx, &iri.ListMachinesRequest{
70+
Filter: &iri.MachineFilter{
71+
LabelSelector: map[string]string{
72+
"machinepoolletv1alpha1.MachineUIDLabel": "foo",
73+
},
74+
},
75+
})
76+
Expect(err).NotTo(HaveOccurred())
77+
Expect(listResp.Machines).NotTo(BeEmpty())
78+
Expect(listResp.Machines).Should(HaveLen(1))
79+
80+
By("listing machines using incorrect Label selector")
81+
listResp, err = machineClient.ListMachines(ctx, &iri.ListMachinesRequest{
82+
Filter: &iri.MachineFilter{
83+
LabelSelector: map[string]string{
84+
"foo": "wrong",
85+
},
86+
},
87+
})
88+
Expect(err).NotTo(HaveOccurred())
89+
Expect(listResp).NotTo(BeNil())
90+
Expect(listResp.Machines).To(BeEmpty())
91+
})
92+
})
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package server_test
5+
6+
import (
7+
iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
8+
irimeta "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
9+
"github.com/ironcore-dev/libvirt-provider/api"
10+
. "github.com/onsi/ginkgo/v2"
11+
. "github.com/onsi/gomega"
12+
)
13+
14+
var _ = Describe("NetworkInterfaceAttach", func() {
15+
It("should attach a network interface to the machine", func(ctx SpecContext) {
16+
By("creating a machine")
17+
createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{
18+
Machine: &iri.Machine{
19+
Metadata: &irimeta.ObjectMetadata{
20+
Labels: map[string]string{
21+
"machinepoolletv1alpha1.MachineUIDLabel": "foobar",
22+
},
23+
},
24+
Spec: &iri.MachineSpec{
25+
Power: iri.Power_POWER_ON,
26+
Class: machineClassx3xlarge,
27+
},
28+
},
29+
})
30+
Expect(err).NotTo(HaveOccurred())
31+
Expect(createResp).NotTo(BeNil())
32+
DeferCleanup(cleanupMachine(createResp.Machine.Metadata.Id))
33+
34+
By("ensuring the correct creation response")
35+
Expect(createResp).Should(SatisfyAll(
36+
HaveField("Machine.Metadata.Id", Not(BeEmpty())),
37+
HaveField("Machine.Status.NetworkInterfaces", BeNil()),
38+
))
39+
40+
By("ensuring the machine gets created in the store")
41+
Eventually(func(g Gomega) {
42+
msList, err := machineStore.List(ctx)
43+
g.Expect(err).NotTo(HaveOccurred())
44+
g.Expect(msList).NotTo(BeEmpty())
45+
g.Expect(msList).To(HaveLen(1))
46+
}).Should(Succeed())
47+
48+
By("attaching network interface to the machine")
49+
attachNetworkResp, err := machineClient.AttachNetworkInterface(ctx, &iri.AttachNetworkInterfaceRequest{
50+
MachineId: createResp.Machine.Metadata.Id,
51+
NetworkInterface: &iri.NetworkInterface{
52+
Name: "nic-1",
53+
},
54+
})
55+
Expect(err).NotTo(HaveOccurred())
56+
Expect(attachNetworkResp).NotTo(BeNil())
57+
58+
By("ensuring nic information is updated in the store")
59+
Eventually(func(g Gomega) *api.Machine {
60+
msList, err := machineStore.List(ctx)
61+
g.Expect(err).NotTo(HaveOccurred())
62+
g.Expect(msList).NotTo(BeEmpty())
63+
g.Expect(msList).To(HaveLen(1))
64+
return msList[0]
65+
}).Should(SatisfyAll(
66+
HaveField("Spec.NetworkInterfaces", ContainElement(SatisfyAll(
67+
HaveField("Name", "nic-1"),
68+
))),
69+
))
70+
71+
})
72+
73+
})

0 commit comments

Comments
 (0)