k8s-proxmox / cluster-api-provider-proxmox

Cluster API provider implementation for Proxmox VE
Apache License 2.0
94 stars 11 forks source link

Reconciliation fails when no user data is provided #83

Closed simplysoft closed 9 months ago

simplysoft commented 9 months ago

When ProxmoxMachineTemplate does not contain spec.template.spec.cloudInit.user, the merging (and thus reconciliation) fails, even though omitting of that field is allowed according to the spec.

As a workaround adding empty map solves this issue:

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: ProxmoxMachineTemplate
metadata:
  [...]
spec:
  template:
    spec:
      [...]
      cloudInit:
        user: {}

The underlying issue can be reproduced with code: mergeUserDatas(bootstrapConfig, baseUserData(vmName), &infrav1.UserData{}) works, but mergeUserDatas(bootstrapConfig, baseUserData(vmName), nil) doesn't

Either that cases should be handeled or the spec adjusted to not allow omitting that field

Environment:

sp-yduck commented 9 months ago

Thank you for pointing out. I don't want to update api(crd) so let's fix by modifying the mergeUserDatas() func to accept nil. do you mind to send PR out for this ?