Skip to content

Commit c915b41

Browse files
authored
Merge pull request #1074 from trinaths/1.11-stable
1.11.1 patch release
2 parents 8d53185 + 32918ee commit c915b41

File tree

11 files changed

+25337
-75
lines changed

11 files changed

+25337
-75
lines changed

build-tools/Dockerfile.debian.runtime

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2121
RUN apt-get remove -y libidn11
2222

2323
COPY bigip-virtual-server_v*.json $APPPATH/vendor/src/f5/schemas/
24-
COPY as3-schema-3.11.0-3-cis.json $APPPATH/vendor/src/f5/schemas/
24+
COPY as3-schema-3.13.2-1-cis.json $APPPATH/vendor/src/f5/schemas/
2525
COPY k8s-bigip-ctlr $APPPATH/bin
2626
COPY VERSION_BUILD.json $APPPATH/vendor/src/f5/
2727

build-tools/Dockerfile.debug.runtime

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2626
RUN apt-get remove -y libidn11
2727

2828
COPY bigip-virtual-server_v*.json $APPPATH/vendor/src/f5/schemas/
29-
COPY as3-schema-3.11.0-3-cis.json $APPPATH/vendor/src/f5/schemas/
29+
COPY as3-schema-3.13.2-1-cis.json $APPPATH/vendor/src/f5/schemas/
3030
COPY k8s-bigip-ctlr $APPPATH/bin
3131
COPY VERSION_BUILD.json $APPPATH/vendor/src/f5/
3232
COPY --from=builder /go/bin/dlv /app/bin

build-tools/Dockerfile.rhel7.runtime

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RUN microdnf --enablerepo=rhel-7-server-rpms --enablerepo=rhel-7-server-optional
4343
microdnf clean all
4444

4545
COPY bigip-virtual-server_v*.json $APPPATH/vendor/src/f5/schemas/
46-
COPY as3-schema-3.11.0-3-cis.json $APPPATH/vendor/src/f5/schemas/
46+
COPY as3-schema-3.13.2-1-cis.json $APPPATH/vendor/src/f5/schemas/
4747
COPY k8s-bigip-ctlr $APPPATH/bin/k8s-bigip-ctlr.real
4848
COPY VERSION_BUILD.json $APPPATH/vendor/src/f5/
4949

build-tools/build-release-images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ docker rm -f cp-temp
3434

3535
cp requirements.txt $WKDIR/
3636
cp schemas/bigip-virtual-server_v*.json $WKDIR/
37-
cp schemas/as3-schema-3.11.0-3-cis.json $WKDIR/
37+
cp schemas/as3-schema-3.13.2-1-cis.json $WKDIR/
3838
cp LICENSE $WKDIR/
3939
cp $CURDIR/help.md $WKDIR/help.md
4040
echo "{\"version\": \"${VERSION_INFO}\", \"build\": \"${BUILD_INFO}\"}" \

cmd/k8s-bigip-ctlr/main.go

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ import (
5151
routeclient "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1"
5252
)
5353

54-
const as3SchemaLatestUrl = "https://raw.githubusercontent.com/F5Networks/f5-appsvcs-extension/master/schema/latest/as3-schema.json"
54+
const as3SchemaLatestURL = "https://raw.githubusercontent.com/F5Networks/f5-appsvcs-extension/master/schema/latest/as3-schema.json"
55+
const as3SchemaFileName = "as3-schema-3.13.2-1-cis.json"
5556

