Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merge pull request #141 from yboaron/get_endpoints" #146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 3 additions & 33 deletions pkg/config/node.go
Expand Up @@ -22,10 +22,7 @@ import (
"github.com/openshift/installer/pkg/types"
)

const (
localhostKubeApiServerUrl = "https://localhost:6443"
defaultIngressControllerName = "router-internal-default"
)
const localhostKubeApiServerUrl string = "https://localhost:6443"

var log = logrus.New()

Expand Down Expand Up @@ -66,8 +63,7 @@ type ApiLBConfig struct {
}

type IngressConfig struct {
Peers []string
Priority int
Peers []string
}

type Node struct {
Expand Down Expand Up @@ -222,33 +218,6 @@ func IsUpgradeStillRunning(kubeconfigPath string) (error, bool) {
return nil, false
}

func GetIngressPriority(kubeconfigPath string, nonVirtualIP string) int {
config, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
if err != nil {
log.Errorf("Failed to retrieve config from kubeconfig: %s , set priority to lower value", err)
return 20
}

clientset, err := kubernetes.NewForConfig(config)
if err != nil {
log.Errorf("Failed to build client config: %s , set priority to lower value", err)
return 20
}
endpoint, err := clientset.CoreV1().Endpoints("openshift-ingress").Get(defaultIngressControllerName, metav1.GetOptions{})
if err != nil {
log.Errorf("Failed to read %s endpoints: %s , set priority to lower value", defaultIngressControllerName, err)
return 20
}
for _, entry := range endpoint.Subsets {
for _, address := range entry.Addresses {
if address.IP == nonVirtualIP {
return 40
}
}
}
return 20
}

func GetIngressConfig(kubeconfigPath string) (ingressConfig IngressConfig, err error) {
config, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
if err != nil {
Expand All @@ -259,6 +228,7 @@ func GetIngressConfig(kubeconfigPath string) (ingressConfig IngressConfig, err e
if err != nil {
return ingressConfig, err
}

nodes, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{})
if err != nil {
return ingressConfig, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/monitor/dynkeepalived.go
Expand Up @@ -335,6 +335,7 @@ func KeepalivedWatch(kubeconfigPath, clusterConfigPath, templatePath, cfgPath st
newConfig.EnableUnicast = false
}
updateUnicastConfig(kubeconfigPath, &newConfig, appliedConfig)

log.WithFields(logrus.Fields{
"curConfig": newConfig,
}).Info("Mode Update config change")
Expand Down Expand Up @@ -380,7 +381,6 @@ func KeepalivedWatch(kubeconfigPath, clusterConfigPath, templatePath, cfgPath st
newConfig.EnableUnicast = curEnableUnicast
}
updateUnicastConfig(kubeconfigPath, &newConfig, appliedConfig)
newConfig.IngressConfig.Priority = config.GetIngressPriority(kubeconfigPath, newConfig.NonVirtualIP)
curConfig = &newConfig
if doesConfigChanged(curConfig, appliedConfig) {
if prevConfig == nil || cmp.Equal(*prevConfig, *curConfig) {
Expand Down