Skip to content

Conversation

@petr-muller
Copy link
Member

@petr-muller petr-muller commented Dec 13, 2022

Looking at Cache.Match() implementation, the c.Condition.Match() on L133 can be called with targetCondition=nil and that seems to be intentional. In tests, c.Condition is a mock, which did not expect that pointer to be nil and dereferenced it, resulting in an occassional panic in tests like #871 (comment). The fix stores the full pointer (its deepcopy to avoid sharing that memory) in the mock instead.

I needed to restructure the tests a little to allow adding a nil parameter testcase

@openshift-ci openshift-ci bot requested review from DavidHurta and wking December 13, 2022 17:51
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 13, 2022
@petr-muller
Copy link
Member Author

/test e2e-agnostic

@petr-muller
Copy link
Member Author

/retest

2 similar comments
@petr-muller
Copy link
Member Author

/retest

@petr-muller
Copy link
Member Author

/retest

@petr-muller
Copy link
Member Author

/override ci/prow/e2e-agnostic-upgrade-into-change

Node ci-op-ss56w10k-b1493-6h6wr-worker-eastus21-6w9b7 went unready multiple times: 2022-12-15T00:54:13Z, 2022-12-15T00:58:34Z
Node ci-op-ss56w10k-b1493-6h6wr-worker-eastus21-6w9b7 went ready multiple times: 2022-12-15T00:57:01Z, 2022-12-15T00:58:39Z

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 15, 2022

@petr-muller: Overrode contexts on behalf of petr-muller: ci/prow/e2e-agnostic-upgrade-into-change

Details

In response to this:

/override ci/prow/e2e-agnostic-upgrade-into-change

Node ci-op-ss56w10k-b1493-6h6wr-worker-eastus21-6w9b7 went unready multiple times: 2022-12-15T00:54:13Z, 2022-12-15T00:58:34Z
Node ci-op-ss56w10k-b1493-6h6wr-worker-eastus21-6w9b7 went ready multiple times: 2022-12-15T00:57:01Z, 2022-12-15T00:58:39Z

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@DavidHurta DavidHurta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor requested change and one even smaller possible nitpick 👍

Other than that, the code looks good to me! I really like the new restructured code. At least for me, it's more readable.

},
{
name: "two entries, both old evaluatations, clear evaluation winner",
name: "two entries, both old evaluations, clear evaluation winner",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment actually refers to lines 97--100 in the file cache_test.go:

name := fmt.Sprintf("condition %d", i)
condition := configv1.ClusterCondition{Type: name}
var previousCall *mock.Call
for j, call := range m.Calls {
	if reflect.DeepEqual(call.Condition, condition) {

Especially the line:

	if reflect.DeepEqual(call.Condition, condition) {

Given the changes to the Call structure we would be now calling the reflect.DeepEqual() function on a pointer (call.Condition) and a structure (condition) resulting in the function never returning true since a pointer and a data structure are not deeply equal.


Something like:

condition := &configv1.ClusterCondition{Type: name}

should do the trick.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch 👍

I'll also check whether the test could be made more robust against such silent failure, it seems that it's quite easy to unwittingly make this test silently pass by never passing that DeepEqual.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was the only other place where .Condition was used, so we should be safe now. I also improved the test to fail when the checked condition is not found in the recorded calls (it fails before the fix you suggested).

Looking at `Cache.Match()` implementation, the `c.Condition.Match()` on L133 can be called with `targetCondition=nil` and that seems to be intentional. In tests, `c.Condition` is a mock, which did not expect that pointer to be `nil` and dereferenced it, resulting in an occassional panic in tests like openshift#871 (comment). The fix stores the full pointer (its deepcopy to avoid sharing that memory) in the mock instead.

I needed to restructure the tests a little to allow adding a nil parameter testcase
@petr-muller
Copy link
Member Author

/retest

1 similar comment
@petr-muller
Copy link
Member Author

/retest

@petr-muller
Copy link
Member Author

/override ci/prow/e2e-agnostic-upgrade-out-of-change

{  ingress-to-console-reused-connections was unreachable during disruption testing for at least 16s of 1h13m32s (maxAllowed=14s):

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 19, 2022

@petr-muller: Overrode contexts on behalf of petr-muller: ci/prow/e2e-agnostic-upgrade-out-of-change

Details

In response to this:

/override ci/prow/e2e-agnostic-upgrade-out-of-change

{  ingress-to-console-reused-connections was unreachable during disruption testing for at least 16s of 1h13m32s (maxAllowed=14s):

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@DavidHurta
Copy link
Contributor

DavidHurta commented Dec 21, 2022

Override seems to be justified, this PR only affects unit tests and shouldn't result in the given error.

New changes look good to me 👍

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 21, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Davoska, petr-muller

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

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 71fb59f and 2 for PR HEAD 882c63d in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 21, 2022

@petr-muller: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit 0969cc7 into openshift:master Dec 21, 2022
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. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants