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

Add SessionAffinity and SessionAffinityConfig fields to ServiceOptions #571

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

trevorpburke
Copy link

@trevorpburke trevorpburke commented May 24, 2023

Attempts to address: #535

Copy link
Contributor

@HoustonPutman HoustonPutman left a comment

Choose a reason for hiding this comment

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

This is a great start!

So what you have done is make the configuration available in the CRD. So the user can now provide it, however it doesn't actually set the configuration on the underlying Services that are created for the SolrCloud/PrometheusExporter.

So we still need to:

  • add the controller logic to set these fields when creating services
  • make sure the fields are copied correctly when updating the services
  • add tests to ensure the fields are propagated correctly
  • Add helm chart options

If you want an example of a PR that does something very similar, you can look here: #350

I'm happy to contribute too, I just don't want to step on your toes! Let me know how I can help 🙂

@@ -164,6 +164,14 @@ type ServiceOptions struct {
// Labels to be added for the Service.
// +optional
Labels map[string]string `json:"labels,omitempty"`

// Supports "ClientIP" and "None". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None
// +optional
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// +optional
// +optional
// +kubebuilder:default=None
// +kubebuilder:validation:Enum=None,ClientIP

So we can actually put the default, and the enum constraints into the CRD itself using Kubebuilder CRD markers!

Copy link
Author

Choose a reason for hiding this comment

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

Ah, neat code-gen


// sessionAffinityConfig contains the configurations of session affinity.
// +optional
SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
SessionAffinityConfig *corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`

Making this field a pointer, makes it easier for us to know whether the user provided one or not!

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense

@trevorpburke
Copy link
Author

trevorpburke commented May 31, 2023

This is a great start!

So what you have done is make the configuration available in the CRD. So the user can now provide it, however it doesn't actually set the configuration on the underlying Services that are created for the SolrCloud/PrometheusExporter.

So we still need to:

  • add the controller logic to set these fields when creating services
  • make sure the fields are copied correctly when updating the services
  • add tests to ensure the fields are propagated correctly
  • Add helm chart options

If you want an example of a PR that does something very similar, you can look here: #350

I'm happy to contribute too, I just don't want to step on your toes! Let me know how I can help 🙂

Thanks for the feedback. I think I addressed updating the helm/ files that were changed in the PR you linked. Can you share which of those files in #350 are generated vs manually written?

AFAICT it looks like I need to also update controllers/util/solr_util.go, controllers/util/prometheus_exporter_util.go, and controllers/util/common.go.

Also, make prepare is failing for me, but guessing that's because I need to add to the controllers/util/ files and the accompanying tests

Copy link
Contributor

@HoustonPutman HoustonPutman left a comment

Choose a reason for hiding this comment

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

The changes look good so far! Just a few comments.

Now for actually implementing and testing!

There are three places to implement this logic.

In controllers/util/solr_util.go:GenerateCommonService(). That is what generates the common service for the solrCloud, so that's where we need to take these options from the SolrCloud and pass it to the Service.

In controllers/util/prometheus_exporter_util.go:GenerateSolrMetricsService(). This should be exactly (or almost exactly) the same logic as used above. We just need to support the same thing for the prometheus exporter, since it's a shared option amongst all services.

In controllers/util/common.go:CopyServiceFields(). This is where we update the existing service with what our "expected state" of the service is. So we are copying from the from service to the to service. You can basically copy and paste those if statements, using new ones for sessionAffinity and sessionAffinityConfig.

Then our last step will be testing!

// +optional
SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
// +kubebuilder:default=None
Copy link
Contributor

Choose a reason for hiding this comment

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

These (the default and enum lines) were meant to be put up above with sessionAffinity, not sessionAffinityConfig.

helm/solr/README.md Outdated Show resolved Hide resolved
@HoustonPutman
Copy link
Contributor

Also just a thought, but we are giving users the option for the headlessService and podService, but those really don't need sessionAffinity, because they are meant to send requests to a single pod, so affinity doesn't matter. So I'm fine leaving those undocumented and unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants