Bug 2099822

Summary: [4.10z] exporting a pointer for the loop variable
Product: OpenShift Container Platform Reporter: Tim Rozet <trozet>
Component: NetworkingAssignee: Tim Rozet <trozet>
Networking sub component: ovn-kubernetes QA Contact: Anurag saxena <anusaxen>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high CC: anusaxen, pdiak
Version: 4.10   
Target Milestone: ---   
Target Release: 4.10.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2099821 Environment:
Last Closed: 2022-07-07 11:40:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 2099821    
Bug Blocks:    

Description Tim Rozet 2022-06-21 18:50:06 UTC
+++ This bug was initially created as a clone of Bug #2099821 +++

Description of problem:
This problem was fixed in 4.11 during the dev cycle but still appears to be an issue in 4.10. There are many places in the code where this type of for loop is done:

	for i, sw := range switches {
		sw.ACLs = aclUUIDs
		swName := switches[i].Name
		opModels = append(opModels, OperationModel{
			Model:          &sw,
			ModelPredicate: func(ls *nbdb.LogicalSwitch) bool { return ls.Name == swName },
			OnModelMutations: []interface{}{
				&sw.ACLs,
			},
			ErrNotFound: true,
			BulkOp:      true,
		})
	}

Where the address of the loop variable is used to add to a slice. This will cause the slice to only ever hold the final object in the loop. One of the consequences of this kind of bug is that ACLs, or other OVN configuration may be missing since only the final object int he loop will have configuration applied.

--- Additional comment from Tim Rozet on 2022-06-21 18:49:17 UTC ---

Since this is not present in 4.11z, moving bug state.

Comment 1 Patryk Diak 2022-06-22 13:20:50 UTC
*** Bug 2100092 has been marked as a duplicate of this bug. ***

Comment 6 errata-xmlrpc 2022-07-07 11:40:21 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.10.21 bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:5428