k3s-io / cluster-api-k3s

Cluster API k3s
Apache License 2.0
149 stars 41 forks source link

KThreesControlPlane ServerConfig always reverts to defaults #120

Closed anmazzotti closed 5 months ago

anmazzotti commented 6 months ago

Using the v1beta2 and configuring for example:

apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: KThreesControlPlane
metadata:
  name: k3s-control-plane
  namespace: default
spec:
  kthreesConfigSpec:
    serverConfig:
      disableCloudController: false
      cloudProviderName: ""
  machineTemplate:
    infrastructureRef:
      apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
      kind: InfraMachineTemplate
      name: infra-cluster-k3s-control-plane
  replicas: 1
  version: v1.28.5+k3s1

After applying this config, the KThreesControlPlane defaults back to:

        serverConfig:
          cloudProviderName: external
          disableCloudController: true

This was reported in the Slack channel in this thread.

anmazzotti commented 6 months ago

I'm already having a look at this, trying to fix it asap. I wonder if the CustomDefaulter we recently activated is the related to this, but I'm having some hard time solving it at the moment.

nasusoba commented 6 months ago

I tried to add some breakpoint to the CustomDefaulter, and I observed the value remains disableCloudController=false. It seems that it is not the CustomDefaulter causing the issue. This is really weird...

nasusoba commented 6 months ago

@anmazzotti Could you check if this would help golang omitempty , it seems that we should use *bool when using with omitempty

anmazzotti commented 6 months ago

I'm indeed using pointers in the PR I opened yesterday to fix this. It's indeed odd, but I was able to reproduce it.

Somehow the kubebuilder defaults are a bit too sticky, but setting everything in the custom defaulter seem to work just fine.

nasusoba commented 6 months ago

Does the issue got fixed? I have not tried with your PR yet, I have not noticed it has been changed to pointer XD

anmazzotti commented 6 months ago

I tested it locally and it seems to be fixed.

I should be adding some e2e test, but I think that also needs porting of all current tests to v1beta2 manifests, so may take a bit. I added a new issue for that and I'll try to prioritize it: https://github.com/k3s-io/cluster-api-k3s/issues/123