Skip to content

Add hostname support to Machine via GuestConfig - #1454

Merged
afritzler merged 3 commits into
ironcore-dev:mainfrom
opensovereigncloud:osc/enh/machine_hostname
May 5, 2026
Merged

afritzler merged 3 commits into
ironcore-dev:mainfrom
opensovereigncloud:osc/enh/machine_hostname

Conversation

@ushabelgur

@ushabelgur ushabelgur commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Add guestConfig along with hostname to Machine type, which will allow users to specify a hostname for a Machine
  • Add validation for hostname field
  • Update machine proto to pass down hostname information
  • Update broker and poollet code to pass hostname info.

Fixes #1450

Summary by CodeRabbit

  • New Features
    • Optional guest hostname on machine specs — users can set a guest OS hostname at creation; client apply helpers and API schemas support it.
  • Behavior Changes
    • Hostname must be a valid DNS label and is immutable once set; attempts to clear or change it are rejected.
  • Tests
    • Added validation and end-to-end tests to ensure hostname propagation and enforcement.

@github-actions github-actions Bot added size/L enhancement New feature or request labels Mar 12, 2026
@ushabelgur
ushabelgur marked this pull request as ready for review March 12, 2026 10:30
@ushabelgur
ushabelgur requested a review from a team March 12, 2026 10:30
@coderabbitai

coderabbitai Bot commented Mar 12, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an optional GuestConfig (with Hostname) to MachineSpec and propagates it through API types, conversions, deepcopy/generated clients, validation, IRI protobuf, broker creation logic, and poollet controller/tests. Validation enforces DNS-label format and immutability rules for spec.guestConfig.hostname.

Changes

