Skip to content

Comments

(feat): Extra Valkey config#44

Open
utdrmac wants to merge 21 commits intovalkey-io:mainfrom
utdrmac:valkeyConfig
Open

(feat): Extra Valkey config#44
utdrmac wants to merge 21 commits intovalkey-io:mainfrom
utdrmac:valkeyConfig

Conversation

@utdrmac
Copy link

@utdrmac utdrmac commented Jan 9, 2026

This feature request implements the ability for users to supply their own configuration for Valkey as an inline stanza when deploying a new cluster. The user configuration is appended to the required base configuration, which is created as a configMap. Since the operator manages the configMap, any changes to the config are reconciled. Additionally, users cannot override the required cluster settings.

This PR implements the ability for users to supply additional configuration for Valkey. Any provided parameters are appended to default configuration required by the operator

Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Copy link
Member

@sandeepkunusoth sandeepkunusoth left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@sandeepkunusoth sandeepkunusoth left a comment

Choose a reason for hiding this comment

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

lint errors and e2e errors

Signed-off-by: utdrmac <matthew.boehm@percona.com>
@utdrmac
Copy link
Author

utdrmac commented Jan 10, 2026

ugh. why didn't lint/fmt/vet catch those?

Signed-off-by: utdrmac <matthew.boehm@percona.com>
Copy link
Collaborator

@jdheyburn jdheyburn left a comment

Choose a reason for hiding this comment

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

Minor comments, keen to hear opinions, otherwise LGTM

Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
@utdrmac
Copy link
Author

utdrmac commented Jan 12, 2026

e2e still fails due to #43

@sandeepkunusoth
Copy link
Member

sandeepkunusoth commented Jan 12, 2026

e2e still fails due to #43

no this is different issue than 43. its failing because of events limitation. maybe as u have added new emit event other events are not coming. https://github.com/valkey-io/valkey-operator/actions/runs/20936033780/job/60159472854?pr=44.
image

check this PR description #37. maybe you can update events check accordingly. currently we are not asserting for all events due to events rate limit.

@utdrmac
Copy link
Author

utdrmac commented Jan 12, 2026

I only added 1 new event which isn't triggered during the e2e. When I run e2e on my local kind cluster, I don't get that failure; I get the same failure as #43.

@sandeepkunusoth
Copy link
Member

sandeepkunusoth commented Jan 12, 2026

I only added 1 new event which isn't triggered during the e2e. When I run e2e on my local kind cluster, I don't get that failure; I get the same failure as #43.

no i don't think its related. you can check the issue description failure test case and logs are different for both of these errors. i have neven seen failure of valkey creation CR test case in main branch. if in case we are seeing, we need to create different issue.

this PR is failing this test "Manager when a ValkeyCluster CR is applied [It] creates a Valkey Cluster deployment"

43 issue is with other test "Manager when a ValkeyCluster experiences degraded state [It] should detect and recover when a deployment is deleted" https://github.com/valkey-io/valkey-operator/actions/runs/20806446577/job/59761668293

quick fix: we may need to remove assertions of some of the events.

g.Expect(output).To(ContainSubstring("ClusterMeet"), "ClusterMeet event should appear in describe")

bjosv
bjosv previously approved these changes Jan 14, 2026
Copy link
Collaborator

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

LGTM

@bjosv
Copy link
Collaborator

bjosv commented Jan 15, 2026

Rebasing (or add merge commit of main) should fix the e2e test now.

Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
@utdrmac
Copy link
Author

utdrmac commented Jan 22, 2026

@bjosv The test failed on some trivial text matching. I removed it because the two lines above are checking the same string.

Copy link
Author

@utdrmac utdrmac left a comment

Choose a reason for hiding this comment

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

Everything is resolved. @sandeepkunusoth github says you've requested changes but I can't find anything unresolved when looking at the 'Files changed' tab.

r.Recorder.Eventf(cluster, corev1.EventTypeNormal, "ConfigMapUpdated", "Synchronized server configMap")

// All is good. Server configMap will be auto-mounted in the deployment
return nil
Copy link
Member

Choose a reason for hiding this comment

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

i dont think updated configmap will be auto mounted in the existing deployments during update. Did u test this

Copy link
Collaborator

@bjosv bjosv Jan 29, 2026

Choose a reason for hiding this comment

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

It seem to update the configfile in the pods when I test it on kind minikube now, but it takes some time before the file is getting updated.

But, I now see that we are not using SubPath in the VolumeMounts on containers..
We probably should (?) since both /scripts and /configs contains all files from the configmap.
The problem then will be that the volume mount will not receive updates when the ConfigMap changes though..

Copy link
Collaborator

