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

Bumped dependencies #1420

Merged
merged 12 commits into from
Mar 18, 2020
Merged

Bumped dependencies #1420

merged 12 commits into from
Mar 18, 2020

Conversation

zen-dog
Copy link
Contributor

@zen-dog zen-dog commented Mar 11, 2020

Summary:

  • controller-runtime to 0.5.1
  • kubectl to 0.17.3

Gotchas:
For some harness tests, I had to edit our test CRDs like:

-  name: mycrds.mycrd.k8s.io
+  name: mycrds.mycrd.example.com

With new kubectl version, the original name had multiple problems:

  • names ending with k8s.io are restricted and now require an api-approved.kubernetes.io annotation pointing to a PR which introduced them
  • adding this annotation proved challenging since we then see a new transition condition with the reason: ApprovedAnnotation thus bringing the number of status.condition s to three. These conditions would sometimes arrive out of order, however, test harness does not support the same order of elements when comparing two arrays, thus making the tests flaky. See this thread for more details:

Signed-off-by: Aleksey Dukhovniy alex.dukhovniy@googlemail.com

{bool: true, createns: "default", obj: &obj}, // 4
{getns: "kudo", obj: &obj}, // 4
{exists: true, obj: &obj}, // 3
{exists: true, createns: "default", obj: &obj, getns: "default"}, // 4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was failing without explicitly using namespace default.