Cohort / File(s) Summary
API Types
api/compute/v1alpha1/machine_types.go, internal/apis/compute/machine_types.go
Add MachineGuestConfig (Hostname string) and GuestConfig *MachineGuestConfig to MachineSpec.
Deepcopy & Model Metadata
api/compute/v1alpha1/zz_generated.deepcopy.go, internal/apis/compute/zz_generated.deepcopy.go, api/compute/v1alpha1/zz_generated.model_name.go
Generated deepcopy methods for MachineGuestConfig, updated MachineSpec.DeepCopyInto, and added model name method for OpenAPI.
Conversions
internal/apis/compute/v1alpha1/zz_generated.conversion.go
Register and implement conversions between v1alpha1 and internal MachineGuestConfig; propagate GuestConfig in MachineSpec conversions.
Validation & Tests
internal/apis/compute/validation/machine.go, internal/apis/compute/validation/machine_test.go
Validate spec.guestConfig.hostname as DNS label; add immutability/change-restriction checks and corresponding unit tests (four cases).
Client-Go Apply Configs & Utils
client-go/applyconfigurations/compute/v1alpha1/machineguestconfig.go, client-go/applyconfigurations/compute/v1alpha1/machinespec.go, client-go/applyconfigurations/utils.go
Add MachineGuestConfigApplyConfiguration, builder WithHostname, WithGuestConfig, and register kind handling in ForKind.
OpenAPI Schema
client-go/openapi/zz_generated.openapi.go
Add OpenAPI schema for MachineGuestConfig and reference it from MachineSpec schema.
IRI Protobuf
iri/apis/machine/v1alpha1/api.proto
Add message GuestConfig { string hostname = 1; } and MachineSpec guest_config = 6;.
Broker: create & conversion
broker/machinebroker/server/machine_create.go, broker/machinebroker/server/machine_create_test.go, broker/machinebroker/server/machine.go
Add internal IroncoreGuestConfig, map GuestConfig.Hostname during config extraction and machine creation; populate iri.MachineSpec.GuestConfig; test verifies hostname propagation.
Poollet controller & test
poollet/machinepoollet/controllers/machine_controller.go, poollet/machinepoollet/controllers/machine_controller_test.go
Map machine.Spec.GuestConfigiri.GuestConfig in prepareIRIMachine; update test to assert propagation.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant API as "Kubernetes API"
    participant Poollet as "Machine Poollet"
    participant Broker as "Machine Broker"
    participant IRI as "IRI / protobuf"
    User->>API: Create Machine (spec.guestConfig.hostname)
    API->>Poollet: watch/create Machine resource
    Poollet->>IRI: prepareIRIMachine (include GuestConfig if set)
    Poollet->>Broker: send IRI Machine request
    Broker->>IRI: convert & populate GuestConfig in IRI MachineSpec
    Broker->>Broker: create IronCore Machine with GuestConfig
    Broker-->>API: creation result persisted
    API-->>User: creation acknowledged
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the template structure with clear proposed changes and a reference to the linked issue (#1450).
Linked Issues check ✅ Passed The PR fully addresses the primary objective from issue #1450 by implementing Option 2 (structured guestConfig approach) with validation, API updates, and propagation through broker/poollet layers.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the linked issue objectives: adding guestConfig with hostname, validation, proto updates, and broker/poollet propagation.
Title check ✅ Passed The title directly and clearly describes the main change: adding hostname support to the Machine type via a new GuestConfig field.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/apis/compute/validation/machine_test.go (1)

577-608: LGTM!

The tests correctly cover the two key validation scenarios:

  1. Clearing an existing hostname produces an InvalidField error
  2. Changing an existing hostname produces an ImmutableField error

Consider adding test cases for:

  • Invalid hostname format (e.g., underscores, uppercase, exceeds 63 chars) to verify DNS label validation
  • Setting hostname on a machine that previously had GuestConfig: nil (should be allowed)

These would provide more comprehensive coverage of the hostname validation rules.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/apis/compute/validation/machine_test.go` around lines 577 - 608, Add
two new Ginkgo table entries next to the existing "remove hostname if set" and
"immutable hostname if set" cases in
internal/apis/compute/validation/machine_test.go: (1) an "invalid hostname
format" entry that supplies a Machine with a GuestConfig.Hostname containing
invalid DNS label examples (underscore, uppercase, >63 chars) and expects
ContainElement(InvalidField("spec.guestConfig.hostname")); (2) an "allow set
hostname when previously nil" entry that uses an old Machine with
Spec.GuestConfig == nil and a new Machine with GuestConfig.Hostname set and
expects Not(ContainElement(ImmutableField("spec.guestConfig.hostname"))) or no
validation error for that field; place these alongside the existing Entry items
so they run in the same table-driven test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/apis/compute/validation/machine_test.go`:
- Around line 577-608: Add two new Ginkgo table entries next to the existing
"remove hostname if set" and "immutable hostname if set" cases in
internal/apis/compute/validation/machine_test.go: (1) an "invalid hostname
format" entry that supplies a Machine with a GuestConfig.Hostname containing
invalid DNS label examples (underscore, uppercase, >63 chars) and expects
ContainElement(InvalidField("spec.guestConfig.hostname")); (2) an "allow set
hostname when previously nil" entry that uses an old Machine with
Spec.GuestConfig == nil and a new Machine with GuestConfig.Hostname set and
expects Not(ContainElement(ImmutableField("spec.guestConfig.hostname"))) or no
validation error for that field; place these alongside the existing Entry items
so they run in the same table-driven test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7346c92-5030-40a9-91b8-ee667637c148

📥 Commits

Reviewing files that changed from the base of the PR and between fb091b3 and 4daf02c.

⛔ Files ignored due to path filters (1)
  • iri/apis/machine/v1alpha1/api.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (18)
  • api/compute/v1alpha1/machine_types.go
  • api/compute/v1alpha1/zz_generated.deepcopy.go
  • broker/machinebroker/server/machine.go
  • broker/machinebroker/server/machine_create.go
  • broker/machinebroker/server/machine_create_test.go
  • client-go/applyconfigurations/compute/v1alpha1/machineguestconfig.go
  • client-go/applyconfigurations/compute/v1alpha1/machinespec.go
  • client-go/applyconfigurations/internal/internal.go
  • client-go/applyconfigurations/utils.go
  • client-go/openapi/zz_generated.openapi.go
  • internal/apis/compute/machine_types.go
  • internal/apis/compute/v1alpha1/zz_generated.conversion.go
  • internal/apis/compute/validation/machine.go
  • internal/apis/compute/validation/machine_test.go
  • internal/apis/compute/zz_generated.deepcopy.go
  • iri/apis/machine/v1alpha1/api.proto
  • poollet/machinepoollet/controllers/machine_controller.go
  • poollet/machinepoollet/controllers/machine_controller_test.go

@ushabelgur ushabelgur self-assigned this Mar 12, 2026
@ushabelgur
ushabelgur marked this pull request as draft March 12, 2026 11:15
@hardikdr hardikdr added the area/iaas Issues related to IronCore IaaS development. label Mar 13, 2026
@hardikdr hardikdr added this to Roadmap Mar 13, 2026
@ushabelgur
ushabelgur marked this pull request as ready for review March 13, 2026 09:06
Comment thread iri/apis/machine/v1alpha1/api.proto Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
internal/apis/compute/validation/machine_test.go (1)

577-636: Tests correctly cover the update validation logic.

The four test cases properly verify the hostname immutability/set-once semantics implemented in validateMachineSpecUpdate.

Consider adding test coverage for hostname format validation in the ValidateMachine table (lines 26-207) to verify that invalid DNS labels are rejected:

Suggested additional test cases for ValidateMachine
Entry("invalid guestConfig hostname",
	&compute.Machine{
		Spec: compute.MachineSpec{
			GuestConfig: &compute.MachineGuestConfig{
				Hostname: "foo*bar",
			},
		},
	},
	ContainElement(InvalidField("spec.guestConfig.hostname")),
),
Entry("valid guestConfig hostname",
	&compute.Machine{
		Spec: compute.MachineSpec{
			GuestConfig: &compute.MachineGuestConfig{
				Hostname: "my-hostname",
			},
		},
	},
	Not(ContainElement(InvalidField("spec.guestConfig.hostname"))),
),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/apis/compute/validation/machine_test.go` around lines 577 - 636, The
ValidateMachine tests lack cases that assert hostname format validation; add
table-driven tests in the ValidateMachine suite (the table around
ValidateMachine) to cover invalid and valid DNS-label hostnames by creating
Machine objects with Spec.GuestConfig.Hostname set to "foo*bar" (expect
ContainElement(InvalidField("spec.guestConfig.hostname"))) and "my-hostname"
(expect Not(ContainElement(InvalidField("spec.guestConfig.hostname")))); this
ensures the ValidateMachine validation path (which complements
validateMachineSpecUpdate) rejects malformed hostnames and accepts valid ones.
internal/apis/compute/machine_types.go (1)

42-43: Consider removing the JSON tag for consistency with other fields.

Other fields in MachineSpec (lines 17-41) do not have JSON tags. Since this is an internal API package and serialization is typically handled through conversion to versioned types, this tag creates an inconsistency.

Suggested fix
 	// GuestConfig contains an optional guest OS level configuration for the machine.
-	GuestConfig *MachineGuestConfig `json:"guestConfig,omitempty"`
+	GuestConfig *MachineGuestConfig
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/apis/compute/machine_types.go` around lines 42 - 43, The GuestConfig
field in MachineSpec currently has an explicit json tag; remove the
`json:"guestConfig,omitempty"` tag from the GuestConfig declaration so it
matches the other untagged fields in MachineSpec and relies on
conversion/versioned serialization; update the struct field `GuestConfig
*MachineGuestConfig` accordingly to maintain consistency with the surrounding
fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/apis/compute/machine_types.go`:
- Around line 42-43: The GuestConfig field in MachineSpec currently has an
explicit json tag; remove the `json:"guestConfig,omitempty"` tag from the
GuestConfig declaration so it matches the other untagged fields in MachineSpec
and relies on conversion/versioned serialization; update the struct field
`GuestConfig *MachineGuestConfig` accordingly to maintain consistency with the
surrounding fields.

In `@internal/apis/compute/validation/machine_test.go`:
- Around line 577-636: The ValidateMachine tests lack cases that assert hostname
format validation; add table-driven tests in the ValidateMachine suite (the
table around ValidateMachine) to cover invalid and valid DNS-label hostnames by
creating Machine objects with Spec.GuestConfig.Hostname set to "foo*bar" (expect
ContainElement(InvalidField("spec.guestConfig.hostname"))) and "my-hostname"
(expect Not(ContainElement(InvalidField("spec.guestConfig.hostname")))); this
ensures the ValidateMachine validation path (which complements
validateMachineSpecUpdate) rejects malformed hostnames and accepts valid ones.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4004b771-bec5-4f9e-8897-d1d08d447ea4

📥 Commits

Reviewing files that changed from the base of the PR and between 4daf02c and 99ed8ae.

⛔ Files ignored due to path filters (1)
  • iri/apis/machine/v1alpha1/api.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (18)
  • api/compute/v1alpha1/machine_types.go
  • api/compute/v1alpha1/zz_generated.deepcopy.go
  • broker/machinebroker/server/machine.go
  • broker/machinebroker/server/machine_create.go
  • broker/machinebroker/server/machine_create_test.go
  • client-go/applyconfigurations/compute/v1alpha1/machineguestconfig.go
  • client-go/applyconfigurations/compute/v1alpha1/machinespec.go
  • client-go/applyconfigurations/internal/internal.go
  • client-go/applyconfigurations/utils.go
  • client-go/openapi/zz_generated.openapi.go
  • internal/apis/compute/machine_types.go
  • internal/apis/compute/v1alpha1/zz_generated.conversion.go
  • internal/apis/compute/validation/machine.go
  • internal/apis/compute/validation/machine_test.go
  • internal/apis/compute/zz_generated.deepcopy.go
  • iri/apis/machine/v1alpha1/api.proto
  • poollet/machinepoollet/controllers/machine_controller.go
  • poollet/machinepoollet/controllers/machine_controller_test.go
✅ Files skipped from review due to trivial changes (3)
  • client-go/applyconfigurations/utils.go
  • broker/machinebroker/server/machine_create_test.go
  • client-go/applyconfigurations/compute/v1alpha1/machineguestconfig.go
🚧 Files skipped from review as they are similar to previous changes (9)
  • poollet/machinepoollet/controllers/machine_controller_test.go
  • iri/apis/machine/v1alpha1/api.proto
  • api/compute/v1alpha1/machine_types.go
  • client-go/applyconfigurations/compute/v1alpha1/machinespec.go
  • broker/machinebroker/server/machine_create.go
  • client-go/applyconfigurations/internal/internal.go
  • internal/apis/compute/zz_generated.deepcopy.go
  • api/compute/v1alpha1/zz_generated.deepcopy.go
  • internal/apis/compute/v1alpha1/zz_generated.conversion.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/apis/compute/machine_types.go (1)

42-43: Remove inconsistent JSON tag from internal API type.

The GuestConfig field in internal MachineSpec has an explicit JSON tag json:"guestConfig,omitempty", but the internal API pattern (as seen in MachineClassRef and other fields) is to omit JSON tags. JSON tags belong at the versioned API layer, not in internal API types.

♻️ Suggested fix
 	// GuestConfig contains an optional guest OS level configuration for the machine.
-	GuestConfig *MachineGuestConfig `json:"guestConfig,omitempty"`
+	GuestConfig *MachineGuestConfig
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/apis/compute/machine_types.go` around lines 42 - 43, The GuestConfig
field on the internal MachineSpec currently has an explicit JSON tag
(`GuestConfig *MachineGuestConfig json:"guestConfig,omitempty"`) which violates
the internal API pattern; remove the JSON struct tag so the field is declared
simply as `GuestConfig *MachineGuestConfig` to match other internal fields like
`MachineClassRef` and ensure JSON tags are only applied in the versioned API
types.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/apis/compute/machine_types.go`:
- Around line 42-43: The GuestConfig field on the internal MachineSpec currently
has an explicit JSON tag (`GuestConfig *MachineGuestConfig
json:"guestConfig,omitempty"`) which violates the internal API pattern; remove
the JSON struct tag so the field is declared simply as `GuestConfig
*MachineGuestConfig` to match other internal fields like `MachineClassRef` and
ensure JSON tags are only applied in the versioned API types.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0db5c5e-5f63-4a32-b89b-5eb43e69e39f

📥 Commits

Reviewing files that changed from the base of the PR and between 99ed8ae and 07999aa.

⛔ Files ignored due to path filters (1)
  • iri/apis/machine/v1alpha1/api.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (18)
  • api/compute/v1alpha1/machine_types.go
  • api/compute/v1alpha1/zz_generated.deepcopy.go
  • broker/machinebroker/server/machine.go
  • broker/machinebroker/server/machine_create.go
  • broker/machinebroker/server/machine_create_test.go
  • client-go/applyconfigurations/compute/v1alpha1/machineguestconfig.go
  • client-go/applyconfigurations/compute/v1alpha1/machinespec.go
  • client-go/applyconfigurations/internal/internal.go
  • client-go/applyconfigurations/utils.go
  • client-go/openapi/zz_generated.openapi.go
  • internal/apis/compute/machine_types.go
  • internal/apis/compute/v1alpha1/zz_generated.conversion.go
  • internal/apis/compute/validation/machine.go
  • internal/apis/compute/validation/machine_test.go
  • internal/apis/compute/zz_generated.deepcopy.go
  • iri/apis/machine/v1alpha1/api.proto
  • poollet/machinepoollet/controllers/machine_controller.go
  • poollet/machinepoollet/controllers/machine_controller_test.go
✅ Files skipped from review due to trivial changes (4)
  • broker/machinebroker/server/machine_create_test.go
  • client-go/applyconfigurations/utils.go
  • poollet/machinepoollet/controllers/machine_controller.go
  • client-go/applyconfigurations/compute/v1alpha1/machineguestconfig.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • internal/apis/compute/validation/machine_test.go
  • internal/apis/compute/validation/machine.go
  • poollet/machinepoollet/controllers/machine_controller_test.go
  • iri/apis/machine/v1alpha1/api.proto
  • api/compute/v1alpha1/machine_types.go
  • client-go/applyconfigurations/internal/internal.go
  • api/compute/v1alpha1/zz_generated.deepcopy.go
  • internal/apis/compute/zz_generated.deepcopy.go
  • client-go/openapi/zz_generated.openapi.go
  • internal/apis/compute/v1alpha1/zz_generated.conversion.go

@lukasfrank

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lukasfrank lukasfrank changed the title Add guestConfig along with hostname to Machine type Add hostname support to Machine via GuestConfig Apr 23, 2026
@ushabelgur

Copy link
Copy Markdown
Contributor Author

@afritzler Can we get this merged ?

@afritzler
afritzler merged commit db456bb into ironcore-dev:main May 5, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Roadmap May 5, 2026
@afritzler afritzler removed the breaking label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/iaas Issues related to IronCore IaaS development. enhancement New feature or request size/XL

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add hostname configuration to Machine type

4 participants