-
Notifications
You must be signed in to change notification settings - Fork 104
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
Bumped dependencies #1420
Conversation
{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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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>
2c1ef5b
to
579263d
Compare
…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>
579263d
to
06fafe0
Compare
….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>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
There was a problem hiding this 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.
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary:
Gotchas:
For some harness tests, I had to edit our test CRDs like:
With new kubectl version, the original name had multiple problems:
k8s.io
are restricted and now require anapi-approved.kubernetes.io
annotation pointing to a PR which introduced themreason: ApprovedAnnotation
thus bringing the number ofstatus.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