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

Association controller bug fixes #2679

Merged
merged 17 commits into from
Mar 18, 2020
Merged

Conversation

barkbay
Copy link
Contributor

@barkbay barkbay commented Mar 9, 2020

This PR fixes #2675 #2674 #2694 #2695 #2692

About the unit test: I only added a unit test for #2674. My feeling is that either we are missing some tooling to properly create unit tests against controllers or adding a unit test to cover reconcileInternal would be out the scope of this PR. I can, however, create an issue to track this.

@barkbay barkbay added v1.1.0 >bug Something isn't working labels Mar 9, 2020
Copy link
Contributor

@sebgl sebgl left a comment

Choose a reason for hiding this comment

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

Good catch!

I have some comments because parts of the code are not exactly clear to me. Most of those are not related to this PR though, but I guess to existing code that was moved around by this PR. Since everything's still fresh in your mind I thought this PR may be worth adding some clarification and/or refactoring?

pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
pkg/controller/kibanaassociation/association_controller.go Outdated Show resolved Hide resolved
pkg/controller/kibanaassociation/labels.go Outdated Show resolved Hide resolved
@barkbay
Copy link
Contributor Author

barkbay commented Mar 13, 2020

This PR adds a consistent way to detect Secrets that serves an association purpose.
They now all have the following labels:

  • [kibana|apm]association.k8s.elastic.co/name
  • [kibana|apm]association.k8s.elastic.co/namespace

This simplifies the code, we don't need to rely on ownership for some of them or labels for some other ones.

It's also fixes some issues found while reviewing the code.

I'll update the title and the description before merging.

@barkbay barkbay requested a review from sebgl March 16, 2020 14:58
@@ -68,10 +69,12 @@ func ReconcileCASecret(
Expected: &expectedSecret,
Reconciled: &reconciledSecret,
NeedsUpdate: func() bool {
return !reflect.DeepEqual(expectedSecret.Data, reconciledSecret.Data)
return !reflect.DeepEqual(expectedSecret.Data, reconciledSecret.Data) ||
!maps.IsSubset(expectedSecret.Labels, reconciledSecret.Labels)
Copy link
Contributor

Choose a reason for hiding this comment

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

#2707 should help.
I'll do a second pass in a few days for in-flight PRs that did not benefit from it so we can keep this PR as is.

pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
pkg/controller/common/association/resources.go Outdated Show resolved Hide resolved
@@ -0,0 +1,74 @@
package association
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole file is much easier to digest since you changed the labelling logic 🙏

pkg/controller/kibana/driver.go Show resolved Hide resolved
Copy link
Contributor

@sebgl sebgl left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -290,6 +251,69 @@ func Test_deleteOrphanedResources(t *testing.T) {
},
wantErr: false,
},
{
name: "No more es ref in Kibana, orphan user for previous es ref in a different namespace still exist",
Copy link
Collaborator

Choose a reason for hiding this comment

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

exists

@barkbay barkbay changed the title Fix association resource leak Association controller bug fixes Mar 18, 2020
@barkbay barkbay merged commit b73d83c into elastic:master Mar 18, 2020
@barkbay barkbay deleted the assoc-user-leak branch March 18, 2020 09:26
@anyasabo anyasabo mentioned this pull request Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Something isn't working v1.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annotation 'association.k8s.elastic.co/es-conf' should be removed for unmanaged ES clusters
3 participants