Skip to content

Commit

Permalink
update: change API for modelcontroller
Browse files Browse the repository at this point in the history
- fix installedComponent map to not include modelcontroller
- to not add old kserve UID when new kserve CR created(if in any case, kserve CR is deleted but UID remain in modelcontroller)
- ditto to modelmeshserving
- add .status.uri to set exactly which uri is used for devflag if devFlags is set overwrite odh-model-controller
- to explicitly show .spec.kserve.managementstate and .spec.modelmeshserving.managementstate in modelcontroller

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Dec 3, 2024
1 parent 02b95fc commit 225dfe5
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 197 deletions.
19 changes: 17 additions & 2 deletions apis/components/v1/modelcontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-modelcontroller'",message="ModelController name must be default-modelcontroller"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`,description="Ready"
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`,description="Reason"
// +kubebuilder:printcolumn:name="URI",type=string,JSONPath=`.status.URI`,description="devFlag's URI used to download"

// ModelController is the Schema for the modelcontroller API, it is a shared component between kserve and modelmeshserving
type ModelController struct {
Expand All @@ -49,14 +50,28 @@ type ModelController struct {

// ModelControllerSpec defines the desired state of ModelController
type ModelControllerSpec struct {
//ModelMeshServing DSCModelMeshServing `json:"modelMeshServing,omitempty"`
Kserve *ModelControllerKerveSpec `json:"kserve,omitempty"`
ModelMeshServing *ModelControllerMMSpec `json:"modelMeshServing,omitempty"`
}

// a mini version of the DSCKserve only keep devflags and management spec
type ModelControllerKerveSpec struct {
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
common.DevFlagsSpec `json:",inline"`
}

// a mini version of the DSCModelMeshServing only keep devflags and management spec
type ModelControllerMMSpec struct {
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
common.DevFlagsSpec `json:",inline"`
ModelMeshServing operatorv1.ManagementState `json:"modelMeshServing,omitempty"`
Kserve operatorv1.ManagementState `json:"kserve,omitempty"`
}

// ModelControllerStatus defines the observed state of ModelController
type ModelControllerStatus struct {
common.Status `json:",inline"`
// devflag's URI
URI string `json:"URI,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
43 changes: 42 additions & 1 deletion apis/components/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 75 additions & 29 deletions bundle/manifests/components.opendatahub.io_modelcontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ spec:
jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
- description: devFlag's URI used to download
jsonPath: .status.URI
name: URI
type: string
name: v1
schema:
openAPIV3Schema:
Expand All @@ -49,42 +53,84 @@ spec:
spec:
description: ModelControllerSpec defines the desired state of ModelController
properties:
devFlags:
description: Add developer fields
kserve:
description: ModelMeshServing DSCModelMeshServing `json:"modelMeshServing,omitempty"`
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the folder
containing manifests in a repository, default value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any sub-folder
or path: `base`, `overlays/dev`, `default`, `odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with tag/branch.
e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
devFlags:
description: Add developer fields
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the
folder containing manifests in a repository, default
value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any
sub-folder or path: `base`, `overlays/dev`, `default`,
`odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with
tag/branch. e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
type: object
managementState:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
kserve:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
modelMeshServing:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
description: a mini version of the DSCModelMeshServing only keep devflags
and management spec
properties:
devFlags:
description: Add developer fields
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the
folder containing manifests in a repository, default
value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any
sub-folder or path: `base`, `overlays/dev`, `default`,
`odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with
tag/branch. e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
type: object
managementState:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
type: object
status:
description: ModelControllerStatus defines the observed state of ModelController
properties:
URI:
description: devflag's URI
type: string
conditions:
items:
description: Condition contains details for one aspect of the current
Expand Down
104 changes: 75 additions & 29 deletions config/crd/bases/components.opendatahub.io_modelcontrollers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ spec:
jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
- description: devFlag's URI used to download
jsonPath: .status.URI
name: URI
type: string
name: v1
schema:
openAPIV3Schema:
Expand All @@ -49,42 +53,84 @@ spec:
spec:
description: ModelControllerSpec defines the desired state of ModelController
properties:
devFlags:
description: Add developer fields
kserve:
description: ModelMeshServing DSCModelMeshServing `json:"modelMeshServing,omitempty"`
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the folder
containing manifests in a repository, default value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any sub-folder
or path: `base`, `overlays/dev`, `default`, `odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with tag/branch.
e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
devFlags:
description: Add developer fields
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the
folder containing manifests in a repository, default
value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any
sub-folder or path: `base`, `overlays/dev`, `default`,
`odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with
tag/branch. e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
type: object
managementState:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
kserve:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
modelMeshServing:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
description: a mini version of the DSCModelMeshServing only keep devflags
and management spec
properties:
devFlags:
description: Add developer fields
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the
folder containing manifests in a repository, default
value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any
sub-folder or path: `base`, `overlays/dev`, `default`,
`odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with
tag/branch. e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
type: object
managementState:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
type: object
status:
description: ModelControllerStatus defines the observed state of ModelController
properties:
URI:
description: devflag's URI
type: string
conditions:
items:
description: Condition contains details for one aspect of the current
Expand Down
12 changes: 7 additions & 5 deletions controllers/components/kserve/kserve_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,16 @@ func patchOwnerReference(ctx context.Context, rr *odhtypes.ReconciliationRequest
}
return odherrors.NewStopError("failed to get ModelController CR: %v", err)
}
for _, owners := range mc.GetOwnerReferences() {
if owners.UID == k.GetUID() {

owners := []metav1.OwnerReference{}
for _, o := range mc.GetOwnerReferences() {
if o.UID == k.GetUID() {
return nil // kserve already as owner to modelcontroller, early exit
}
if o.Kind != componentsv1.KserveKind { // TODO: a workaround to ensure no old UID exist, this should be moved into finalizer later
owners = append(owners, o)
}
}

owners := []metav1.OwnerReference{}
owners = append(owners, mc.GetOwnerReferences()...) // keep the existing ones
owners = append(owners, metav1.OwnerReference{
Kind: componentsv1.KserveKind,
APIVersion: componentsv1.GroupVersion.String(),
Expand Down
Loading

0 comments on commit 225dfe5

Please sign in to comment.