Skip to content

Commit 51ad727

Browse files
committed
Add hostname to NetworkInterface object
Signed-off-by: Guvenc Gulce <[email protected]>
1 parent f18b6eb commit 51ad727

9 files changed

+27
-3
lines changed

.github/workflows/publish-docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
paths-ignore:
1818
- 'docs/**'
1919
- '**/*.md'
20+
types: [labeled, unlabeled, opened, synchronize, reopened]
2021

2122
jobs:
2223
buildAndPush:
@@ -60,7 +61,6 @@ jobs:
6061
version: latest
6162
endpoint: builders # self-hosted
6263
- name: Login to GHCR
63-
if: github.event_name != 'pull_request'
6464
uses: docker/login-action@v3
6565
with:
6666
registry: ghcr.io
@@ -72,6 +72,6 @@ jobs:
7272
with:
7373
context: .
7474
platforms: ${{env.platforms}}
75-
push: ${{ github.event_name != 'pull_request' }}
75+
push: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))) || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-image')) }}
7676
tags: ${{ steps.meta.outputs.tags }}
7777
labels: ${{ steps.meta.outputs.labels }}

api/v1alpha1/networkinterface_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type NetworkInterfaceSpec struct {
4040
FirewallRules []FirewallRule `json:"firewallRules,omitempty"`
4141
// MeteringRate are the metering parameters to be applied to this interface.
4242
MeteringRate *MeteringParameters `json:"meteringRate,omitempty"`
43+
// Hostname is the hostname which should be announced by the network interface.
44+
Hostname *string `json:"hostname,omitempty"`
4345
}
4446

4547
// NetworkInterfaceStatus defines the observed state of NetworkInterface

api/v1alpha1/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/networking.metalnet.ironcore.dev_networkinterfaces.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ spec:
168168
- ipFamily
169169
type: object
170170
type: array
171+
hostname:
172+
description: Hostname is the hostname which should be announced by
173+
the network interface.
174+
type: string
171175
ipFamilies:
172176
description: |-
173177
IPFamilies defines which IPFamilies this NetworkInterface is supporting

controllers/controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ var _ = Describe("Network Controller", Label("network"), Ordered, func() {
133133
Addr: netip.MustParseAddr("10.0.0.3"),
134134
},
135135
},
136+
Hostname: &testHost,
136137
},
137138
}
138139

controllers/networkinterface_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ func (r *NetworkInterfaceReconciler) getInterfaceMeteringParams(nic *metalnetv1a
12451245

12461246
func (r *NetworkInterfaceReconciler) applyInterface(ctx context.Context, log logr.Logger, nic *metalnetv1alpha1.NetworkInterface, vni uint32) (*ghw.PCIAddress, netip.Addr, bool, error) {
12471247
log.V(1).Info("Getting dpdk interface")
1248+
var hostName = ""
1249+
12481250
iface, err := r.DPDK.GetInterface(ctx, string(nic.UID))
12491251
if err != nil {
12501252
if !dpdkerrors.IsStatusErrorCode(err, dpdkerrors.NOT_FOUND) {
@@ -1277,6 +1279,10 @@ func (r *NetworkInterfaceReconciler) applyInterface(ctx context.Context, log log
12771279
return nil, netip.Addr{}, false, fmt.Errorf("error getting metering params: %w", err)
12781280
}
12791281

1282+
if nic.Spec.Hostname != nil {
1283+
hostName = *nic.Spec.Hostname
1284+
}
1285+
12801286
iface, err := r.DPDK.CreateInterface(ctx, &dpdk.Interface{
12811287
InterfaceMeta: dpdk.InterfaceMeta{ID: string(nic.UID)},
12821288
Spec: dpdk.InterfaceSpec{
@@ -1285,6 +1291,7 @@ func (r *NetworkInterfaceReconciler) applyInterface(ctx context.Context, log log
12851291
IPv4: &primaryIpv4,
12861292
IPv6: &primaryIpv6,
12871293
Metering: meteringParams,
1294+
HostName: hostName,
12881295
},
12891296
})
12901297
if err != nil {

controllers/suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var (
4646
ctxGrpc context.Context
4747
dpserviceAddr string = "127.0.0.1:1337"
4848
testNode string = "testNode"
49+
testHost string = "testhost"
4950
metalnetDir string = "/tmp/var/lib/metalnet"
5051
netFnsManager *netfns.Manager
5152
conn *grpc.ClientConn

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/go-logr/logr v1.4.2
77
github.com/hashicorp/go-version v1.7.0
88
github.com/ironcore-dev/controller-utils v0.9.3
9-
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.11
9+
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.16
1010
github.com/ironcore-dev/ironcore v0.1.2
1111
github.com/ironcore-dev/metalbond v0.3.5
1212
github.com/jaypipes/ghw v0.12.0

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ github.com/ironcore-dev/controller-utils v0.9.3 h1:sTrnxSzX5RrLf4B8KrAH2axSC+gxf
6363
github.com/ironcore-dev/controller-utils v0.9.3/go.mod h1:djKnxDs0Hwxhhc0VmVY8tZnrOrElvrRV2jov/LiCZ2Y=
6464
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.11 h1:m+enb4dHIfhL6s5ca5PFNq6leLnb1nvmXefIRyGlsgE=
6565
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.11/go.mod h1:d5x2tPmu1yqrVHac/FvL+MFOeEb3IT4gn7Bj4+Xkj8M=
66+
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.14-0.20250408102508-69f164478fe9 h1:Nz5L0DkFGyzn8qSpf3gkHUO+ATXTMv7oRhjXjAq2Nbw=
67+
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.14-0.20250408102508-69f164478fe9/go.mod h1:d5x2tPmu1yqrVHac/FvL+MFOeEb3IT4gn7Bj4+Xkj8M=
68+
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.16 h1:gRd8IUsbMhN+5ZU9Ql8E+7lR88VKVmSKmIF0w2lCc14=
69+
github.com/ironcore-dev/dpservice/go/dpservice-go v0.3.16/go.mod h1:d5x2tPmu1yqrVHac/FvL+MFOeEb3IT4gn7Bj4+Xkj8M=
6670
github.com/ironcore-dev/ironcore v0.1.2 h1:zYxKEZ+xXeQ7KVBPgYj+W3D4mlR6sCVJaFKUzfuR204=
6771
github.com/ironcore-dev/ironcore v0.1.2/go.mod h1:ircFIizjXLGUU2r5utcYe/feMnwMZVJuyFZGAWmsmLQ=
6872
github.com/ironcore-dev/metalbond v0.3.5 h1:H+kXba0F/m2rjcAClU0I8Am/gBsFOQkf5icJBC2S8/I=

0 commit comments

Comments
 (0)