karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.25k stars 827 forks source link

[preflight] Some fatal errors occurred: [ERROR]: /etc/karmada/pki/ca.crt already exists #4005

Open chaosi-zju opened 10 months ago

chaosi-zju commented 10 months ago

Please provide an in-depth description of the question you have:

➜  karmada git:(dev) ✗ karmadactl register 172.18.0.2:32443 --token p7dp43.md2a6yso74i87juv --discovery-token-ca-cert-hash sha256:1959d34e358e1f38d0a594e3c4708aa1b9b1321c7a07615feb60338e4f5cb16c --ca-cert-path /etc/karmada/pki2/ca.crt
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR]: /etc/karmada/pki/ca.crt already exists

[preflight] Please check the above errors

What do you think about this question?:

Hello @lonelyCZ, do you have some time to help my question?

pkg/karmadactl/register/register.go:375

// preflight checks the deployment environment of the member cluster
func (o *CommandRegisterOption) preflight() []error {
    var errlist []error

    // check if the given file already exist
    errlist = appendError(errlist, checkFileIfExist(filepath.Join(KarmadaDir, KarmadaAgentBootstrapKubeConfigFileName)))
    errlist = appendError(errlist, checkFileIfExist(filepath.Join(KarmadaDir, KarmadaAgentKubeConfigFileName)))
    errlist = appendError(errlist, checkFileIfExist(CACertPath))

image

In above code, CACertPath is just a default const value /etc/karmada/pki/ca.crt, why if this local path exist should directly return error?

I mean, if I specified --ca-cert-path=/etc/karmada/pki/other-ca.crt, why if /etc/karmada/pki/ca.crt exist shall return error? May be is a small bug?

Much appreciate your help!

Environment:

liangyuanpeng commented 9 months ago

same problem with here, I guess this is to prevent the karmada agent from being deployed on the karmada apiserver.

/assign