Merge pull request #2612 from liangyuanpeng/fix_nil_map_panic
raise an error when there is no healthy nodes for etcd installation
This commit is contained in:
commit
cbc54497c7
|
@ -3,6 +3,7 @@ package kubernetes
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -108,6 +109,10 @@ func (i *CommandInitOption) AddNodeSelectorLabels() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if etcdSelectorLabels == nil {
|
||||||
|
return errors.New("failed to find a healthy node for karmada-etcd")
|
||||||
|
}
|
||||||
|
|
||||||
etcdSelectorLabels["karmada.io/etcd"] = ""
|
etcdSelectorLabels["karmada.io/etcd"] = ""
|
||||||
patchData := map[string]interface{}{"metadata": map[string]map[string]string{"labels": etcdSelectorLabels}}
|
patchData := map[string]interface{}{"metadata": map[string]map[string]string{"labels": etcdSelectorLabels}}
|
||||||
playLoadBytes, _ := json.Marshal(patchData)
|
playLoadBytes, _ := json.Marshal(patchData)
|
||||||
|
|
Loading…
Reference in New Issue