Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Use label selector when listing pods in es controller #187

Merged
merged 1 commit into from
Jan 11, 2018

Conversation

munnerz
Copy link
Contributor

@munnerz munnerz commented Jan 9, 2018

What this PR does / why we need it:

Use a label selector in the Elasticsearch navigator-controller implementations when listing pods to create Pilots for.

This also simplifies the Pilot creation code and decouples it from node pools.

Release note:

NONE

@munnerz
Copy link
Contributor Author

munnerz commented Jan 9, 2018

/test e2e

Copy link
Member

@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

Thanks @munnerz.

  1. Looks good and much simpler than checking the ownership of each pod.
  2. (assuming you agree that the ownership check is no longer necessary)
  3. And should also make it simpler to add unit tests for the Pilot sync method....no need to create a corresponding StatefulSet with ownerrefs, for the pods in tests.
  4. If an ownership check is still necessary, I was looking into whether the pods can be given multiple owner refs....owned by both the statefulset (controller=true) and the ElasticSearch cluster (controller=false)....but I couldn't find any way to add ownerrefs to the statefulset pod template.
  5. Also wondered if it's possible to supply a field selector to List....in which case you could use that for the owner check.

Please merge when the tests pass.

if err != nil {
return err
}

for _, pod := range allPods {
isMember, err := util.PodControlledByCluster(c, pod, e.statefulSetLister)
Copy link
Member

Choose a reason for hiding this comment

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

isMember is now unused and causing compile errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack - accidentally removed too much code!

for _, pod := range allPods {
isMember, err := util.PodControlledByCluster(c, pod, e.statefulSetLister)

if err != nil {
return fmt.Errorf("error checking if pod is controller by elasticsearch cluster: %s", err.Error())
}

if isMember {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it important to also check that the pod is owned by the esCluster resource?
I thought this check was to ensure against deleting pods that, somehow, had been created independently, with the matching cluster label.
And if not, we've got code that looks up the owner of the owning statefulset; can that now be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - this shouldn't have been removed. I've added that check back in.

@munnerz
Copy link
Contributor Author

munnerz commented Jan 10, 2018

/test all

@munnerz
Copy link
Contributor Author

munnerz commented Jan 10, 2018

Thanks for taking a look @wallrj. I've updated to reintroduce the ownership check as it is still necessary. Regarding two ownerReferences - it would be nice, but also quite complex to do via a StatefulSet pod template (and perhaps not possible?). For now I think it's easiest to keep the behaviour the same.

@munnerz munnerz added the lgtm label Jan 10, 2018
@munnerz
Copy link
Contributor Author

munnerz commented Jan 10, 2018

/approve

@jetstack-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: munnerz

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@jetstack-ci-bot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@munnerz
Copy link
Contributor Author

munnerz commented Jan 10, 2018

Test flake caused by #106. I've opened #188 which should resolve it.

@munnerz
Copy link
Contributor Author

munnerz commented Jan 11, 2018

/test verify

@jetstack-ci-bot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@jetstack-ci-bot
Copy link
Contributor

Automatic merge from submit-queue.

@jetstack-ci-bot jetstack-ci-bot merged commit 391640d into jetstack:master Jan 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants