1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

fixed emptying of generated map when main map is empty

This commit is contained in:
postmannen 2022-05-19 08:27:12 +02:00
parent 321150ac84
commit 83a7ea5193
2 changed files with 17 additions and 6 deletions

View file

@ -259,8 +259,18 @@ func (a *accessLists) generateACLsForAllNodes() error {
// are defined for each individual host node. // are defined for each individual host node.
// Range this map, and generate a JSON representation of all // Range this map, and generate a JSON representation of all
// the ACL's each host. // the ACL's each host.
fmt.Printf("\n --- DEBUG: IN GENERATE ACLsToConvert contains: %#v\n", a.schemaGenerated.ACLsToConvert)
func() { func() {
// If the map to generate from map is empty we want to also set the generatedACLsMap
// to empty so we can make sure that no more generated ACL's exists to be distributed.
if len(a.schemaGenerated.ACLsToConvert) == 0 {
fmt.Printf(" ****** MAP IS EMPTY\n")
a.schemaGenerated.GeneratedACLsMap = make(map[Node]HostACLsSerializedWithHash)
}
for n, m := range a.schemaGenerated.ACLsToConvert { for n, m := range a.schemaGenerated.ACLsToConvert {
fmt.Printf("\n ################ DEBUG: RANGE in generate: n=%v, m=%v\n", n, m)
// cbor marshal the data of the ACL map to store for the host node. // cbor marshal the data of the ACL map to store for the host node.
cb, err := cbor.Marshal(m) cb, err := cbor.Marshal(m)
@ -296,6 +306,7 @@ func (a *accessLists) generateACLsForAllNodes() error {
} }
}() }()
fmt.Printf("\n --- DEBUG: IN GENERATE GeneratedACLsMap contains: %v\n", a.schemaGenerated.GeneratedACLsMap)
return nil return nil
} }

View file

@ -47,11 +47,11 @@ func (m methodREQAclAddCommand) handler(proc process, message Message, node stri
// Just print out for testing. // Just print out for testing.
proc.centralAuth.accessLists.schemaMain.mu.Lock() proc.centralAuth.accessLists.schemaMain.mu.Lock()
fmt.Printf("\n ---------- content of main acl map: %v-----------\n", proc.centralAuth.accessLists.schemaMain.ACLMap) fmt.Printf("\n ########### content of main acl map: %v###########\n", proc.centralAuth.accessLists.schemaMain.ACLMap)
proc.centralAuth.accessLists.schemaMain.mu.Unlock() proc.centralAuth.accessLists.schemaMain.mu.Unlock()
proc.centralAuth.accessLists.schemaGenerated.mu.Lock() proc.centralAuth.accessLists.schemaGenerated.mu.Lock()
fmt.Printf("\n ---------- content of generated acl map: %v-----------\n", proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap) fmt.Printf("\n ########### content of generated acl map: %v###########\n", proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap)
proc.centralAuth.accessLists.schemaGenerated.mu.Unlock() proc.centralAuth.accessLists.schemaGenerated.mu.Unlock()
outString := fmt.Sprintf("acl added: host=%v, source=%v, command=%v\n", host, source, cmd) outString := fmt.Sprintf("acl added: host=%v, source=%v, command=%v\n", host, source, cmd)
@ -95,7 +95,7 @@ func (m methodREQAclDeleteCommand) getKind() Event {
} }
func (m methodREQAclDeleteCommand) handler(proc process, message Message, node string) ([]byte, error) { func (m methodREQAclDeleteCommand) handler(proc process, message Message, node string) ([]byte, error) {
inf := fmt.Errorf("<--- methodREQAclAddAccessList received from: %v, containing: %v", message.FromNode, message.MethodArgs) inf := fmt.Errorf("<--- methodREQAclDeleteCommand received from: %v, containing: %v", message.FromNode, message.MethodArgs)
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration) proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
proc.processes.wg.Add(1) proc.processes.wg.Add(1)
@ -127,14 +127,14 @@ func (m methodREQAclDeleteCommand) handler(proc process, message Message, node s
// Just print out for testing. // Just print out for testing.
proc.centralAuth.accessLists.schemaMain.mu.Lock() proc.centralAuth.accessLists.schemaMain.mu.Lock()
fmt.Printf("\n ---------- content of main acl map: %v-----------\n", proc.centralAuth.accessLists.schemaMain.ACLMap) fmt.Printf("\n ########### content of main acl map: %v###########\n", proc.centralAuth.accessLists.schemaMain.ACLMap)
proc.centralAuth.accessLists.schemaMain.mu.Unlock() proc.centralAuth.accessLists.schemaMain.mu.Unlock()
proc.centralAuth.accessLists.schemaGenerated.mu.Lock() proc.centralAuth.accessLists.schemaGenerated.mu.Lock()
fmt.Printf("\n ---------- content of generated acl map: %v-----------\n", proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap) fmt.Printf("\n ########### content of generated acl map: %v###########\n", proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap)
proc.centralAuth.accessLists.schemaGenerated.mu.Unlock() proc.centralAuth.accessLists.schemaGenerated.mu.Unlock()
outString := fmt.Sprintf("acl added: host=%v, source=%v, command=%v\n", host, source, cmd) outString := fmt.Sprintf("acl deleted: host=%v, source=%v, command=%v\n", host, source, cmd)
out := []byte(outString) out := []byte(outString)
select { select {