Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly grab map values instead of using loop-clause variables when setting up federated sync controller tests. #47061

Merged

Conversation

madhusudancs
Copy link
Contributor

Go's loop-clause variables are allocated once and the items are copied to that variable while iterating through the loop. This means, these variables can't escape the scope since closures are bound to loop-clause variables whose value change during each iteration. Doing so would lead to undesired behavior. For more on this topic see: https://github.com/golang/go/wiki/CommonMistakes

So in order to workaround this problem in sync controller e2e tests, we iterate through the map and copy the map value to a variable inside the loop before using it in closures.

Fixes issue: #47059

Release note:

NONE

/assign @marun @shashidharatd @perotinus

cc @csbell @nikhiljindal

/sig federation

…setting up federated sync controller tests.

Go's loop-clause variables are allocated once and the items are copied
to that variable while iterating through the loop. This means, these
variables can't escape the scope since closures are bound to loop-clause
variables whose value change during each iteration. Doing so would lead
to undesired behavior. For more on this topic see:
https://github.com/golang/go/wiki/CommonMistakes

So in order to workaround this problem in sync controller e2e tests, we
iterate through the map and copy the map value to a variable inside the
loop before using it in closures.

Fixes issue: kubernetes#47059
@k8s-ci-robot k8s-ci-robot added sig/federation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 6, 2017
@madhusudancs madhusudancs added this to the v1.7 milestone Jun 6, 2017
@k8s-github-robot k8s-github-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Jun 6, 2017
@shashidharatd
Copy link

Superb @madhusudancs, you nailed the issue. During the ginkgo tree construction time (explained in onsi/ginkgo#168 (comment)) probably only one federated type is picked by the function closure.

The fix looks good to me.
/lgtm

Now after this PR all tests will start to fail i think, because of daemonset test failure :(
The CI was at-least passing in the instances when it was not picking daemonset.
request @madhusudancs to prioritize the daemonset fix.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 6, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: madhusudancs, shashidharatd

Associated issue: 47059

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@madhusudancs
Copy link
Contributor Author

madhusudancs commented Jun 6, 2017

Now after this PR all tests will start to fail i think, because of daemonset test failure :(
The CI was at-least passing in the instances when it was not picking daemonset.

@shashidharatd that's true. I am not entirely sure if I should be happy or sad about this fix :P

request @madhusudancs to prioritize the daemonset fix.

Agreed. I had a chat with @janetkuo. Updated the issue with the resolution - #46925 (comment). Please take a look and comment.

@madhusudancs
Copy link
Contributor Author

@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this

@csbell
Copy link
Contributor

csbell commented Jun 6, 2017

/priority failing-test

@k8s-ci-robot k8s-ci-robot added the kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. label Jun 6, 2017
@madhusudancs
Copy link
Contributor Author

/retest

2 similar comments
@madhusudancs
Copy link
Contributor Author

/retest

@madhusudancs
Copy link
Contributor Author

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 46977, 47005, 47018, 47061, 46809)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants