-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Machine creation fails silently when MachineClass has no labels field in its ProviderSpec. The provider returns an empty ProviderID without executing the CreateMachine code path.
Expected Behavior
When a MachineClass is created without a labels field in its ProviderSpec, the provider should:
- Execute the CreateMachine function in
core.go - Handle the missing labels gracefully (treat as empty map)
- Create the machine in STACKIT IAAS
- Return a valid ProviderID in the format
stackit://<project-id>/<server-id>
Actual Behavior
When labels are omitted from ProviderSpec:
- MCM logs show:
Created new VM for machine: 'machine-wn58lb4r' with ProviderID:(empty ProviderID) - Provider code in
core.go:36(CreateMachine entry point) is never executed - no klog messages - No POST request reaches the IAAS API (confirmed via mock server logs)
- CreateMachine returns successfully but with an empty ProviderID
Root Cause
The issue occurs before the provider code runs, likely in:
decodeProviderSpec()function, OR- The validation layer
When ProviderSpec.Labels is nil, it may cause JSON unmarshalling issues or validation failures that prevent the request from reaching the provider's CreateMachine implementation.
Evidence
From e2e test debugging:
// MachineClass WITHOUT labels
providerSpec:
machineType: "c2i.2"
imageId: "550e8400-e29b-41d4-a716-446655440000"
# NO labels field
Results in:
- ✅ MCM CreateMachine is called (MCM logs confirm)
- ❌ Provider CreateMachine is NOT called (no logs from core.go)
- ❌ IAAS API receives no requests
- ❌ ProviderID is empty
Steps to Reproduce
- Create a MachineClass without labels in providerSpec:
apiVersion: machine.sapcloud.io/v1alpha1
kind: MachineClass
metadata:
name: test-no-labels
namespace: default
providerSpec:
machineType: "c2i.2"
imageId: "550e8400-e29b-41d4-a716-446655440000"
# labels field intentionally omitted
secretRef:
name: stackit-secret
namespace: default
provider: STACKIT- Create a Machine using this MachineClass
- Observe that Machine gets empty ProviderID and provider code is never executed
Affected Code
The issue predates the SDK migration (confirmed 2025-11-06), suggesting it's in the core provider/validation layer:
pkg/provider/apis/provider_spec.go- ProviderSpec definitionpkg/provider/apis/validation/validation.go- Validation logicpkg/provider/core.go- decodeProviderSpec() function
Test Case
See: test/e2e/e2e_labels_test.go - Test: "should create Machine without user-provided labels"
- Currently skipped with Skip() due to this bug
Suggested Investigation
- Add debug logging to
decodeProviderSpec()to see if unmarshalling fails - Check validation logic for required vs optional fields
- Run with
-v=4verbose logging to see gRPC/driver layer logs - Verify if
nilvs empty map for Labels field causes different behavior - Compare with working provider implementations (OpenStack) to see how they handle optional labels
Impact
- Severity: Medium-High
- Users cannot create machines without explicitly setting labels (even empty)
- Fails silently without clear error messages
- Blocks e2e test coverage for graceful degradation scenarios
Workaround
Always include a labels field in MachineClass ProviderSpec, even if empty:
providerSpec:
machineType: "c2i.2"
imageId: "550e8400-e29b-41d4-a716-446655440000"
labels: {} # Empty map as workaround