Choose a reason for hiding this comment

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

Updating the configmap is one thing, but the Valkey instances will not use these updates anyway in the current form. Is that what you where thinking on @sandeepkunusoth ?
Maybe the update part in this PR could be moved to its own PR, which could include the pod restart/config reload depending on how we decide.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree that we should omit live applying changes to the config for another PR

// Create or update a default valkey.conf
// If additional config is provided, append to the default map
func (r *ValkeyClusterReconciler) upsertConfigMap(ctx context.Context, cluster *valkeyiov1alpha1.ValkeyCluster) error {

Copy link
Member

Choose a reason for hiding this comment

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

can we rename this file to configmap.go

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point

@sandeepkunusoth sandeepkunusoth requested a review from bjosv January 23, 2026 17:35
r.Recorder.Eventf(cluster, corev1.EventTypeNormal, "ConfigMapUpdated", "Synchronized server configMap")

// All is good. Server configMap will be auto-mounted in the deployment
return nil
Copy link
Collaborator

@bjosv bjosv Jan 29, 2026

Choose a reason for hiding this comment

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

It seem to update the configfile in the pods when I test it on kind minikube now, but it takes some time before the file is getting updated.

But, I now see that we are not using SubPath in the VolumeMounts on containers..
We probably should (?) since both /scripts and /configs contains all files from the configmap.
The problem then will be that the volume mount will not receive updates when the ConfigMap changes though..

// Create or update a default valkey.conf
// If additional config is provided, append to the default map
func (r *ValkeyClusterReconciler) upsertConfigMap(ctx context.Context, cluster *valkeyiov1alpha1.ValkeyCluster) error {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point

// Calculate hash of new config parameters
newServerConfigHash := fmt.Sprintf("%x", sha256.Sum256([]byte(serverConfig)))

// Was the configMap changed? This is an invalid action, as users should modify
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit hard to follow with a lot of flags (maybe I need more coffee..)
It possibly simpler to just create the configmap at the start of this function, including its annotation, and then return thereafter.
This part would only handle the cases when the configmap already exists in some form.
I think that would remove the need of needCreateConfigMap and origConfigModified

r.Recorder.Eventf(cluster, corev1.EventTypeNormal, "ConfigMapUpdated", "Synchronized server configMap")

// All is good. Server configMap will be auto-mounted in the deployment
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Updating the configmap is one thing, but the Valkey instances will not use these updates anyway in the current form. Is that what you where thinking on @sandeepkunusoth ?
Maybe the update part in this PR could be moved to its own PR, which could include the pod restart/config reload depending on how we decide.

Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
hashConfigContents := sha256.New()

// Embed readiness check script
readiness, err := scripts.ReadFile("scripts/readiness-check.sh")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know if this is nitpicking, but does it make sense to have scripts in a configmap named mycluster-config? That to me indicates that the ConfigMap contains only configurations.

I would argue to keep -config out of the resource name and just keep it to the name of the cluster.

Copy link
Author

Choose a reason for hiding this comment

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

Is your suggestion to move the scripts to their own configMap? I have no objection with that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's fine to leave as is. We can refactor later on

Comment on lines +82 to +99
if len(specConfig) > 0 {

// Sort the config keys to keep consistent processing order
sortedKeys := slices.Sorted(maps.Keys(specConfig))

// Build the config
serverConfig += "\n# Extra config\n"
for _, k := range sortedKeys {

if slices.Contains(valkeyiov1alpha1.NonUserOverrideConfigParameters, k) {
log.Error(nil, "Prohibited valkey server config", "parameter", k)
r.Recorder.Eventf(cluster, nil, corev1.EventTypeWarning, "ConfigMapUpdateFailed", "UpsertConfigMap", "Prohibited config: %v", k)
continue
}

serverConfig += k + " " + specConfig[k] + "\n"
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be extracted into its own function? Something like:

if len(cluster.Spec.ValkeySpec.Configuration) > 0 {
    appendSpecConfig(&serverConfig, cluster.Spec.ValkeySpec.Configuration)
}

Copy link
Author

Choose a reason for hiding this comment

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

I guess it could. What's the benefit though of having the same code but in another function? Doesn't that introduce additional code jumps?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The benefit is readability - ideally we want to keep isolated units of work behind functions that are named well so that when reading the entirety of upsertConfigMap it is easy to follow along and not get bogged down on the low-level implementation of building the extra config :)

r.Recorder.Eventf(cluster, corev1.EventTypeNormal, "ConfigMapUpdated", "Synchronized server configMap")

// All is good. Server configMap will be auto-mounted in the deployment
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree that we should omit live applying changes to the config for another PR

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.

4 participants