[Fleet] Deprecate is_default and is_default_fleet_server flags#6724
Conversation
411eeb4 to
7eb423f
Compare
pebrc
left a comment
There was a problem hiding this comment.
LGTM want to run a few tests still. I like the way you integrated warnings into the webhook tooling 👍
| ) | ||
|
|
||
| var ( | ||
| MandatoryPolicyIDVersion = version.MustParse("9.0.0-SNAPSHOT") |
There was a problem hiding this comment.
Do we know it is going away in 9.0.0 or is this only a placeholder? If so let's add a comment.
There was a problem hiding this comment.
Hi @juliaElastic 👋 , could you confirm that is_default and is_default_fleet_server flags should be removed in 9.0.0?
There was a problem hiding this comment.
Yes, that is the plan.
| // We have read the min. expected number of events | ||
| return gotEvents | ||
| } | ||
| case <-c: |
There was a problem hiding this comment.
Do we need the timeout given that this is always used in a unit test context and there is no expectation of concurrent use?
t.Helper()
if minEventCount == 0 {
return nil
}
gotEvents := make([]string, 0, minEventCount)
gotEventCount := 0
for i := 0; i < minEventCount; i++ {
select {
case e := <-recorder.Events:
gotEvents = append(gotEvents, e)
gotEventCount++
default:
t.Errorf("expected at least %d events, got %d", minEventCount, gotEventCount)
}
}
return gotEventsalso the name is could be then something along the lines of ReadNEvents
There was a problem hiding this comment.
Do we need the timeout given that this is always used in a unit test context and there is no expectation of concurrent use?
I think we need a timeout so we eventually exit the function if there are less events than minEventCount. Otherwise, the function may wait forever on case e := <-recorder.Events.
There was a problem hiding this comment.
That's why I added the default clause in the select so that it immediately errors out or maybe I am missing your point.
There was a problem hiding this comment.
Sorry I'm missed your original point. I was assuming that we didn't want to depend on whether or not events were published synchronously in the recorder. But I agree that it is fair to say that it will be the case here.
pebrc
left a comment
There was a problem hiding this comment.
LGTM I tried the webhook very nice!

This PR:
spec.PolicyIDis not set:{ "kind": "AdmissionReview", "apiVersion": "admission.k8s.io/v1beta1", "response": { "uid": "705ab4f5-6393-11e8-b7cc-42010a800002", "allowed": true, "status": { "metadata": {}, "code": 200 }, "warnings": [ "spec.PolicyID is empty, spec.PolicyID will become mandatory in a future release" ] } }is_defaultandis_default_fleet_serverfrom our examples and our documentation, addsspec.PolicyIDinstead.TODO:
is_defaultoris_default_fleet_serveris set.E2EFleetPoliciesas long as the flags are supported.spec.PolicyIDwill be tested as part of the updates inconfig/recipes/elastic-agent, for example withTestFleetKubernetesIntegrationRecipe. TODO: create an issue to track this effort once these 2 flags are actually removedspec.PolicyIDmandatory field for any stack version > 8.x.x ?Fix #6678