mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
fix ipset creation fails on centos. issue 65461
This commit is contained in:
parent
24ab69d358
commit
9d0b4853cc
@ -289,7 +289,7 @@ func (runner *runner) CreateSet(set *IPSet, ignoreExistErr bool) error {
|
|||||||
// If ignoreExistErr is set to true, then the -exist option of ipset will be specified, ipset ignores the error
|
// If ignoreExistErr is set to true, then the -exist option of ipset will be specified, ipset ignores the error
|
||||||
// otherwise raised when the same set (setname and create parameters are identical) already exists.
|
// otherwise raised when the same set (setname and create parameters are identical) already exists.
|
||||||
func (runner *runner) createSet(set *IPSet, ignoreExistErr bool) error {
|
func (runner *runner) createSet(set *IPSet, ignoreExistErr bool) error {
|
||||||
args := []string{"create", set.Name, string(set.SetType), "comment"}
|
args := []string{"create", set.Name, string(set.SetType)}
|
||||||
if set.SetType == HashIPPortIP || set.SetType == HashIPPort {
|
if set.SetType == HashIPPortIP || set.SetType == HashIPPort {
|
||||||
args = append(args,
|
args = append(args,
|
||||||
"family", set.HashFamily,
|
"family", set.HashFamily,
|
||||||
@ -313,7 +313,7 @@ func (runner *runner) createSet(set *IPSet, ignoreExistErr bool) error {
|
|||||||
// If the -exist option is specified, ipset ignores the error otherwise raised when
|
// If the -exist option is specified, ipset ignores the error otherwise raised when
|
||||||
// the same set (setname and create parameters are identical) already exists.
|
// the same set (setname and create parameters are identical) already exists.
|
||||||
func (runner *runner) AddEntry(entry string, set *IPSet, ignoreExistErr bool) error {
|
func (runner *runner) AddEntry(entry string, set *IPSet, ignoreExistErr bool) error {
|
||||||
args := []string{"add", set.Name, entry, "comment", set.Comment}
|
args := []string{"add", set.Name, entry}
|
||||||
if ignoreExistErr {
|
if ignoreExistErr {
|
||||||
args = append(args, "-exist")
|
args = append(args, "-exist")
|
||||||
}
|
}
|
||||||
@ -325,7 +325,6 @@ func (runner *runner) AddEntry(entry string, set *IPSet, ignoreExistErr bool) er
|
|||||||
|
|
||||||
// DelEntry is used to delete the specified entry from the set.
|
// DelEntry is used to delete the specified entry from the set.
|
||||||
func (runner *runner) DelEntry(entry string, set string) error {
|
func (runner *runner) DelEntry(entry string, set string) error {
|
||||||
entry = strings.Split(entry, " comment")[0]
|
|
||||||
if _, err := runner.exec.Command(IPSetCmd, "del", set, entry).CombinedOutput(); err != nil {
|
if _, err := runner.exec.Command(IPSetCmd, "del", set, entry).CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("error deleting entry %s: from set: %s, error: %v", entry, set, err)
|
return fmt.Errorf("error deleting entry %s: from set: %s, error: %v", entry, set, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user