-
Notifications
You must be signed in to change notification settings - Fork 42
feat(controller): watch run.yaml configmap for updates #68
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
Conversation
|
Some additional information: A minimal example of an ollama run.yaml config is provided for demonstration purposes. Parameters for the example's ollama deployment match those of the current README.md file. If a ConfigMap is specified in the Otherwise, if the |
|
I'm also open to changing things like:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid, thanks!
| Watches( | ||
| &corev1.ConfigMap{}, | ||
| handler.EnqueueRequestsFromMapFunc(r.findLlamaStackDistributionsForConfigMap), | ||
| builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}), | ||
| ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can include another predicate to diff the content of the cm on updates using a predicate.Funcs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That approach sounds good, I've now updated the code to only reconcile on changes to the ConfigMap's Data field, and creation/deletion events.
|
|
||
| // findLlamaStackDistributionsForConfigMap maps ConfigMap changes to LlamaStackDistribution reconcile requests. | ||
| func (r *LlamaStackDistributionReconciler) findLlamaStackDistributionsForConfigMap(ctx context.Context, configMap client.Object) []reconcile.Request { | ||
| attachedLlamaStacks := &llamav1alpha1.LlamaStackDistributionList{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No immediate action, can be done in a followup, up to you. Can you use a Field Indexer with a FieldSelector in the List calls? This will drastically improve performance on a large number of CM which is not uncommon on a cluster.
Something like:
r.List(ctx, &matchedDistributions, &client.ListOptions{
FieldSelector: client.MatchingFields{
".spec.server.userConfig.configMapKey": key,
},
})but you need to setup an indexer first in the manager, see: https://book.kubebuilder.io/cronjob-tutorial/controller-implementation#setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started implementing this approach, but hit some errors around failing to list when using the field selector. I'll look into it more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking again into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the cause of the errors that I saw, it was due to missing selectablefield kubebuilder markers. I've made the necessary updates and will work on getting those changes included in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to include these changes into this PR.
|
This pull request has merge conflicts that must be resolved before it can be merged. @rhdedgar please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
0a9654e to
5f40a92
Compare
|
/hold |
|
I'll hold this until more testing can be done after the rebase (merge conflict). |
|
|
||
| // findLlamaStackDistributionsForConfigMap maps ConfigMap changes to LlamaStackDistribution reconcile requests. | ||
| func (r *LlamaStackDistributionReconciler) findLlamaStackDistributionsForConfigMap(ctx context.Context, configMap client.Object) []reconcile.Request { | ||
| attachedLlamaStacks := &llamav1alpha1.LlamaStackDistributionList{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking again into this.
Added do-not-merge label instead. We don't have support for those commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change @rhdedgar !
I think it would also be helpful to extend readme to include this feature - Deployment of Llama Stack Server
| func (r *LlamaStackDistributionReconciler) reconcileUserConfigMap(ctx context.Context, instance *llamav1alpha1.LlamaStackDistribution) error { | ||
| logger := log.FromContext(ctx) | ||
|
|
||
| if instance.Spec.Server.UserConfig == nil || instance.Spec.Server.UserConfig.ConfigMapName == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check seems redundant with the one in Reconcile()
|
|
||
| // getConfigMapHash calculates a hash of the ConfigMap data to detect changes. | ||
| func (r *LlamaStackDistributionReconciler) getConfigMapHash(ctx context.Context, instance *llamav1alpha1.LlamaStackDistribution) (string, error) { | ||
| if instance.Spec.Server.UserConfig == nil || instance.Spec.Server.UserConfig.ConfigMapName == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, check seems redundant with one in reconcile()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Upon further review, I've removed some duplicate checks like these, and added helper functions for the reusable checks to improve readability. Things like SetupWithManager will look a bit more clear now.
5f40a92 to
0ef764b
Compare
|
I've updated this branch with my current working state (fieldSelector PoC). I'll get some additional changes made tomorrow. I'll also look to address the most recent comments, and get code to address the feedback included in this PR. |
0ef764b to
20c573e
Compare
Signed-off-by: Doug Edgar <dedgar@redhat.com>
d7d2d88 to
0c80a32
Compare
Signed-off-by: Doug Edgar <dedgar@redhat.com>
0c80a32 to
fda5b86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid! Thanks!
| } | ||
|
|
||
| // Only trigger if Data or BinaryData has changed | ||
| dataChanged := !cmp.Equal(oldConfigMap.Data, newConfigMap.Data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we print the diff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do! I've added diff printing for ConfigMap Data when changes are detected.
Example:
2025-06-27T21:38:09Z INFO Referenced ConfigMap change detected {"configMapName": "llama-stack-config", "configMapNamespace": "new-llama"}
2025-06-27T21:38:09Z INFO ConfigMap Data changed {"configMapName": "llama-stack-config", "configMapNamespace": "new-llama"}
ConfigMap new-llama/llama-stack-config Data diff:
map[string]string{
"run.yaml": (
"""
... // 3 identical lines
apis:
- inference
+ - scoring
providers:
inference:
... // 11 identical lines
"""
),
}
|
I see following errors even before creating |
…g configmap sample Signed-off-by: Doug Edgar <dedgar@redhat.com>
|
@VaishnaviHire's recent comment (I don't see it at the moment) helped me find that I had omitted a check for only ConfigMaps referenced by existing LlamaStackDistributions. I had originally tried to keep the log output as low as possible to maintain readability, and as a result, I was missing out on some efficiency opportunities to that would have been apparent from more verbose logging. I'll lean towards this approach more in the future. |
Updates the operator's controller to watch for the changes to the ConfigMap specified in the LlamaStackDistribution CR. Closes: llamastack#12 --------- Signed-off-by: Doug Edgar <dedgar@redhat.com> (cherry picked from commit 1d09c42)
Updates the operator's controller to watch for the changes to the ConfigMap specified in the LlamaStackDistribution CR. Closes: llamastack#12 --------- Signed-off-by: Doug Edgar <dedgar@redhat.com> (cherry picked from commit 1d09c42)
Signed-off-by: konflux-internal-p02 <170854209+konflux-internal-p02[bot]@users.noreply.github.com> Co-authored-by: konflux-internal-p02[bot] <170854209+konflux-internal-p02[bot]@users.noreply.github.com>
Updates the operator's controller to watch for the changes to the ConfigMap specified in the LlamaStackDistribution CR.
Closes: #12