5657
type globalSection struct {
5758
LogLevel string `json:"log-level,omitempty"`
@@ -780,34 +781,46 @@ func main() {
780781

781782
func fetchAS3Schema(appMgr *appmanager.Manager) {
782783

783-
res, resErr := http.Get(as3SchemaLatestUrl)
784+
res, resErr := http.Get(as3SchemaLatestURL)
784785
if resErr != nil {
785-
log.Debugf("error while fetching latest as3 schema : %v", resErr)
786+
log.Debugf("Error while fetching latest as3 schema : %v", resErr)
787+
fallbackToLocalAS3Schema(appMgr)
788+
return
786789
}
787-
788790
if res.StatusCode == http.StatusOK {
789791
body, err := ioutil.ReadAll(res.Body)
790792
if err != nil {
791-
log.Debugf("unable to read the as3 template from json response body : %v", err)
793+
log.Debugf("Unable to read the as3 template from json response body : %v", err)
794+
fallbackToLocalAS3Schema(appMgr)
795+
return
792796
}
793797
defer res.Body.Close()
794798

795799
jsonMap := make(map[string]interface{})
796800
err = json.Unmarshal(body, &jsonMap)
797801
if err != nil {
798-
log.Debugf("unable to unmarshal json response body : %v", err)
802+
log.Debugf("Unable to unmarshal json response body : %v", err)
803+
fallbackToLocalAS3Schema(appMgr)
804+
return
799805
}
800806

801-
jsonMap["$id"] = as3SchemaLatestUrl
807+
jsonMap["$id"] = as3SchemaLatestURL
802808
byteJSON, err := json.Marshal(jsonMap)
803809
if err != nil {
804-
log.Debugf("unable to marshal : %v", err)
810+
log.Debugf("Unable to marshal : %v", err)
811+
fallbackToLocalAS3Schema(appMgr)
812+
return
805813
}
806814
appMgr.As3SchemaLatest = string(byteJSON)
807-
808-
} else {
809-
log.Debugf("unable to fetch the latest AS3 schema")
810-
appMgr.As3SchemaLatest = ""
815+
return
811816
}
817+
fallbackToLocalAS3Schema(appMgr)
818+
return
819+
}
812820

821+
func fallbackToLocalAS3Schema(appMgr *appmanager.Manager) {
822+
appMgr.As3SchemaFlag = true
823+
log.Debugf("Unable to fetch the latest AS3 schema : validating AS3 schema with %v", as3SchemaFileName)
824+
appMgr.As3SchemaLatest = appMgr.SchemaLocalPath + as3SchemaFileName
825+
return
813826
}

docs/RELEASE-NOTES.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
Release Notes for BIG-IP Controller for Kubernetes
22
==================================================
33

4+
v1.11.1
5+
------------
6+
Bug Fixes
7+
`````````
8+
* Controller handles WAF Policy in the root path of a domain in OpenShift Routes.
9+
* Controller handles OpenShift Routes with WAF Policy in multiple namespaces.
10+
* Controller now does not push configuration to BIG-IP using AS3 for every 30 seconds with no changes.
11+
* :issues:`1041` Controller now does not log dozens of "INFO" log messages frequently.
12+
* :issues:`1040` Controller does not crashes if latest AS3 schema is not available.
13+
* Controller updates Route Status in OpenShift Management Console (OCP 4.x)
14+
* Controller does not crash when handling Route with WAF Policy that does not have a service.
15+
16+
417
v1.11.0
518
------------
619
Added Functionality

pkg/appmanager/appManager.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const f5VsWAFPolicy = "virtual-server.f5.com/waf"
7272

7373
type ResourceMap map[int32][]*ResourceConfig
7474

75+
type RouteMap map[string]*routeapi.Route
76+
7577
type Manager struct {
7678
resources *Resources
7779
customProfiles *CustomProfileStore
@@ -145,7 +147,12 @@ type Manager struct {
145147
WatchedNS WatchedNamespaces
146148
as3RouteCfg ActiveAS3Route
147149
As3SchemaLatest string
148-
intF5Res InternalF5Resources // AS3 Specific features that can be applied to a Route/Ingress
150+
intF5Res InternalF5ResourcesGroup // AS3 Specific features that can be applied to a Route/Ingress
151+
// Path of schemas reside locally
152+
SchemaLocalPath string
153+
// Flag to check schema validation using reference or string
154+
As3SchemaFlag bool
155+
RoutesProcessed RouteMap // Processed routes for updating Admit Status
149156
}
150157

151158
// FIXME: Refactor to have one struct to hold all AS3 specific data.
@@ -193,6 +200,7 @@ type Params struct {
193200
SSLInsecure bool
194201
TrustedCertsCfgmap string
195202
Agent string
203+
SchemaLocalPath string
196204
}
197205

198206
// Configuration options for Routes in OpenShift
@@ -248,6 +256,8 @@ func NewManager(params *Params) *Manager {
248256
sslInsecure: params.SSLInsecure,
249257
trustedCertsCfgmap: params.TrustedCertsCfgmap,
250258
Agent: getValidAgent(params.Agent),
259+
intF5Res: make(map[string]InternalF5Resources),
260+
SchemaLocalPath: params.SchemaLocal,
251261
}
252262
if nil != manager.kubeClient && nil == manager.restClientv1 {
253263
// This is the normal production case, but need the checks for unit tests.
@@ -439,7 +449,6 @@ func (appMgr *Manager) syncNamespace(nsName string) error {
439449
appMgr.removeNamespaceLocked(nsName)
440450
appMgr.eventNotifier.deleteNotifierForNamespace(nsName)
441451
appMgr.resources.Lock()
442-
defer appMgr.resources.Unlock()
443452
rsDeleted := 0
444453
appMgr.resources.ForEach(func(key serviceKey, cfg *ResourceConfig) {
445454
if key.Namespace == nsName {
@@ -448,8 +457,9 @@ func (appMgr *Manager) syncNamespace(nsName string) error {
448457
}
449458
}
450459
})
460+
appMgr.resources.Unlock()
451461
if rsDeleted > 0 {
452-
appMgr.outputConfigLocked()
462+
appMgr.outputConfig()
453463
}
454464
}
455465

@@ -1353,6 +1363,7 @@ func (appMgr *Manager) syncRoutes(
13531363
appInf *appInformer,
13541364
dgMap InternalDataGroupMap,
13551365
) error {
1366+
appMgr.RoutesProcessed = make(RouteMap)
13561367
routeByIndex, err := appInf.getOrderedRoutes(sKey.Namespace)
13571368
if nil != err {
13581369
log.Warningf("Unable to list routes for namespace '%v': %v",
@@ -1364,13 +1375,13 @@ func (appMgr *Manager) syncRoutes(
13641375
svcFwdRulesMap := NewServiceFwdRuleMap()
13651376

13661377
// buffer to hold F5Resources till all routes are processed
1367-
bufferF5Res := map[Record]F5Resources{}
1378+
bufferF5Res := InternalF5Resources{}
13681379

13691380
for _, route := range routeByIndex {
13701381
if route.ObjectMeta.Namespace != sKey.Namespace {
13711382
continue
13721383
}
1373-
RoutesProcessed = append(RoutesProcessed, route)
1384+
appMgr.RoutesProcessed[route.ObjectMeta.Name] = route
13741385

13751386
//FIXME(kenr): why do we process services that aren't associated
13761387
// with a route?
@@ -1521,8 +1532,10 @@ func (appMgr *Manager) syncRoutes(
15211532
}
15221533

15231534
// if buffer is updated then update the appMgr and stats
1524-
if !reflect.DeepEqual(appMgr.intF5Res, bufferF5Res) {
1525-
appMgr.intF5Res = bufferF5Res
1535+
if (len(appMgr.intF5Res[sKey.Namespace]) != 0 || len(bufferF5Res) != 0) &&
1536+
(!reflect.DeepEqual(appMgr.intF5Res[sKey.Namespace], bufferF5Res)) {
1537+
1538+
appMgr.intF5Res[sKey.Namespace] = bufferF5Res
15261539
stats.vsUpdated++
15271540
}
15281541

0 commit comments

Comments
 (0)