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:
karmada-bot 2022-10-13 15:35:14 +08:00 committed by GitHub
commit cbc54497c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package kubernetes
import (
"context"
"encoding/json"
"errors"
"fmt"
"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"] = ""
patchData := map[string]interface{}{"metadata": map[string]map[string]string{"labels": etcdSelectorLabels}}
playLoadBytes, _ := json.Marshal(patchData)