Skip to content

Commit f0b77c8

Browse files
authored
Merge pull request #856 from trinaths/as3-dev
Branch out the CC implementation for AS3 Specific implementation.
2 parents 31eab0e + 8bdc65e commit f0b77c8

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

pkg/appmanager/appManager.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ func (appMgr *Manager) GetNamespaceLabelInformer() cache.SharedIndexInformer {
405405
type serviceQueueKey struct {
406406
Namespace string
407407
ServiceName string
408+
As3Name string // as3 Specific configMap name
409+
As3Data string // if As3Name is present, populate this with as3 tmpl data
408410
}
409411

410412
type appInformer struct {
@@ -764,6 +766,13 @@ func (appMgr *Manager) virtualServerWorker() {
764766

765767
func (appMgr *Manager) processNextVirtualServer() bool {
766768
key, quit := appMgr.vsQueue.Get()
769+
k := key.(serviceQueueKey)
770+
if len(k.As3Name) != 0 {
771+
log.Debugf("[as3_log] Processing AS3 cfgMap (%s) with AS3 Manager.\n", k.As3Name)
772+
log.Debugf("[as3_log] AS3 ConfigMap Data: %s\n", k.As3Data)
773+
appMgr.vsQueue.Done(key)
774+
return false
775+
}
767776
if !appMgr.initialState && appMgr.processedItems == 0 {
768777
//TODO: Properly handlle queueLen assessment and remove Sleep function
769778
time.Sleep(1 * time.Second)
@@ -916,6 +925,14 @@ func (appMgr *Manager) syncConfigMaps(
916925
if cm.ObjectMeta.Namespace != sKey.Namespace {
917926
continue
918927
}
928+
// If as3 just continue
929+
if val, ok := cm.ObjectMeta.Labels["as3"]; ok {
930+
if as3Val, err := strconv.ParseBool(val); err == nil {
931+
if as3Val {
932+
continue
933+
}
934+
}
935+
}
919936

920937
rsCfg, err := parseConfigMap(cm, appMgr.schemaLocal, appMgr.vsSnatPoolName)
921938
if nil != err {

pkg/appmanager/appManager_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4068,6 +4068,16 @@ var _ = Describe("AppManager Tests", func() {
40684068
Expect(events[0].Reason).To(Equal("DNSResolutionError"))
40694069
Expect(events[1].Reason).To(Equal("ResourceConfigured"))
40704070
})
4071+
// Test Case to check AS3 specific branching out.
4072+
It("ConfigMap with AS3 true flag", func() {
4073+
cfgFoo := test.NewConfigMap("foomap", "1", namespace, map[string]string{
4074+
"data": configmapFoo})
4075+
cfgFoo.ObjectMeta.Labels = make(map[string]string)
4076+
cfgFoo.ObjectMeta.Labels["as3"] = "true"
4077+
ok, keyList := mockMgr.appMgr.checkValidConfigMap(cfgFoo)
4078+
Expect(ok).To(BeTrue(), "ConfigMap with AS3 TRUE be processed.")
4079+
Expect(keyList[:1][0].As3Name).To(Equal("foomap"))
4080+
})
40714081
})
40724082

40734083
Context("namespace related", func() {

pkg/appmanager/validateResources.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,26 @@ func (appMgr *Manager) checkValidConfigMap(
2929
) (bool, []*serviceQueueKey) {
3030
// Identify the specific service being referenced, and return it if it's
3131
// one we care about.
32+
var keyList []*serviceQueueKey
3233
cm := obj.(*v1.ConfigMap)
3334
namespace := cm.ObjectMeta.Namespace
3435
_, ok := appMgr.getNamespaceInformer(namespace)
3536
if !ok {
3637
// Not watching this namespace
3738
return false, nil
3839
}
40+
//check as3 config map.
41+
// if ok, add cfgMap name and data to serviceQueueKey.
42+
if ok := appMgr.checkAs3ConfigMap(obj); ok {
43+
log.Debugf("[as3_log] Found AS3 ConfigMap - %s.", cm.ObjectMeta.Name)
44+
key := &serviceQueueKey{
45+
Namespace: namespace,
46+
As3Name: cm.ObjectMeta.Name,
47+
As3Data: cm.Data["template"],
48+
}
49+
keyList = append(keyList, key)
50+
return true, keyList
51+
}
3952
cfg, err := parseConfigMap(cm, appMgr.schemaLocal, appMgr.vsSnatPoolName)
4053
if nil != err {
4154
if handleConfigMapParseFailure(appMgr, cm, cfg, err) {
@@ -62,7 +75,6 @@ func (appMgr *Manager) checkValidConfigMap(
6275
ServiceName: cfg.Pools[0].ServiceName,
6376
Namespace: namespace,
6477
}
65-
var keyList []*serviceQueueKey
6678
keyList = append(keyList, key)
6779
return true, keyList
6880
}
@@ -363,3 +375,23 @@ func validateAppRootAnnotations(rsType int, entries map[string]string) {
363375
}
364376
}
365377
}
378+
379+
// name: checkAs3ConfigMap
380+
// arguments: obj interface{} - ConfigMap Object
381+
// return val: bool - is it AS3 or not
382+
// description: This function validates configmap be AS3 specific or not
383+
384+
func (appMgr *Manager) checkAs3ConfigMap(
385+
obj interface{},
386+
) bool {
387+
// check for metadata.labels has 'as3' and that 'as3' is set to 'true'
388+
cm := obj.(*v1.ConfigMap)
389+
labels := cm.ObjectMeta.Labels
390+
if val, ok := labels["as3"]; ok {
391+
log.Debugf("[as3_log] Found AS3 config map...")
392+
if val == "true" {
393+
return true
394+
}
395+
}
396+
return false
397+
}

0 commit comments

Comments
 (0)