Conversation
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>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
|
ugh. why didn't lint/fmt/vet catch those? |
jdheyburn
left a comment
There was a problem hiding this comment.
Minor comments, keen to hear opinions, otherwise LGTM
Signed-off-by: utdrmac <matthew.boehm@percona.com>
Signed-off-by: utdrmac <matthew.boehm@percona.com>
|
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. 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. |
|
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. valkey-operator/test/e2e/e2e_test.go Line 405 in 44d674b |
|
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>
|
@bjosv The test failed on some trivial text matching. I removed it because the two lines above are checking the same string. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
i dont think updated configmap will be auto mounted in the existing deployments during update. Did u test this
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { | ||
|
|
There was a problem hiding this comment.
can we rename this file to configmap.go
| r.Recorder.Eventf(cluster, corev1.EventTypeNormal, "ConfigMapUpdated", "Synchronized server configMap") | ||
|
|
||
| // All is good. Server configMap will be auto-mounted in the deployment | ||
| return nil |
There was a problem hiding this comment.
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 { | ||
|
|
| // 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Is your suggestion to move the scripts to their own configMap? I have no objection with that.
There was a problem hiding this comment.
I think it's fine to leave as is. We can refactor later on
| 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" | ||
| } | ||
| } |
There was a problem hiding this comment.
Could this be extracted into its own function? Something like:
if len(cluster.Spec.ValkeySpec.Configuration) > 0 {
appendSpecConfig(&serverConfig, cluster.Spec.ValkeySpec.Configuration)
}There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Agree that we should omit live applying changes to the config for another PR

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.