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

Kibana: Set status.ObservedGeneration from metadata.Generation #5409

Merged
merged 9 commits into from
Feb 28, 2022

Conversation

naemono
Copy link
Contributor

@naemono naemono commented Feb 23, 2022

This PR is Kibana specific.

related to #3392
related to #5331

This change allows status.ObservedGeneration to be kept in sync with metadata.Generation according to the rules described in the above issue. This change adds a set of unit tests which show more details into when observedGeneration will, and will not be updated according to any errors that may occur during reconciliation. Steps were added to any kibana mutating e2e tests to show how the change is intended to function in a true cluster.

@botelastic botelastic bot added the triage label Feb 23, 2022
@naemono naemono force-pushed the 3392-kibana-observedGeneration branch from caf4843 to 783a536 Compare February 23, 2022 18:05
@naemono naemono marked this pull request as ready for review February 23, 2022 18:08
@naemono
Copy link
Contributor Author

naemono commented Feb 23, 2022

run full pr build

1 similar comment
@naemono
Copy link
Contributor Author

naemono commented Feb 23, 2022

run full pr build

@pebrc pebrc added the >enhancement Enhancement of existing functionality label Feb 24, 2022
@botelastic botelastic bot removed the triage label Feb 24, 2022
@pebrc pebrc changed the title Kibanat: Set status.ObservedGeneration from metadata.Generation Kibana: Set status.ObservedGeneration from metadata.Generation Feb 24, 2022
pkg/controller/kibana/controller.go Show resolved Hide resolved
pkg/controller/kibana/controller.go Outdated Show resolved Hide resolved
pkg/controller/kibana/controller_test.go Outdated Show resolved Hide resolved
pkg/controller/kibana/controller_test.go Outdated Show resolved Hide resolved
test/e2e/test/generation/generation.go Outdated Show resolved Hide resolved
pkg/controller/kibana/controller.go Outdated Show resolved Hide resolved
@naemono naemono added the v2.1.0 label Feb 24, 2022
pkg/controller/kibana/controller.go Outdated Show resolved Hide resolved
pkg/controller/kibana/controller_test.go Show resolved Hide resolved
}

// RetrieveAgentGenerationsStep stores the current metadata.Generation, and status.ObservedGeneration into the given fields.
func RetrieveAgentGenerationsStep(obj commonv1.HasObservedGeneration, k *test.K8sClient, generation, observedGeneration *int64) test.Step {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agent?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would expect these also to be used for the Elasticsearch tests but I think you based this branch of a version of main where the observedGeneration code for Elasticsearch does not exist yet. Worth merging main and using the same code for both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed agent from this in this PR. Let me see about merging rebasing/merging main and fixing this in ES e2e tests also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rebased main, and updated Elasticsearch e2e tests to use shared/common generation package.

Update observedGeneration description.
Defer status updates to kibana to ensure status gets updated regardless of reconcilation outcome.
Add common generation steps for e2e tests to use.
add nolint:thelper to test because of validation func
Use named errors in doReconcile allowing deferred function to modify return values.
Update logic in NewState to not double copy original Kibana object.
Modify tests to check the error message returned from Reconcile.
Add a failing k8s client to unit test the deferred functional modifying the return values.
Remove agent from generic generation package in e2e tests.
@naemono naemono force-pushed the 3392-kibana-observedGeneration branch from 101f741 to 7836cc1 Compare February 24, 2022 17:33
@naemono
Copy link
Contributor Author

naemono commented Feb 24, 2022

run full pr build

Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

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

LGTM

// or more contributor license agreements. Licensed under the Elastic License 2.0;
// you may not use this file except in compliance with the Elastic License 2.0.

package generation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit I would probably have put this into common_steps.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking at the surrounding files, and their names, I went with steps_common.go. lmk if that's acceptable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I my comment was not explicit enough. I meant keeping this in the test package in the already existing file by that name. But either way is OK.

@naemono
Copy link
Contributor Author

naemono commented Feb 24, 2022

run full pr build

@naemono naemono merged commit d8bd53b into elastic:main Feb 28, 2022
@naemono naemono deleted the 3392-kibana-observedGeneration branch February 28, 2022 14:04
fantapsody pushed a commit to fantapsody/cloud-on-k8s that referenced this pull request Feb 7, 2023
…ic#5409)

* Add Kibana observedGeneration.
Update observedGeneration description.
Defer status updates to kibana to ensure status gets updated regardless of reconcilation outcome.
Add common generation steps for e2e tests to use.

* remove unnecessary args struct
add nolint:thelper to test because of validation func

* Add new interface for retrieving of observed generation.
Use named errors in doReconcile allowing deferred function to modify return values.
Update logic in NewState to not double copy original Kibana object.
Modify tests to check the error message returned from Reconcile.
Add a failing k8s client to unit test the deferred functional modifying the return values.

* Simplify Kibana new state logic.
Remove agent from generic generation package in e2e tests.

* Make Elasticsearch Generation e2e tests use common generation package.

* make receiver name consistent.

* Adjust wording in test name

* Add spacing to api docs

* rename common generation filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants