feat: add ownedBy and createdAt for OpenModel#438
Conversation
|
will test locally soon |
cc8eca3 to
55df089
Compare
root@VM-0-3-ubuntu:/home/ubuntu/llmaz/docs/examples/ollama# kubectl get openmodel -oyaml
apiVersion: v1
items:
- apiVersion: llmaz.io/v1alpha1
kind: OpenModel
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"llmaz.io/v1alpha1","kind":"OpenModel","metadata":{"annotations":{},"name":"qwen2-0--5b"},"spec":{"familyName":"qwen2","source":{"uri":"ollama://qwen2:0.5b"}}}
creationTimestamp: "2025-06-03T13:30:42Z"
generation: 2
labels:
llmaz.io/model-family-name: qwen2
name: qwen2-0--5b
resourceVersion: "3586"
uid: 9df4445e-fbbb-4083-b3ff-4591dfc1f95e
spec:
createdAt: "2025-06-03T13:30:42Z"
familyName: qwen2
ownedBy: llmaz
source:
uri: ollama://qwen2:0.5b
kind: List
metadata:
resourceVersion: ""
root@VM-0-3-ubuntu:/home/ubuntu/llmaz/docs/examples/ollama# |
|
/kind feature |
| } | ||
|
|
||
| // needsUpdated checks if the model needs to be updated. | ||
| func needsUpdated(model *coreapi.OpenModel) (bool, *coreapi.OpenModel) { |
There was a problem hiding this comment.
Move them to the webhooks which I believe is the right place. And I think we don't need to set the OwnedBy since we have kubebuilder tag.
There was a problem hiding this comment.
sgtm. I forget that we have OpenModelWebhook... I will change this part
There was a problem hiding this comment.
Back to this again, if I understand correctly, when we put it in the webhook, it seems that model.CreationTimestamp is still empty when we create it. @kerthcet
🤔
func (w *OpenModelWebhook) Default(ctx context.Context, obj runtime.Object) error {
model := obj.(*coreapi.OpenModel)
if model.Labels == nil {
model.Labels = map[string]string{}
}
model.Labels[coreapi.ModelFamilyNameLabelKey] = string(model.Spec.FamilyName)
if model.Spec.CreatedAt == nil {
model.Spec.CreatedAt = &model.CreationTimestamp
}
return nil
}There was a problem hiding this comment.
Yes, we should set it automatically.
55df089 to
dcbc1e8
Compare
4282a0e to
779b7c2
Compare
| model.Labels = map[string]string{} | ||
| } | ||
| model.Labels[coreapi.ModelFamilyNameLabelKey] = string(model.Spec.FamilyName) | ||
| if model.Spec.CreatedAt == nil { |
There was a problem hiding this comment.
change to: in webhook , if it is not filled, just set time.Now().
779b7c2 to
0915166
Compare
| gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) | ||
| gomega.Expect(model).To(gomega.BeComparableTo(tc.wantModel(), | ||
| cmpopts.IgnoreTypes(coreapi.ModelStatus{}), | ||
| cmpopts.IgnoreFields(coreapi.ModelSpec{}, "CreatedAt"), |
There was a problem hiding this comment.
Regarding the time field, in order to avoid fake tests, we should avoid checking
| model.Labels[coreapi.ModelFamilyNameLabelKey] = string(model.Spec.FamilyName) | ||
| if model.Spec.CreatedAt == nil { | ||
| now := metav1.Now().Rfc3339Copy() | ||
| model.Spec.CreatedAt = &now |
There was a problem hiding this comment.
chango to:
createdAt := ptr.Deref[metav1.Time](model.Spec.CreatedAt, metav1.Now().Rfc3339Copy())
model.Spec.CreatedAt = &createdAt0915166 to
dfb491f
Compare
Signed-off-by: googs1025 <googs1025@gmail.com>
dfb491f to
1190bad
Compare
|
/approve |
What this PR does / why we need it
Which issue(s) this PR fixes
Fixes #435
Special notes for your reviewer
Does this PR introduce a user-facing change?