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

Refactor how the Elasticsearch controller retrieves resources (rely on ResourcesState?) #3490

Open
sebgl opened this issue Jul 20, 2020 · 0 comments

Comments

@sebgl
Copy link
Contributor

sebgl commented Jul 20, 2020

There is a bit of confusion coming from the way we check Pods and StatefulSets in the Elasticsearch controller.

In some places we rely on a ResourcesState struct:

type ResourcesState struct {
// AllPods are all the Elasticsearch pods related to the Elasticsearch cluster, including ones with a
// DeletionTimestamp tombstone set.
AllPods []corev1.Pod
// CurrentPods are all non-deleted Elasticsearch pods.
CurrentPods []corev1.Pod
// CurrentPodsByPhase are all non-deleted Elasticsearch indexed by their PodPhase
CurrentPodsByPhase map[corev1.PodPhase][]corev1.Pod
// DeletingPods are all deleted Elasticsearch pods.
DeletingPods []corev1.Pod
// ExternalService is the user-facing service related to the Elasticsearch cluster.
ExternalService corev1.Service
}

This struct contains the actual Pods (and StatefulSets), retrieved only once.

In other places we retrieve Pods and StatefulSets from the client in the middle of the reconciliation:

// check if actual StatefulSets and corresponding pods match our expectations before applying any change
ok, err := d.expectationsSatisfied()
if err != nil {
return results.WithError(err)
}
if !ok {
return results.WithResult(defaultRequeue)
}
actualStatefulSets, err := sset.RetrieveActualStatefulSets(d.Client, k8s.ExtractNamespacedName(&d.ES))
if err != nil {
return results.WithError(err)
}

We should pick a single way of doing things. I tend to think working with the Pods and StatefulSets retrieved through ResourcesState, only once at the beginning of the reconciliation, is cleaner and produces more deterministic actions.

We should also make sure the entire thing plays well with the expectations mechanism.

@sebgl sebgl changed the title Refactor Elasticsearch controller ResourcesState Refactor how the Elasticsearch controller retrieves resources (rely on ResourcesState?) Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant