mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Reset load balancer state during restoraion (#3878)
Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com> Reset load balancer state during restoraion Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
This commit is contained in:
parent
3e250fdbab
commit
656c190629
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
@ -162,3 +163,12 @@ func reusePort(network, address string, conn syscall.RawConn) error {
|
||||
syscall.SetsockoptInt(int(descriptor), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
||||
})
|
||||
}
|
||||
|
||||
// ResetLoadBalancer will delete the local state file for the load balacner on disk
|
||||
func ResetLoadBalancer(dataDir, serviceName string) error {
|
||||
stateFile := filepath.Join(dataDir, "etc", serviceName+".json")
|
||||
if err := os.Remove(stateFile); err != nil {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"github.com/erikdubbelboer/gspt"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rancher/k3s/pkg/agent"
|
||||
"github.com/rancher/k3s/pkg/agent/loadbalancer"
|
||||
"github.com/rancher/k3s/pkg/cli/cmds"
|
||||
"github.com/rancher/k3s/pkg/clientaccess"
|
||||
"github.com/rancher/k3s/pkg/datadir"
|
||||
@ -159,6 +160,10 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
|
||||
serverConfig.ControlConfig.DisableControllerManager = true
|
||||
serverConfig.ControlConfig.DisableScheduler = true
|
||||
serverConfig.ControlConfig.DisableCCM = true
|
||||
|
||||
// delete local loadbalancers state for apiserver and supervisor servers
|
||||
loadbalancer.ResetLoadBalancer(filepath.Join(cfg.DataDir, "agent"), loadbalancer.SupervisorServiceName)
|
||||
loadbalancer.ResetLoadBalancer(filepath.Join(cfg.DataDir, "agent"), loadbalancer.APIServerServiceName)
|
||||
}
|
||||
|
||||
serverConfig.ControlConfig.ClusterReset = cfg.ClusterReset
|
||||
|
Loading…
Reference in New Issue
Block a user