@@ -32,7 +33,7 @@ func TestStepClean(t *testing.T) {
pod2WithNamespace := testutils.NewPod("hello2", testNamespace)
pod2WithDiffNamespace := testutils.NewPod("hello2", "different-namespace")

cl := fake.NewFakeClient(pod, pod2WithNamespace, pod2WithDiffNamespace)
cl := fake.NewFakeClientWithScheme(scheme.Scheme, pod, pod2WithNamespace, pod2WithDiffNamespace)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NewFakeClient method is deprecated

@@ -53,16 +54,16 @@ func TestStepClean(t *testing.T) {
// Each test provides a path to a set of test steps and their rendered result.
func TestStepCreate(t *testing.T) {

pod := testutils.NewPod("hello", "")
pod := testutils.NewPod("hello", "default")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

another case where a test started to fail without an explicit default namespace.

Choose a reason for hiding this comment

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

🤔 I feel like this behavior as tested is wrong. It should only be setting the namespace if it isn't set. Do you know what changed?

Copy link
Contributor Author

@zen-dog zen-dog Mar 13, 2020

Choose a reason for hiding this comment

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

So, for anybody who is interested: after some researching and debugging, I believe it was this change in go-client testing fixture that made this test fail. The commit description says it all.
As for the default client, this is also explicitly forbidden. Another mystery solved.

@@ -3,6 +3,8 @@ apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: mycrds.mycrd.k8s.io
annotations:
api-approved.kubernetes.io: "https://github.com/kubernetes/enhancements/pull/1111"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the PR in the annotation for more details on why this is needed

@@ -11,8 +11,3 @@ status:
singular: mycrd
storedVersions:
- v1beta1
conditions:

Choose a reason for hiding this comment

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

Did something in the CRD API change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see my comment below

@@ -53,16 +54,16 @@ func TestStepClean(t *testing.T) {
// Each test provides a path to a set of test steps and their rendered result.
func TestStepCreate(t *testing.T) {

pod := testutils.NewPod("hello", "")
pod := testutils.NewPod("hello", "default")

Choose a reason for hiding this comment

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

🤔 I feel like this behavior as tested is wrong. It should only be setting the namespace if it isn't set. Do you know what changed?

@@ -11,8 +11,3 @@ status:
singular: mycrd
storedVersions:
- v1beta1
conditions:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have one more condition now:

  - type: KubernetesAPIApprovalPolicyConformant
    reason: ApprovedAnnotation
    status: "True"

and with that, the test became flaky. I'm not sure if it takes a while for the transition to happen or smth. else

Copy link
Contributor Author

@zen-dog zen-dog Mar 13, 2020

Choose a reason for hiding this comment

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

Ok, so I've got to the bottom of it (which in the hindsight wasn't very deep): with three conditions, they sometimes simply come out of order and test-harness expects the same order of elements when comparing slices in the IsSubset method. A quick test confirms:

assert.Nil(t, IsSubset(
	[]string{"foo", "bar"},
	[]string{"bar", "foo"},
))

fails with: 
Expected nil, but got: &utils.SubsetError{path:[]string(nil), message:"value mismatch, expected: foo != actual: bar"}

However, it turns out we can not omit the conditions here:

  • the first step creates the CRD and assumes that they're created
  • the second step creates a CR of that CRD

but the second create-step (not the assert one) occasionally fails with the server could not find the requested resource because the CRD hasn't gone through all transitions yet.

I'd suggest fixing IsSubset comparing slices but I'm not sure about all the implications. /cc @justinbarrick

Choose a reason for hiding this comment

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

Yeah, right now it is order dependent, I need to evaluate existing tests to see if order is often important. IIRC @alenkacz and I discussed this a while back but I don't remember where we landed on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so I avoided the problem for this bump by changing the CRD name/group to prowjobs.prow.example.com (instead of *.k8s.io) which doesn't require the annotation and so we only have the same two conditions as before (these two do not come out of order).

However, the bigger question stays: I'm not sure if k8s guarantee array elements order in all places. We might want to relax the current subset comparison to be order independent or give the user the choice to use both (some sort of annotation maybe?)

@@ -5,13 +5,5 @@ metadata:
status:
acceptedNames:
kind: ProwJob
# InitialNamesAccepted will change from False -> True once the CRD is ready.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here

"--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}",
"--insecure-bind-address={{ if .URL }}{{ .URL.Hostname }}{{ end }}",
"--secure-port={{ if .SecurePort }}{{ .SecurePort }}{{ end }}",
"--admission-control=AlwaysAdmit",
Copy link
Contributor

@alenkacz alenkacz Mar 12, 2020

Choose a reason for hiding this comment

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

I wrote you a lenghty comment on slack so just re-posting part of it here because this won't work:

if you're interested in the details - before the admission plugins were disabled altogether with AlwaysAdmiy, that was the default behavior of envtest, so no admission plugin was ever hit in tests (I think that is wrong anyway and we plan to change it in 0.6.0). But I needed to touch that anyway because I needed to enable webhook admission plugins in order for webhooks to work. So I had to drop AlwaysAdmit and that might be the reason. I instead explicitly disabled all admission plugins that are enabled by default but maybe that's not exactly 1:1 and might be causing you some troubles (edited)

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean it's fine for the bump, but not for the webhooks test. It's also not fine in general because you're ignoring all kinds of real apiserver errors that normally happen

and kubectl to 0.17.3

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
…ator`

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
@zen-dog zen-dog force-pushed the ad/bump-controller-runtime-0.5.1 branch from 2c1ef5b to 579263d Compare March 13, 2020 14:17
…rguments"

This reverts commit a7b1150.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
…ersion

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
@zen-dog zen-dog force-pushed the ad/bump-controller-runtime-0.5.1 branch from 579263d to 06fafe0 Compare March 13, 2020 14:31
….example.com`

this will avoid the problem of having to compare slices independent of elements order since we wont have the annotation condition present.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
go.mod Outdated Show resolved Hide resolved
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Copy link
Member

@porridge porridge left a comment

Choose a reason for hiding this comment

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

Please mention why we needed this bump in PR description.

Also, I'd suggest changing:

Bumped controller-runtime to 0.5.1

and kubectl to 0.17.3

To something like:

Bumped dependencies.

- controller-runtime to 0.5.1
- kubectl to 0.17.3

Finally, if you feel like it, it would be great if you could summarize the gotchas in the PR description for posterity. Right now it can take a while to hunt them down and realize there was a slight change of approach on the .k8s.io issue.

pkg/kudoctl/util/kudo/kudo_test.go Show resolved Hide resolved
pkg/test/test_data/crd-in-step/00-assert.yaml Show resolved Hide resolved
@zen-dog zen-dog changed the title Bumped controller-runtime to 0.5.1 Bumped dependencies Mar 17, 2020
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Copy link
Member

@ANeumann82 ANeumann82 left a comment

Choose a reason for hiding this comment

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

lgtm

@zen-dog zen-dog merged commit 452c5b6 into master Mar 18, 2020
@zen-dog zen-dog deleted the ad/bump-controller-runtime-0.5.1 branch March 18, 2020 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants