Skip to content

Commit

Permalink
Merge pull request #978 from trinaths/1.9-stable
Browse files Browse the repository at this point in the history
1.9.2
  • Loading branch information
trinaths authored Jul 26, 2019
2 parents 2dddf6d + 603e7bf commit 8af9237
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
12 changes: 11 additions & 1 deletion cmd/k8s-bigip-ctlr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ func createLabel(label string) (labels.Selector, error) {
return l, nil
}

// Get Namespaces we are watching to know the vsQueue Length
func GetNamespaces(appMgr *appmanager.Manager) {
if len(*namespaces) != 0 && len(*namespaceLabel) == 0 {
appMgr.WatchedNS.Namespaces = *namespaces
}
if len(*namespaces) == 0 && len(*namespaceLabel) != 0 {
appMgr.WatchedNS.NamespaceLabel = *namespaceLabel
}
}

// setup the initial watch based off the flags passed in, if no flags then we
// watch all namespaces
func setupWatchers(appMgr *appmanager.Manager, resyncPeriod time.Duration) {
Expand Down Expand Up @@ -705,7 +715,7 @@ func main() {
}

appMgr := appmanager.NewManager(&appMgrParms)

GetNamespaces(appMgr)
intervalFactor := time.Duration(*nodePollInterval)
np := pollers.NewNodePoller(appMgrParms.KubeClient, intervalFactor*time.Second, *nodeLabelSelector)
err = setupNodePolling(appMgr, np, eventChan, appMgrParms.KubeClient)
Expand Down
7 changes: 7 additions & 0 deletions docs/RELEASE-NOTES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Release Notes for BIG-IP Controller for Kubernetes
==================================================

v1.9.2
------
Bug Fixes
`````````
* Controller handles http redirects without entering into an infinite loop.
* :issues:`810` Controller does not delete resources in BIG-IP and recreates during controller pod restart.

v1.9.1
------
Added Functionality
Expand Down
49 changes: 46 additions & 3 deletions pkg/appmanager/appManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ type Manager struct {
activeCfgMap ActiveAS3ConfigMap
// List of Watched Endpoints for user-defined AS3
watchedAS3Endpoints map[string]struct{}
// Watched namespaces
WatchedNS WatchedNamespaces
}

// FIXME: Refactor to have one struct to hold all AS3 specific data.
Expand All @@ -146,6 +148,12 @@ type ActiveAS3ConfigMap struct {
Data string // if AS3 Name is present, populate this with AS3 template data.
}

// Watched Namespaces for global availability.
type WatchedNamespaces struct {
Namespaces []string
NamespaceLabel string
}

// Struct to allow NewManager to receive all or only specific parameters.
type Params struct {
KubeClient kubernetes.Interface
Expand Down Expand Up @@ -828,6 +836,43 @@ func (appMgr *Manager) virtualServerWorker() {
}
}

// Get all Namespaces being watched based on Namespaces provided, Namespace Label or all
func (appMgr *Manager) GetAllWatchedNamespaces() []string {
var namespaces []string
switch {
case len(appMgr.WatchedNS.Namespaces) != 0:
namespaces = appMgr.WatchedNS.Namespaces
case len(appMgr.WatchedNS.NamespaceLabel) != 0:
NsListOptions := metav1.ListOptions{
LabelSelector: appMgr.WatchedNS.NamespaceLabel,
}
nsL, err := appMgr.kubeClient.CoreV1().Namespaces().List(NsListOptions)
if err != nil {
log.Errorf("Error getting Namespaces with Namespace label - %v.", err)
}
for _, v := range nsL.Items {
namespaces = append(namespaces, v.Name)
}
default:
namespaces = append(namespaces, "")
}
return namespaces
}

// Get the count of Services from the Namespaces being watched.
func (appMgr *Manager) getServiceCount() int {
qLen := 0
for _, ns := range appMgr.GetAllWatchedNamespaces() {
services, err := appMgr.kubeClient.CoreV1().Services(ns).List(metav1.ListOptions{})
qLen += len(services.Items)
if err != nil {
log.Errorf("Failed getting Services from watched namespace : %v.", err)
qLen = appMgr.vsQueue.Len()
}
}
return qLen
}

func (appMgr *Manager) processNextVirtualServer() bool {
key, quit := appMgr.vsQueue.Get()
k := key.(serviceQueueKey)
Expand All @@ -845,9 +890,7 @@ func (appMgr *Manager) processNextVirtualServer() bool {
return false
}
if !appMgr.initialState && appMgr.processedItems == 0 {
//TODO: Properly handlle queueLen assessment and remove Sleep function
time.Sleep(1 * time.Second)
appMgr.queueLen = appMgr.vsQueue.Len()
appMgr.queueLen = appMgr.getServiceCount()
}
if quit {
// The controller is shutting down.
Expand Down
1 change: 1 addition & 0 deletions pkg/appmanager/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ func httpRedirectIRule(port int32) string {
}
if {$paths != ""} {
set redir 0
set prefix ""
foreach s [split $paths "|"] {
# See if the request path starts with the prefix
append prefix "^" $s "($|/*)"
Expand Down

0 comments on commit 8af9237

Please sign in to comment.