diff --git a/api/tas/v1alpha1/conversion.go b/api/tas/v1alpha1/conversion.go deleted file mode 100644 index 521281038..000000000 --- a/api/tas/v1alpha1/conversion.go +++ /dev/null @@ -1,84 +0,0 @@ -package v1alpha1 - -import ( - v1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts the v1alpha1 TrustyAIService to v1 TrustyAIService -func (src *TrustyAIService) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v1.TrustyAIService) - - // Convert ObjectMeta - dst.ObjectMeta = src.ObjectMeta - dst.TypeMeta = src.TypeMeta - - // Convert Spec - dst.Spec.Replicas = src.Spec.Replicas - dst.Spec.Storage.Format = src.Spec.Storage.Format - dst.Spec.Storage.Folder = src.Spec.Storage.Folder - dst.Spec.Storage.Size = src.Spec.Storage.Size - dst.Spec.Storage.DatabaseConfigurations = src.Spec.Storage.DatabaseConfigurations - dst.Spec.Data.Filename = src.Spec.Data.Filename - dst.Spec.Data.Format = src.Spec.Data.Format - dst.Spec.Metrics.Schedule = src.Spec.Metrics.Schedule - dst.Spec.Metrics.BatchSize = src.Spec.Metrics.BatchSize - - // Convert Status - dst.Status.Phase = src.Status.Phase - dst.Status.Replicas = src.Status.Replicas - dst.Status.Ready = src.Status.Ready - - // Convert Conditions - dst.Status.Conditions = make([]v1.Condition, len(src.Status.Conditions)) - for i, srcCondition := range src.Status.Conditions { - dst.Status.Conditions[i] = v1.Condition{ - Type: srcCondition.Type, - Status: srcCondition.Status, - LastTransitionTime: srcCondition.LastTransitionTime, - Reason: srcCondition.Reason, - Message: srcCondition.Message, - } - } - - return nil -} - -// ConvertFrom converts the v1 TrustyAIService (Hub version) to v1alpha1 TrustyAIService -func (dst *TrustyAIService) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v1.TrustyAIService) - - // Convert ObjectMeta - dst.ObjectMeta = src.ObjectMeta - dst.TypeMeta = src.TypeMeta - - // Convert Spec - dst.Spec.Replicas = src.Spec.Replicas - dst.Spec.Storage.Format = src.Spec.Storage.Format - dst.Spec.Storage.Folder = src.Spec.Storage.Folder - dst.Spec.Storage.Size = src.Spec.Storage.Size - dst.Spec.Storage.DatabaseConfigurations = src.Spec.Storage.DatabaseConfigurations - dst.Spec.Data.Filename = src.Spec.Data.Filename - dst.Spec.Data.Format = src.Spec.Data.Format - dst.Spec.Metrics.Schedule = src.Spec.Metrics.Schedule - dst.Spec.Metrics.BatchSize = src.Spec.Metrics.BatchSize - - // Convert Status - dst.Status.Phase = src.Status.Phase - dst.Status.Replicas = src.Status.Replicas - dst.Status.Ready = src.Status.Ready - - // Convert Conditions - dst.Status.Conditions = make([]Condition, len(src.Status.Conditions)) - for i, srcCondition := range src.Status.Conditions { - dst.Status.Conditions[i] = Condition{ - Type: srcCondition.Type, - Status: srcCondition.Status, - LastTransitionTime: srcCondition.LastTransitionTime, - Reason: srcCondition.Reason, - Message: srcCondition.Message, - } - } - - return nil -} diff --git a/api/tas/v1alpha1/groupversion_info.go b/api/tas/v1alpha1/groupversion_info.go deleted file mode 100644 index b557566cc..000000000 --- a/api/tas/v1alpha1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1alpha1 contains API Schema definitions for the trustyai.opendatahub.io v1alpha1 API group -// +kubebuilder:object:generate=true -// +groupName=trustyai.opendatahub.io -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "trustyai.opendatahub.io", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/api/tas/v1alpha1/trustyaiservice_types.go b/api/tas/v1alpha1/trustyaiservice_types.go deleted file mode 100644 index d76d684d6..000000000 --- a/api/tas/v1alpha1/trustyaiservice_types.go +++ /dev/null @@ -1,141 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// TrustyAIService is the Schema for the trustyaiservices API -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -type TrustyAIService struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec TrustyAIServiceSpec `json:"spec,omitempty"` - Status TrustyAIServiceStatus `json:"status,omitempty"` -} - -type StorageSpec struct { - // Format only supports "PVC" or "DATABASE" values - // +kubebuilder:validation:Enum=PVC;DATABASE - Format string `json:"format"` - Folder string `json:"folder,omitempty"` - Size string `json:"size,omitempty"` - DatabaseConfigurations string `json:"databaseConfigurations,omitempty"` -} - -type DataSpec struct { - Filename string `json:"filename,omitempty"` - Format string `json:"format,omitempty"` -} - -type MetricsSpec struct { - Schedule string `json:"schedule"` - BatchSize *int `json:"batchSize,omitempty"` -} - -// TrustyAIServiceSpec defines the desired state of TrustyAIService -type TrustyAIServiceSpec struct { - // Number of replicas - // +optional - Replicas *int32 `json:"replicas"` - Storage StorageSpec `json:"storage"` - Data DataSpec `json:"data,omitempty"` - Metrics MetricsSpec `json:"metrics"` -} - -// TrustyAIServiceStatus defines the observed state of TrustyAIService -type TrustyAIServiceStatus struct { - // Define your status fields here - Phase string `json:"phase"` - Replicas int32 `json:"replicas"` - Conditions []Condition `json:"conditions"` - Ready corev1.ConditionStatus `json:"ready,omitempty"` -} - -// Condition represents possible conditions of a TrustyAIServiceStatus -type Condition struct { - Type string `json:"type"` - Status corev1.ConditionStatus `json:"status"` - LastTransitionTime metav1.Time `json:"lastTransitionTime"` - Reason string `json:"reason"` - Message string `json:"message"` -} - -//+kubebuilder:object:root=true - -// TrustyAIServiceList contains a list of TrustyAIService -type TrustyAIServiceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []TrustyAIService `json:"items"` -} - -func init() { - SchemeBuilder.Register(&TrustyAIService{}, &TrustyAIServiceList{}) -} - -// IsDatabaseConfigurationsSet returns true if the DatabaseConfigurations field is set. -func (s *StorageSpec) IsDatabaseConfigurationsSet() bool { - return s.DatabaseConfigurations != "" -} - -// IsStoragePVC returns true if the storage is set to PVC. -func (s *StorageSpec) IsStoragePVC() bool { - return s.Format == "PVC" -} - -// IsStorageDatabase returns true if the storage is set to database. -func (s *StorageSpec) IsStorageDatabase() bool { - return s.Format == "DATABASE" -} - -// IsMigration returns true if the migration fields are set. -func (t *TrustyAIService) IsMigration() bool { - if t.Spec.Storage.Format == "DATABASE" && t.Spec.Storage.Folder != "" && t.Spec.Data.Filename != "" { - return true - } else { - return false - } -} - -// SetStatus sets the status of the TrustyAIService -func (t *TrustyAIService) SetStatus(condType, reason, message string, status corev1.ConditionStatus) { - now := metav1.Now() - condition := Condition{ - Type: condType, - Status: status, - Reason: reason, - Message: message, - LastTransitionTime: now, - } - // Replace or append condition - found := false - for i, cond := range t.Status.Conditions { - if cond.Type == condType { - t.Status.Conditions[i] = condition - found = true - break - } - } - if !found { - t.Status.Conditions = append(t.Status.Conditions, condition) - } -} diff --git a/api/tas/v1alpha1/zz_generated.deepcopy.go b/api/tas/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 2c7b65d0a..000000000 --- a/api/tas/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,195 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Condition) DeepCopyInto(out *Condition) { - *out = *in - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. -func (in *Condition) DeepCopy() *Condition { - if in == nil { - return nil - } - out := new(Condition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DataSpec) DeepCopyInto(out *DataSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataSpec. -func (in *DataSpec) DeepCopy() *DataSpec { - if in == nil { - return nil - } - out := new(DataSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MetricsSpec) DeepCopyInto(out *MetricsSpec) { - *out = *in - if in.BatchSize != nil { - in, out := &in.BatchSize, &out.BatchSize - *out = new(int) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsSpec. -func (in *MetricsSpec) DeepCopy() *MetricsSpec { - if in == nil { - return nil - } - out := new(MetricsSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StorageSpec) DeepCopyInto(out *StorageSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageSpec. -func (in *StorageSpec) DeepCopy() *StorageSpec { - if in == nil { - return nil - } - out := new(StorageSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TrustyAIService) DeepCopyInto(out *TrustyAIService) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrustyAIService. -func (in *TrustyAIService) DeepCopy() *TrustyAIService { - if in == nil { - return nil - } - out := new(TrustyAIService) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TrustyAIService) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TrustyAIServiceList) DeepCopyInto(out *TrustyAIServiceList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]TrustyAIService, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrustyAIServiceList. -func (in *TrustyAIServiceList) DeepCopy() *TrustyAIServiceList { - if in == nil { - return nil - } - out := new(TrustyAIServiceList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TrustyAIServiceList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TrustyAIServiceSpec) DeepCopyInto(out *TrustyAIServiceSpec) { - *out = *in - if in.Replicas != nil { - in, out := &in.Replicas, &out.Replicas - *out = new(int32) - **out = **in - } - out.Storage = in.Storage - out.Data = in.Data - in.Metrics.DeepCopyInto(&out.Metrics) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrustyAIServiceSpec. -func (in *TrustyAIServiceSpec) DeepCopy() *TrustyAIServiceSpec { - if in == nil { - return nil - } - out := new(TrustyAIServiceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TrustyAIServiceStatus) DeepCopyInto(out *TrustyAIServiceStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrustyAIServiceStatus. -func (in *TrustyAIServiceStatus) DeepCopy() *TrustyAIServiceStatus { - if in == nil { - return nil - } - out := new(TrustyAIServiceStatus) - in.DeepCopyInto(out) - return out -} diff --git a/artifacts/examples/example-trustyai.yaml b/artifacts/examples/example-trustyai.yaml index 3486ab94e..8ed1a4a64 100644 --- a/artifacts/examples/example-trustyai.yaml +++ b/artifacts/examples/example-trustyai.yaml @@ -1,4 +1,4 @@ -apiVersion: trustyai.opendatahub.io/v1alpha1 +apiVersion: trustyai.opendatahub.io/v1 kind: TrustyAIService metadata: name: example-trustyai-service diff --git a/cmd/main.go b/cmd/main.go index c637abc29..8e4e528bf 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -42,7 +42,6 @@ import ( gorchv1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/gorch/v1alpha1" lmesv1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/lmes/v1alpha1" tasv1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" - tasv1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" "github.com/trustyai-explainability/trustyai-service-operator/controllers" "github.com/trustyai-explainability/trustyai-service-operator/controllers/constants" "github.com/trustyai-explainability/trustyai-service-operator/controllers/utils" @@ -57,7 +56,6 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(tasv1alpha1.AddToScheme(scheme)) utilruntime.Must(tasv1.AddToScheme(scheme)) utilruntime.Must(lmesv1alpha1.AddToScheme(scheme)) utilruntime.Must(monitoringv1.AddToScheme(scheme)) diff --git a/config/crd/bases/trustyai.opendatahub.io_trustyaiservices.yaml b/config/crd/bases/trustyai.opendatahub.io_trustyaiservices.yaml index 5d10a0e91..fdcbbf26a 100644 --- a/config/crd/bases/trustyai.opendatahub.io_trustyaiservices.yaml +++ b/config/crd/bases/trustyai.opendatahub.io_trustyaiservices.yaml @@ -124,113 +124,3 @@ spec: storage: true subresources: status: {} - - name: v1alpha1 - schema: - openAPIV3Schema: - description: TrustyAIService is the Schema for the trustyaiservices API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: TrustyAIServiceSpec defines the desired state of TrustyAIService - properties: - data: - properties: - filename: - type: string - format: - type: string - type: object - metrics: - properties: - batchSize: - type: integer - schedule: - type: string - required: - - schedule - type: object - replicas: - description: Number of replicas - format: int32 - type: integer - storage: - properties: - databaseConfigurations: - type: string - folder: - type: string - format: - description: Format only supports "PVC" or "DATABASE" values - enum: - - PVC - - DATABASE - type: string - size: - type: string - required: - - format - type: object - required: - - metrics - - storage - type: object - status: - description: TrustyAIServiceStatus defines the observed state of TrustyAIService - properties: - conditions: - items: - description: Condition represents possible conditions of a TrustyAIServiceStatus - properties: - lastTransitionTime: - format: date-time - type: string - message: - type: string - reason: - type: string - status: - type: string - type: - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - phase: - description: Define your status fields here - type: string - ready: - type: string - replicas: - format: int32 - type: integer - required: - - conditions - - phase - - replicas - type: object - type: object - served: true - storage: false - subresources: - status: {} diff --git a/controllers/tas/certificates.go b/controllers/tas/certificates.go index 54e1e1aef..05f6d0817 100644 --- a/controllers/tas/certificates.go +++ b/controllers/tas/certificates.go @@ -3,7 +3,7 @@ package tas import ( "context" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" @@ -20,7 +20,7 @@ type TLSCertVolumes struct { } // createFor creates the required volumes and volume mount for the TLS certificates for a specific Kubernetes secret -func (cert *TLSCertVolumes) createFor(instance *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func (cert *TLSCertVolumes) createFor(instance *trustyaiopendatahubiov1.TrustyAIService) { volume := corev1.Volume{ Name: instance.Name + "-internal", VolumeSource: corev1.VolumeSource{ @@ -39,7 +39,7 @@ func (cert *TLSCertVolumes) createFor(instance *trustyaiopendatahubiov1alpha1.Tr cert.volumeMount = volumeMount } -func (r *TrustyAIServiceReconciler) GetCustomCertificatesBundle(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) CustomCertificatesBundle { +func (r *TrustyAIServiceReconciler) GetCustomCertificatesBundle(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) CustomCertificatesBundle { var customCertificatesBundle CustomCertificatesBundle // Check for custom certificate bundle config map presence diff --git a/controllers/tas/database.go b/controllers/tas/database.go index 014b55d94..b6e4a75c8 100644 --- a/controllers/tas/database.go +++ b/controllers/tas/database.go @@ -4,7 +4,7 @@ import ( "context" "strings" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -12,7 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -func (r *TrustyAIServiceReconciler) checkDatabaseAccessible(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (bool, error) { +func (r *TrustyAIServiceReconciler) checkDatabaseAccessible(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) (bool, error) { deployment := &appsv1.Deployment{} err := r.Get(ctx, types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace}, deployment) if err != nil { diff --git a/controllers/tas/deployment.go b/controllers/tas/deployment.go index 4d95740ea..3be60ab32 100644 --- a/controllers/tas/deployment.go +++ b/controllers/tas/deployment.go @@ -5,7 +5,7 @@ import ( "reflect" "strconv" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/constants" templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/tas/templates" appsv1 "k8s.io/api/apps/v1" @@ -31,7 +31,7 @@ type CustomCertificatesBundle struct { } type DeploymentConfig struct { - Instance *trustyaiopendatahubiov1alpha1.TrustyAIService + Instance *trustyaiopendatahubiov1.TrustyAIService ServiceImage string OAuthImage string Schedule string @@ -44,7 +44,7 @@ type DeploymentConfig struct { } // createDeploymentObject returns a Deployment for the TrustyAI Service instance -func (r *TrustyAIServiceReconciler) createDeploymentObject(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, serviceImage string, caBunble CustomCertificatesBundle) (*appsv1.Deployment, error) { +func (r *TrustyAIServiceReconciler) createDeploymentObject(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, serviceImage string, caBunble CustomCertificatesBundle) (*appsv1.Deployment, error) { var batchSize int // If no batch size is provided, assume the default one @@ -98,7 +98,7 @@ func (r *TrustyAIServiceReconciler) createDeploymentObject(ctx context.Context, } // reconcileDeployment returns a Deployment object with the same name/namespace as the cr -func (r *TrustyAIServiceReconciler) createDeployment(ctx context.Context, cr *trustyaiopendatahubiov1alpha1.TrustyAIService, imageName string, caBundle CustomCertificatesBundle) error { +func (r *TrustyAIServiceReconciler) createDeployment(ctx context.Context, cr *trustyaiopendatahubiov1.TrustyAIService, imageName string, caBundle CustomCertificatesBundle) error { if !cr.Spec.Storage.IsDatabaseConfigurationsSet() { @@ -135,7 +135,7 @@ func (r *TrustyAIServiceReconciler) createDeployment(ctx context.Context, cr *tr } // updateDeployment returns a Deployment object with the same name/namespace as the cr -func (r *TrustyAIServiceReconciler) updateDeployment(ctx context.Context, cr *trustyaiopendatahubiov1alpha1.TrustyAIService, imageName string, caBundle CustomCertificatesBundle) error { +func (r *TrustyAIServiceReconciler) updateDeployment(ctx context.Context, cr *trustyaiopendatahubiov1.TrustyAIService, imageName string, caBundle CustomCertificatesBundle) error { if !cr.Spec.Storage.IsDatabaseConfigurationsSet() { @@ -171,7 +171,7 @@ func (r *TrustyAIServiceReconciler) updateDeployment(ctx context.Context, cr *tr } -func (r *TrustyAIServiceReconciler) ensureDeployment(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, caBundle CustomCertificatesBundle, migration bool) error { +func (r *TrustyAIServiceReconciler) ensureDeployment(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, caBundle CustomCertificatesBundle, migration bool) error { // Get image and tag from ConfigMap // If there's a ConfigMap with custom images, it is only applied when the operator is first deployed @@ -204,7 +204,7 @@ func (r *TrustyAIServiceReconciler) ensureDeployment(ctx context.Context, instan } // checkDeploymentReady verifies that a TrustyAI service deployment is ready -func (r *TrustyAIServiceReconciler) checkDeploymentReady(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (bool, error) { +func (r *TrustyAIServiceReconciler) checkDeploymentReady(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) (bool, error) { deployment := &appsv1.Deployment{} err := r.Get(ctx, types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace}, deployment) diff --git a/controllers/tas/deployment_test.go b/controllers/tas/deployment_test.go index 323adf5de..cfeddc9e4 100644 --- a/controllers/tas/deployment_test.go +++ b/controllers/tas/deployment_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/constants" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -28,7 +28,7 @@ func printKubeObject(obj interface{}) { } } -func setupAndTestDeploymentDefault(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string) { +func setupAndTestDeploymentDefault(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string) { Expect(createNamespace(ctx, k8sClient, namespace)).To(Succeed()) caBundle := reconciler.GetCustomCertificatesBundle(ctx, instance) @@ -92,7 +92,7 @@ func setupAndTestDeploymentDefault(instance *trustyaiopendatahubiov1alpha1.Trust } -func setupAndTestDeploymentConfigMap(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string) { +func setupAndTestDeploymentConfigMap(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string) { serviceImage := "custom-service-image:foo" oauthImage := "custom-oauth-proxy:bar" Expect(createNamespace(ctx, k8sClient, namespace)).To(Succeed()) @@ -167,7 +167,7 @@ func setupAndTestDeploymentConfigMap(instance *trustyaiopendatahubiov1alpha1.Tru } -func setupAndTestDeploymentNoCustomCABundle(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string) { +func setupAndTestDeploymentNoCustomCABundle(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string) { Expect(createNamespace(ctx, k8sClient, namespace)).To(Succeed()) caBundle := reconciler.GetCustomCertificatesBundle(ctx, instance) @@ -200,7 +200,7 @@ func setupAndTestDeploymentNoCustomCABundle(instance *trustyaiopendatahubiov1alp } -func setupAndTestDeploymentCustomCABundle(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string) { +func setupAndTestDeploymentCustomCABundle(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string) { caBundleConfigMap := createTrustedCABundleConfigMap(namespace) Expect(createNamespace(ctx, k8sClient, namespace)).To(Succeed()) Expect(k8sClient.Create(ctx, caBundleConfigMap)).To(Succeed()) @@ -235,7 +235,7 @@ func setupAndTestDeploymentCustomCABundle(instance *trustyaiopendatahubiov1alpha } -func setupAndTestDeploymentServiceAccount(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string, mode string) { +func setupAndTestDeploymentServiceAccount(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string, mode string) { Expect(createNamespace(ctx, k8sClient, namespace)).To(Succeed()) caBundle := reconciler.GetCustomCertificatesBundle(ctx, instance) @@ -255,7 +255,7 @@ func setupAndTestDeploymentServiceAccount(instance *trustyaiopendatahubiov1alpha Expect(deployment.Spec.Template.Spec.ServiceAccountName).To(Equal(instance.Name + "-proxy")) } -func setupAndTestDeploymentInferenceService(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string, mode string) { +func setupAndTestDeploymentInferenceService(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string, mode string) { WaitFor(func() error { return createNamespace(ctx, k8sClient, namespace) }, "failed to create namespace") @@ -350,7 +350,7 @@ var _ = Describe("TrustyAI operator", func() { }) Context("When deploying with default settings without an InferenceService", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Creates a deployment and a service with the default configuration in PVC-mode", func() { namespace := "trusty-ns-a-1-pvc" instance = createDefaultPVCCustomResource(namespace) @@ -378,7 +378,7 @@ var _ = Describe("TrustyAI operator", func() { }) Context("When deploying with a ConfigMap and without an InferenceService", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Creates a deployment and a service with the ConfigMap configuration in PVC-mode", func() { namespace := "trusty-ns-a-1-cm-pvc" @@ -394,7 +394,7 @@ var _ = Describe("TrustyAI operator", func() { }) Context("When deploying with default settings without an InferenceService", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("should set environment variables correctly in PVC mode", func() { @@ -719,7 +719,7 @@ var _ = Describe("TrustyAI operator", func() { }) Context("When deploying with no custom CA bundle ConfigMap", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("should use the correct service account and not include CustomCertificatesBundle in PVC-mode", func() { @@ -743,7 +743,7 @@ var _ = Describe("TrustyAI operator", func() { }) Context("When deploying with a custom CA bundle ConfigMap", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("should use the correct service account and include CustomCertificatesBundle in PVC-mode", func() { @@ -766,7 +766,7 @@ var _ = Describe("TrustyAI operator", func() { }) Context("When deploying with default settings without an InferenceService", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("should use the correct service account in PVC-mode", func() { @@ -847,11 +847,11 @@ var _ = Describe("TrustyAI operator", func() { }) Context("Across multiple namespaces", func() { - var instances []*trustyaiopendatahubiov1alpha1.TrustyAIService + var instances []*trustyaiopendatahubiov1.TrustyAIService var namespaces = []string{"namespace1", "namespace2", "namespace3"} - instances = make([]*trustyaiopendatahubiov1alpha1.TrustyAIService, len(namespaces)) + instances = make([]*trustyaiopendatahubiov1.TrustyAIService, len(namespaces)) It("Deploys services with defaults in each specified namespace", func() { for i, namespace := range namespaces { diff --git a/controllers/tas/destination_rule.go b/controllers/tas/destination_rule.go index caf323363..72be5bb55 100644 --- a/controllers/tas/destination_rule.go +++ b/controllers/tas/destination_rule.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/tas/templates" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -44,7 +44,7 @@ func (r *TrustyAIServiceReconciler) isDestinationRuleCRDPresent(ctx context.Cont return true, nil } -func (r *TrustyAIServiceReconciler) ensureDestinationRule(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func (r *TrustyAIServiceReconciler) ensureDestinationRule(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) error { destinationRuleName := instance.Name + "-internal" diff --git a/controllers/tas/events.go b/controllers/tas/events.go index 4288a9571..4379c0a83 100644 --- a/controllers/tas/events.go +++ b/controllers/tas/events.go @@ -1,22 +1,22 @@ package tas import ( - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" corev1 "k8s.io/api/core/v1" ) -func (r *TrustyAIServiceReconciler) eventModelMeshConfigured(instance *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func (r *TrustyAIServiceReconciler) eventModelMeshConfigured(instance *trustyaiopendatahubiov1.TrustyAIService) { r.EventRecorder.Event(instance, corev1.EventTypeNormal, EventReasonInferenceServiceConfigured, "ModelMesh InferenceService configured") } -func (r *TrustyAIServiceReconciler) eventKServeConfigured(instance *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func (r *TrustyAIServiceReconciler) eventKServeConfigured(instance *trustyaiopendatahubiov1.TrustyAIService) { r.EventRecorder.Event(instance, corev1.EventTypeNormal, EventReasonInferenceServiceConfigured, "KServe InferenceService configured") } -func (r *TrustyAIServiceReconciler) eventPVCCreated(instance *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func (r *TrustyAIServiceReconciler) eventPVCCreated(instance *trustyaiopendatahubiov1.TrustyAIService) { r.EventRecorder.Event(instance, corev1.EventTypeNormal, EventReasonPVCCreated, "PVC created") } -func (r *TrustyAIServiceReconciler) eventLocalServiceMonitorCreated(instance *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func (r *TrustyAIServiceReconciler) eventLocalServiceMonitorCreated(instance *trustyaiopendatahubiov1.TrustyAIService) { r.EventRecorder.Event(instance, corev1.EventTypeNormal, EventReasonServiceMonitorCreated, "Local ServiceMonitor created") } diff --git a/controllers/tas/finalizers.go b/controllers/tas/finalizers.go index 283e47383..bfb1075ba 100644 --- a/controllers/tas/finalizers.go +++ b/controllers/tas/finalizers.go @@ -3,12 +3,12 @@ package tas import ( "context" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "sigs.k8s.io/controller-runtime/pkg/log" ) // deleteExternalDependency removes the payload processor from the ModelMesh deployment -func (r *TrustyAIServiceReconciler) deleteExternalDependency(crName string, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string, ctx context.Context) error { +func (r *TrustyAIServiceReconciler) deleteExternalDependency(crName string, instance *trustyaiopendatahubiov1.TrustyAIService, namespace string, ctx context.Context) error { log.FromContext(ctx).Info("Deleting external dependencies") // Call handleInferenceServices with remove set to true _, err := r.handleInferenceServices(ctx, instance, namespace, modelMeshLabelKey, modelMeshLabelValue, payloadProcessorName, instance.Name, true) diff --git a/controllers/tas/inference_services.go b/controllers/tas/inference_services.go index f5e488053..d2c2e3e4d 100644 --- a/controllers/tas/inference_services.go +++ b/controllers/tas/inference_services.go @@ -6,7 +6,7 @@ import ( "strings" kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/utils" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -38,7 +38,7 @@ func (r *TrustyAIServiceReconciler) GetDeploymentsByLabel(ctx context.Context, n return deployments.Items, nil } -func (r *TrustyAIServiceReconciler) patchEnvVarsForDeployments(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, deployments []appsv1.Deployment, envVarName string, url string, remove bool) (bool, error) { +func (r *TrustyAIServiceReconciler) patchEnvVarsForDeployments(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, deployments []appsv1.Deployment, envVarName string, url string, remove bool) (bool, error) { // Create volume and volume mount for this intance's TLS secrets certVolumes := TLSCertVolumes{} certVolumes.createFor(instance) @@ -158,7 +158,7 @@ func (r *TrustyAIServiceReconciler) patchEnvVarsForDeployments(ctx context.Conte return true, nil } -func (r *TrustyAIServiceReconciler) patchEnvVarsByLabelForDeployments(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string, labelKey string, labelValue string, envVarName string, crName string, remove bool) (bool, error) { +func (r *TrustyAIServiceReconciler) patchEnvVarsByLabelForDeployments(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, namespace string, labelKey string, labelValue string, envVarName string, crName string, remove bool) (bool, error) { // Get all Deployments for the label deployments, err := r.GetDeploymentsByLabel(ctx, namespace, labelKey, labelValue) if err != nil { @@ -211,7 +211,7 @@ func generateEnvVarValue(currentValue, newValue string, remove bool) string { return currentValue } -func (r *TrustyAIServiceReconciler) handleInferenceServices(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string, labelKey, labelValue, envVarName, crName string, remove bool) (bool, error) { +func (r *TrustyAIServiceReconciler) handleInferenceServices(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, namespace string, labelKey, labelValue, envVarName, crName string, remove bool) (bool, error) { var inferenceServices kservev1beta1.InferenceServiceList if err := r.List(ctx, &inferenceServices, client.InNamespace(namespace)); err != nil { @@ -268,7 +268,7 @@ func (r *TrustyAIServiceReconciler) handleInferenceServices(ctx context.Context, } // patchKServe adds a TrustyAI service as an InferenceLogger to a KServe InferenceService -func (r *TrustyAIServiceReconciler) patchKServe(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, infService kservev1beta1.InferenceService, namespace string, crName string, remove bool, useHTTPS bool) error { +func (r *TrustyAIServiceReconciler) patchKServe(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, infService kservev1beta1.InferenceService, namespace string, crName string, remove bool, useHTTPS bool) error { var url string if useHTTPS { diff --git a/controllers/tas/monitor.go b/controllers/tas/monitor.go index d793f9ade..4d686f01c 100644 --- a/controllers/tas/monitor.go +++ b/controllers/tas/monitor.go @@ -5,7 +5,7 @@ import ( "reflect" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/tas/templates" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -91,7 +91,7 @@ func createLocalServiceMonitorObject(ctx context.Context, deploymentNamespace st } // ensureLocalServiceMonitor ensures that the local ServiceMonitor is created -func (r *TrustyAIServiceReconciler) ensureLocalServiceMonitor(cr *trustyaiopendatahubiov1alpha1.TrustyAIService, ctx context.Context) error { +func (r *TrustyAIServiceReconciler) ensureLocalServiceMonitor(cr *trustyaiopendatahubiov1.TrustyAIService, ctx context.Context) error { serviceMonitor, err := createLocalServiceMonitorObject(ctx, cr.Namespace, cr.Name) if err != nil { return err diff --git a/controllers/tas/monitor_test.go b/controllers/tas/monitor_test.go index e1c15214d..30d054aea 100644 --- a/controllers/tas/monitor_test.go +++ b/controllers/tas/monitor_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" @@ -58,7 +58,7 @@ var _ = Describe("Service Monitor Reconciliation", func() { }) Context("When creating a local ServiceMonitor", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Should have correct values", func() { namespace := "sm-test-namespace-1" instance = createDefaultPVCCustomResource(namespace) diff --git a/controllers/tas/oauth.go b/controllers/tas/oauth.go index 3c7f9acc6..09f13b900 100644 --- a/controllers/tas/oauth.go +++ b/controllers/tas/oauth.go @@ -4,7 +4,7 @@ import ( "context" "reflect" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/constants" templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/tas/templates" corev1 "k8s.io/api/core/v1" @@ -23,13 +23,13 @@ type OAuthConfig struct { } type ServiceTLSConfig struct { - Instance *trustyaiopendatahubiov1alpha1.TrustyAIService + Instance *trustyaiopendatahubiov1.TrustyAIService CustomCertificatesBundle CustomCertificatesBundle Version string } // generateTrustyAIOAuthService defines the desired OAuth service object -func generateTrustyAIOAuthService(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, caBundle CustomCertificatesBundle) (*corev1.Service, error) { +func generateTrustyAIOAuthService(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, caBundle CustomCertificatesBundle) (*corev1.Service, error) { serviceTLSConfig := ServiceTLSConfig{ Instance: instance, @@ -49,7 +49,7 @@ func generateTrustyAIOAuthService(ctx context.Context, instance *trustyaiopendat // reconcileOAuthService will manage the OAuth service reconciliation required // by the service's OAuth proxy -func (r *TrustyAIServiceReconciler) reconcileOAuthService(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, caBundle CustomCertificatesBundle) error { +func (r *TrustyAIServiceReconciler) reconcileOAuthService(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, caBundle CustomCertificatesBundle) error { // Generate the desired OAuth service object desiredService, err := generateTrustyAIOAuthService(ctx, instance, caBundle) diff --git a/controllers/tas/route.go b/controllers/tas/route.go index ec216d651..093a20e6a 100644 --- a/controllers/tas/route.go +++ b/controllers/tas/route.go @@ -5,7 +5,7 @@ import ( "reflect" routev1 "github.com/openshift/api/route/v1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/tas/templates" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -24,7 +24,7 @@ type RouteConfig struct { PortName string } -func (r *TrustyAIServiceReconciler) createRouteObject(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (*routev1.Route, error) { +func (r *TrustyAIServiceReconciler) createRouteObject(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) (*routev1.Route, error) { config := RouteConfig{ Name: instance.Name, @@ -47,8 +47,8 @@ func (r *TrustyAIServiceReconciler) createRouteObject(ctx context.Context, insta // Reconcile will manage the creation, update and deletion of the route returned // by the newRoute function -func (r *TrustyAIServiceReconciler) reconcileRouteAuth(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, - ctx context.Context, newRoute func(context.Context, *trustyaiopendatahubiov1alpha1.TrustyAIService) (*routev1.Route, error)) error { +func (r *TrustyAIServiceReconciler) reconcileRouteAuth(instance *trustyaiopendatahubiov1.TrustyAIService, + ctx context.Context, newRoute func(context.Context, *trustyaiopendatahubiov1.TrustyAIService) (*routev1.Route, error)) error { // Generate the desired route desiredRoute, err := newRoute(ctx, instance) @@ -92,11 +92,11 @@ func (r *TrustyAIServiceReconciler) reconcileRouteAuth(instance *trustyaiopendat // ReconcileRoute will manage the creation, update and deletion of the // TLS route when the service is reconciled func (r *TrustyAIServiceReconciler) ReconcileRoute( - instance *trustyaiopendatahubiov1alpha1.TrustyAIService, ctx context.Context) error { + instance *trustyaiopendatahubiov1.TrustyAIService, ctx context.Context) error { return r.reconcileRouteAuth(instance, ctx, r.createRouteObject) } -func (r *TrustyAIServiceReconciler) checkRouteReady(ctx context.Context, cr *trustyaiopendatahubiov1alpha1.TrustyAIService) (bool, error) { +func (r *TrustyAIServiceReconciler) checkRouteReady(ctx context.Context, cr *trustyaiopendatahubiov1.TrustyAIService) (bool, error) { existingRoute := &routev1.Route{} err := r.Client.Get(ctx, types.NamespacedName{Name: cr.Name, Namespace: cr.Namespace}, existingRoute) diff --git a/controllers/tas/route_test.go b/controllers/tas/route_test.go index 946c0e455..0f87664dd 100644 --- a/controllers/tas/route_test.go +++ b/controllers/tas/route_test.go @@ -6,13 +6,13 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" routev1 "github.com/openshift/api/route/v1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" ) -func setupAndTestRouteCreation(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string) { +func setupAndTestRouteCreation(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string) { WaitFor(func() error { return createNamespace(ctx, k8sClient, namespace) }, "failed to create namespace") @@ -28,7 +28,7 @@ func setupAndTestRouteCreation(instance *trustyaiopendatahubiov1alpha1.TrustyAIS } -func setupAndTestSameRouteCreation(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string) { +func setupAndTestSameRouteCreation(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string) { WaitFor(func() error { return createNamespace(ctx, k8sClient, namespace) }, "failed to create namespace") @@ -61,7 +61,7 @@ var _ = Describe("Route Reconciliation", func() { }) Context("When Route does not exist", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Should create Route successfully in PVC-mode", func() { namespace := "route-test-namespace-1-pvc" instance = createDefaultPVCCustomResource(namespace) @@ -81,7 +81,7 @@ var _ = Describe("Route Reconciliation", func() { }) Context("When Route exists and is the same", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Should not update Route in PVC-mode", func() { namespace := "route-test-namespace-2-pvc" instance = createDefaultPVCCustomResource(namespace) diff --git a/controllers/tas/secrets.go b/controllers/tas/secrets.go index 978f813be..ef49dcf07 100644 --- a/controllers/tas/secrets.go +++ b/controllers/tas/secrets.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/client" @@ -24,7 +24,7 @@ func (r *TrustyAIServiceReconciler) getSecret(ctx context.Context, name, namespa } // findDatabaseSecret finds the DB configuration secret named (specified or default) in the same namespace as the CR -func (r *TrustyAIServiceReconciler) findDatabaseSecret(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (*corev1.Secret, error) { +func (r *TrustyAIServiceReconciler) findDatabaseSecret(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) (*corev1.Secret, error) { databaseConfigurationsName := instance.Spec.Storage.DatabaseConfigurations defaultDatabaseConfigurationsName := instance.Name + dbCredentialsSuffix diff --git a/controllers/tas/service_accounts.go b/controllers/tas/service_accounts.go index 0cf647849..59f5e2749 100644 --- a/controllers/tas/service_accounts.go +++ b/controllers/tas/service_accounts.go @@ -3,7 +3,7 @@ package tas import ( "context" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/constants" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -17,12 +17,12 @@ import ( ctrl "sigs.k8s.io/controller-runtime" ) -func generateServiceAccountName(instance *trustyaiopendatahubiov1alpha1.TrustyAIService) string { +func generateServiceAccountName(instance *trustyaiopendatahubiov1.TrustyAIService) string { return instance.Name + "-proxy" } // createServiceAccount creates a service account for this instance's OAuth proxy -func (r *TrustyAIServiceReconciler) createServiceAccount(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func (r *TrustyAIServiceReconciler) createServiceAccount(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) error { routeName := instance.Name serviceAccountName := generateServiceAccountName(instance) @@ -98,7 +98,7 @@ func (r *TrustyAIServiceReconciler) createServiceAccount(ctx context.Context, in } // createClusterRoleBinding creates a binding between the service account and token review cluster role -func (r *TrustyAIServiceReconciler) createClusterRoleBinding(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, serviceAccountName string) error { +func (r *TrustyAIServiceReconciler) createClusterRoleBinding(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, serviceAccountName string) error { clusterRoleBinding := &rbacv1.ClusterRoleBinding{ ObjectMeta: metav1.ObjectMeta{ Name: instance.Name + "-" + instance.Namespace + "-proxy-rolebinding", diff --git a/controllers/tas/services.go b/controllers/tas/services.go index 4805bd3de..a888ec59f 100644 --- a/controllers/tas/services.go +++ b/controllers/tas/services.go @@ -4,7 +4,7 @@ import ( "context" "reflect" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/constants" templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/tas/templates" corev1 "k8s.io/api/core/v1" @@ -22,7 +22,7 @@ type ServiceConfig struct { Version string } -func (r *TrustyAIServiceReconciler) reconcileService(ctx context.Context, cr *trustyaiopendatahubiov1alpha1.TrustyAIService) (*corev1.Service, error) { +func (r *TrustyAIServiceReconciler) reconcileService(ctx context.Context, cr *trustyaiopendatahubiov1.TrustyAIService) (*corev1.Service, error) { serviceConfig := ServiceConfig{ Name: cr.Name, diff --git a/controllers/tas/statuses.go b/controllers/tas/statuses.go index ca4d44024..d8c11e487 100644 --- a/controllers/tas/statuses.go +++ b/controllers/tas/statuses.go @@ -3,7 +3,7 @@ package tas import ( "context" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" v1 "k8s.io/api/core/v1" "k8s.io/client-go/util/retry" ctrl "sigs.k8s.io/controller-runtime" @@ -26,9 +26,9 @@ type AvailabilityStatus struct { DBReady bool } -func (r *TrustyAIServiceReconciler) updateStatus(ctx context.Context, original *trustyaiopendatahubiov1alpha1.TrustyAIService, update func(saved *trustyaiopendatahubiov1alpha1.TrustyAIService), -) (*trustyaiopendatahubiov1alpha1.TrustyAIService, error) { - saved := &trustyaiopendatahubiov1alpha1.TrustyAIService{} +func (r *TrustyAIServiceReconciler) updateStatus(ctx context.Context, original *trustyaiopendatahubiov1.TrustyAIService, update func(saved *trustyaiopendatahubiov1.TrustyAIService), +) (*trustyaiopendatahubiov1.TrustyAIService, error) { + saved := &trustyaiopendatahubiov1.TrustyAIService{} err := retry.RetryOnConflict(retry.DefaultRetry, func() error { err := r.Client.Get(ctx, client.ObjectKeyFromObject(original), saved) if err != nil { @@ -48,7 +48,7 @@ func (r *TrustyAIServiceReconciler) updateStatus(ctx context.Context, original * } // reconcileStatuses checks the readiness status of required resources -func (r *TrustyAIServiceReconciler) reconcileStatuses(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (ctrl.Result, error) { +func (r *TrustyAIServiceReconciler) reconcileStatuses(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) (ctrl.Result, error) { var err error status := AvailabilityStatus{} @@ -72,7 +72,7 @@ func (r *TrustyAIServiceReconciler) reconcileStatuses(ctx context.Context, insta // All checks passed, resources are ready if status.IsAllReady(instance.Spec.Storage.Format) { - _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { + _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1.TrustyAIService) { if status.InferenceServiceReady { UpdateInferenceServicePresent(saved) @@ -103,7 +103,7 @@ func (r *TrustyAIServiceReconciler) reconcileStatuses(ctx context.Context, insta return RequeueWithErrorMessage(ctx, err, "Failed to update status") } } else { - _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { + _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1.TrustyAIService) { if status.InferenceServiceReady { UpdateInferenceServicePresent(saved) @@ -141,62 +141,62 @@ func (r *TrustyAIServiceReconciler) reconcileStatuses(ctx context.Context, insta return ctrl.Result{}, nil } -func UpdateInferenceServiceNotPresent(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateInferenceServiceNotPresent(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeInferenceServicesPresent, StatusReasonInferenceServicesNotFound, "InferenceServices not found", v1.ConditionFalse) saved.Status.Ready = v1.ConditionFalse } -func UpdateInferenceServicePresent(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateInferenceServicePresent(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeInferenceServicesPresent, StatusReasonInferenceServicesFound, "InferenceServices found", v1.ConditionTrue) } -func UpdatePVCNotAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdatePVCNotAvailable(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypePVCAvailable, StatusReasonPVCNotFound, "PersistentVolumeClaim not found", v1.ConditionFalse) saved.Status.Phase = PhaseNotReady saved.Status.Ready = v1.ConditionFalse } -func UpdatePVCAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdatePVCAvailable(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypePVCAvailable, StatusReasonPVCFound, "PersistentVolumeClaim found", v1.ConditionTrue) } -func UpdateRouteAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateRouteAvailable(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeRouteAvailable, StatusReasonRouteFound, "Route found", v1.ConditionTrue) } -func UpdateRouteNotAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateRouteNotAvailable(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeRouteAvailable, StatusReasonRouteNotFound, "Route not found", v1.ConditionFalse) } -func UpdateTrustyAIServiceAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateTrustyAIServiceAvailable(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeAvailable, StatusAvailable, StatusAvailable, v1.ConditionTrue) } -func UpdateTrustyAIServiceNotAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateTrustyAIServiceNotAvailable(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeAvailable, StatusNotAvailable, "Not all components available", v1.ConditionFalse) saved.Status.Phase = PhaseNotReady saved.Status.Ready = v1.ConditionFalse } -func UpdateDBCredentialsNotFound(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateDBCredentialsNotFound(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeDBAvailable, StatusDBCredentialsNotFound, "Database credentials not found", v1.ConditionFalse) saved.Status.Phase = PhaseNotReady saved.Status.Ready = v1.ConditionFalse } -func UpdateDBCredentialsError(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateDBCredentialsError(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeDBAvailable, StatusDBCredentialsError, "Error with database credentials", v1.ConditionFalse) saved.Status.Phase = PhaseNotReady saved.Status.Ready = v1.ConditionFalse } -func UpdateDBConnectionError(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateDBConnectionError(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeDBAvailable, StatusDBConnectionError, "Error connecting to database", v1.ConditionFalse) saved.Status.Phase = PhaseNotReady saved.Status.Ready = v1.ConditionFalse } -func UpdateDBAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { +func UpdateDBAvailable(saved *trustyaiopendatahubiov1.TrustyAIService) { saved.SetStatus(StatusTypeDBAvailable, StatusDBAvailable, "Database available", v1.ConditionTrue) } diff --git a/controllers/tas/statuses_test.go b/controllers/tas/statuses_test.go index 81d340829..113438db1 100644 --- a/controllers/tas/statuses_test.go +++ b/controllers/tas/statuses_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" routev1 "github.com/openshift/api/route/v1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" ) -func checkCondition(conditions []trustyaiopendatahubiov1alpha1.Condition, conditionType string, expectedStatus corev1.ConditionStatus, allowMissing bool) (*trustyaiopendatahubiov1alpha1.Condition, bool, error) { +func checkCondition(conditions []trustyaiopendatahubiov1.Condition, conditionType string, expectedStatus corev1.ConditionStatus, allowMissing bool) (*trustyaiopendatahubiov1.Condition, bool, error) { for _, cond := range conditions { if cond.Type == conditionType { isExpectedStatus := cond.Status == expectedStatus @@ -28,7 +28,7 @@ func checkCondition(conditions []trustyaiopendatahubiov1alpha1.Condition, condit return nil, false, fmt.Errorf("%s condition not found", conditionType) } -func setupAndTestStatusNoComponent(instance *trustyaiopendatahubiov1alpha1.TrustyAIService, namespace string) { +func setupAndTestStatusNoComponent(instance *trustyaiopendatahubiov1.TrustyAIService, namespace string) { WaitFor(func() error { return createNamespace(ctx, k8sClient, namespace) }, "failed to create namespace") @@ -54,7 +54,7 @@ var _ = Describe("Status and condition tests", func() { BeforeEach(func() { k8sClient = fake.NewClientBuilder().WithScheme(scheme.Scheme).WithStatusSubresource( &routev1.Route{}, - &trustyaiopendatahubiov1alpha1.TrustyAIService{}, + &trustyaiopendatahubiov1.TrustyAIService{}, ).Build() recorder = record.NewFakeRecorder(10) reconciler = &TrustyAIServiceReconciler{ @@ -66,7 +66,7 @@ var _ = Describe("Status and condition tests", func() { }) Context("When no component exists", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Should not be available in PVC-mode", func() { namespace := "statuses-test-namespace-1-pvc" instance = createDefaultPVCCustomResource(namespace) @@ -86,7 +86,7 @@ var _ = Describe("Status and condition tests", func() { }) Context("When route, deployment and PVC component, but not inference service, exist", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Should be available in PVC-mode", func() { namespace := "statuses-test-namespace-2-pvc" instance = createDefaultPVCCustomResource(namespace) @@ -294,7 +294,7 @@ var _ = Describe("Status and condition tests", func() { }) Context("When route, deployment, PVC and inference service components exist", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Should be available", func() { namespace := "statuses-test-namespace-2" instance = createDefaultPVCCustomResource(namespace) diff --git a/controllers/tas/storage.go b/controllers/tas/storage.go index a4e8266e6..6972b917a 100644 --- a/controllers/tas/storage.go +++ b/controllers/tas/storage.go @@ -3,7 +3,7 @@ package tas import ( "context" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" @@ -13,11 +13,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" ) -func generatePVCName(instance *trustyaiopendatahubiov1alpha1.TrustyAIService) string { +func generatePVCName(instance *trustyaiopendatahubiov1.TrustyAIService) string { return instance.Name + "-pvc" } -func (r *TrustyAIServiceReconciler) ensurePVC(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func (r *TrustyAIServiceReconciler) ensurePVC(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) error { pvcName := generatePVCName(instance) pvc := &corev1.PersistentVolumeClaim{} @@ -42,7 +42,7 @@ func (r *TrustyAIServiceReconciler) ensurePVC(ctx context.Context, instance *tru return nil } -func (r *TrustyAIServiceReconciler) createPVC(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func (r *TrustyAIServiceReconciler) createPVC(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) error { pvcName := generatePVCName(instance) pvc := &corev1.PersistentVolumeClaim{ @@ -69,7 +69,7 @@ func (r *TrustyAIServiceReconciler) createPVC(ctx context.Context, instance *tru return r.Create(ctx, pvc) } -func (r *TrustyAIServiceReconciler) checkPVCReady(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (bool, error) { +func (r *TrustyAIServiceReconciler) checkPVCReady(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) (bool, error) { pvc := &corev1.PersistentVolumeClaim{} err := r.Get(ctx, types.NamespacedName{Name: generatePVCName(instance), Namespace: instance.Namespace}, pvc) diff --git a/controllers/tas/storage_test.go b/controllers/tas/storage_test.go index f91919af4..080d7f232 100644 --- a/controllers/tas/storage_test.go +++ b/controllers/tas/storage_test.go @@ -5,7 +5,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -29,7 +29,7 @@ var _ = Describe("PVC Reconciliation", func() { }) Context("when the PVC does not exist", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("should create a new PVC and emit an event", func() { namespace := "pvc-test-namespace-1" instance = createDefaultPVCCustomResource(namespace) @@ -52,7 +52,7 @@ var _ = Describe("PVC Reconciliation", func() { }) Context("when the PVC already exists", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("should not attempt to create the PVC", func() { namespace := "pvc-test-namespace-2" instance = createDefaultPVCCustomResource(namespace) @@ -79,7 +79,7 @@ var _ = Describe("PVC Reconciliation", func() { }) Context("when a migration CR is made", func() { - var instance *trustyaiopendatahubiov1alpha1.TrustyAIService + var instance *trustyaiopendatahubiov1.TrustyAIService It("Check all fields are correct", func() { namespace := "pvc-test-namespace-3" instance = createDefaultMigrationCustomResource(namespace) diff --git a/controllers/tas/subreconciler.go b/controllers/tas/subreconciler.go index 43fb689e0..1e848db2b 100644 --- a/controllers/tas/subreconciler.go +++ b/controllers/tas/subreconciler.go @@ -4,7 +4,7 @@ import ( "context" "time" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -33,4 +33,4 @@ func RequeueWithDelayAndError(dur time.Duration, e error) (reconcile.Result, err } func DoNotRequeue() (reconcile.Result, error) { return ctrl.Result{Requeue: false}, nil } -type SubReconciler = func(context.Context, ctrl.Request, *trustyaiopendatahubiov1alpha1.TrustyAIService) (*ctrl.Result, error) +type SubReconciler = func(context.Context, ctrl.Request, *trustyaiopendatahubiov1.TrustyAIService) (*ctrl.Result, error) diff --git a/controllers/tas/suite_test.go b/controllers/tas/suite_test.go index ae55222f9..8690f7d98 100644 --- a/controllers/tas/suite_test.go +++ b/controllers/tas/suite_test.go @@ -33,7 +33,7 @@ import ( . "github.com/onsi/gomega" routev1 "github.com/openshift/api/route/v1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/constants" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -91,24 +91,24 @@ func WaitFor(operation func() error, errorMsg string) { } // createDefaultPVCCustomResource creates a TrustyAIService instance with default values and PVC backend -func createDefaultPVCCustomResource(namespaceCurrent string) *trustyaiopendatahubiov1alpha1.TrustyAIService { - service := trustyaiopendatahubiov1alpha1.TrustyAIService{ +func createDefaultPVCCustomResource(namespaceCurrent string) *trustyaiopendatahubiov1.TrustyAIService { + service := trustyaiopendatahubiov1.TrustyAIService{ ObjectMeta: metav1.ObjectMeta{ Name: defaultServiceName, Namespace: namespaceCurrent, UID: types.UID(uuid.New().String()), }, - Spec: trustyaiopendatahubiov1alpha1.TrustyAIServiceSpec{ - Storage: trustyaiopendatahubiov1alpha1.StorageSpec{ + Spec: trustyaiopendatahubiov1.TrustyAIServiceSpec{ + Storage: trustyaiopendatahubiov1.StorageSpec{ Format: STORAGE_PVC, Folder: "/data", Size: "1Gi", }, - Data: trustyaiopendatahubiov1alpha1.DataSpec{ + Data: trustyaiopendatahubiov1.DataSpec{ Filename: "data.csv", Format: "CSV", }, - Metrics: trustyaiopendatahubiov1alpha1.MetricsSpec{ + Metrics: trustyaiopendatahubiov1.MetricsSpec{ Schedule: "5s", }, }, @@ -117,19 +117,19 @@ func createDefaultPVCCustomResource(namespaceCurrent string) *trustyaiopendatahu } // createDefaultDBCustomResource creates a TrustyAIService instance with default values and DB backend -func createDefaultDBCustomResource(namespaceCurrent string) *trustyaiopendatahubiov1alpha1.TrustyAIService { - service := trustyaiopendatahubiov1alpha1.TrustyAIService{ +func createDefaultDBCustomResource(namespaceCurrent string) *trustyaiopendatahubiov1.TrustyAIService { + service := trustyaiopendatahubiov1.TrustyAIService{ ObjectMeta: metav1.ObjectMeta{ Name: defaultServiceName, Namespace: namespaceCurrent, UID: types.UID(uuid.New().String()), }, - Spec: trustyaiopendatahubiov1alpha1.TrustyAIServiceSpec{ - Storage: trustyaiopendatahubiov1alpha1.StorageSpec{ + Spec: trustyaiopendatahubiov1.TrustyAIServiceSpec{ + Storage: trustyaiopendatahubiov1.StorageSpec{ Format: STORAGE_DATABASE, DatabaseConfigurations: defaultDatabaseConfigurationName, }, - Metrics: trustyaiopendatahubiov1alpha1.MetricsSpec{ + Metrics: trustyaiopendatahubiov1.MetricsSpec{ Schedule: "5s", }, }, @@ -138,25 +138,25 @@ func createDefaultDBCustomResource(namespaceCurrent string) *trustyaiopendatahub } // createDefaultMigrationCustomResource creates a TrustyAIService instance with default values and both PVC and DB backend -func createDefaultMigrationCustomResource(namespaceCurrent string) *trustyaiopendatahubiov1alpha1.TrustyAIService { - service := trustyaiopendatahubiov1alpha1.TrustyAIService{ +func createDefaultMigrationCustomResource(namespaceCurrent string) *trustyaiopendatahubiov1.TrustyAIService { + service := trustyaiopendatahubiov1.TrustyAIService{ ObjectMeta: metav1.ObjectMeta{ Name: defaultServiceName, Namespace: namespaceCurrent, UID: types.UID(uuid.New().String()), }, - Spec: trustyaiopendatahubiov1alpha1.TrustyAIServiceSpec{ - Storage: trustyaiopendatahubiov1alpha1.StorageSpec{ + Spec: trustyaiopendatahubiov1.TrustyAIServiceSpec{ + Storage: trustyaiopendatahubiov1.StorageSpec{ Format: STORAGE_DATABASE, DatabaseConfigurations: defaultDatabaseConfigurationName, Folder: "/data", Size: "1Gi", }, - Data: trustyaiopendatahubiov1alpha1.DataSpec{ + Data: trustyaiopendatahubiov1.DataSpec{ Filename: "data.csv", Format: "CSV", }, - Metrics: trustyaiopendatahubiov1alpha1.MetricsSpec{ + Metrics: trustyaiopendatahubiov1.MetricsSpec{ Schedule: "5s", }, }, @@ -278,7 +278,7 @@ func createMockPV(ctx context.Context, k8sClient client.Client, pvName string, s return nil } -func createTestPVC(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func createTestPVC(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1.TrustyAIService) error { pvc := &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Name: instance.Name + "-pvc", @@ -332,7 +332,7 @@ func createInferenceService(name string, namespace string) *kservev1beta1.Infere } } -func makePVCReady(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func makePVCReady(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1.TrustyAIService) error { pvc := &corev1.PersistentVolumeClaim{} pvcName := types.NamespacedName{ Name: generatePVCName(instance), @@ -346,7 +346,7 @@ func makePVCReady(ctx context.Context, k8sClient client.Client, instance *trusty return k8sClient.Status().Update(ctx, pvc) } -func makeDeploymentReady(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func makeDeploymentReady(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1.TrustyAIService) error { deployment := &appsv1.Deployment{} deploymentName := types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace} @@ -432,7 +432,7 @@ func makeDeploymentReady(ctx context.Context, k8sClient client.Client, instance return nil } -func makeRouteReady(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func makeRouteReady(ctx context.Context, k8sClient client.Client, instance *trustyaiopendatahubiov1.TrustyAIService) error { route := &routev1.Route{} routeName := types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace} @@ -454,7 +454,7 @@ func makeRouteReady(ctx context.Context, k8sClient client.Client, instance *trus return k8sClient.Status().Update(ctx, route) } -func checkServiceAccountAnnotations(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, k8sClient client.Client) { +func checkServiceAccountAnnotations(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, k8sClient client.Client) { serviceAccount := &corev1.ServiceAccount{} serviceAccountName := generateServiceAccountName(instance) err := k8sClient.Get(ctx, types.NamespacedName{Name: serviceAccountName, Namespace: instance.Namespace}, serviceAccount) @@ -488,7 +488,7 @@ func checkServiceAccountAnnotations(ctx context.Context, instance *trustyaiopend Expect(annotation).To(Equal(string(oauthRedirectRefJSON))) } -func checkClusterRoleBinding(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, k8sClient client.Client) { +func checkClusterRoleBinding(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService, k8sClient client.Client) { clusterRoleBindingName := instance.Name + "-" + instance.Namespace + "-proxy-rolebinding" clusterRoleBinding := &rbacv1.ClusterRoleBinding{} @@ -525,7 +525,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - err = trustyaiopendatahubiov1alpha1.AddToScheme(scheme.Scheme) + err = trustyaiopendatahubiov1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) // Add Monitoring diff --git a/controllers/tas/trustyaiservice_controller.go b/controllers/tas/trustyaiservice_controller.go index 7b3329885..56b89a0c6 100644 --- a/controllers/tas/trustyaiservice_controller.go +++ b/controllers/tas/trustyaiservice_controller.go @@ -22,7 +22,7 @@ import ( "time" kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" "github.com/trustyai-explainability/trustyai-service-operator/controllers/utils" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" @@ -87,7 +87,7 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ // Fetch the resource // Kubernetes convert automatically between versions // This is the controller for the storage version (v1) so we'll get the canonical representation - instance := &trustyaiopendatahubiov1alpha1.TrustyAIService{} + instance := &trustyaiopendatahubiov1.TrustyAIService{} err := r.Get(ctx, req.NamespacedName, instance) if err != nil { if errors.IsNotFound(err) { @@ -169,7 +169,7 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ // Get database configuration secret, err := r.findDatabaseSecret(ctx, instance) if err != nil { - _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { + _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1.TrustyAIService) { UpdateDBCredentialsNotFound(saved) UpdateTrustyAIServiceNotAvailable(saved) saved.Status.Phase = PhaseNotReady @@ -182,7 +182,7 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ } err = r.validateDatabaseSecret(secret) if err != nil { - _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { + _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1.TrustyAIService) { UpdateDBCredentialsError(saved) UpdateTrustyAIServiceNotAvailable(saved) saved.Status.Phase = PhaseNotReady @@ -221,7 +221,7 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ } // Fetch the TrustyAIService instance - trustyAIServiceService := &trustyaiopendatahubiov1alpha1.TrustyAIService{} + trustyAIServiceService := &trustyaiopendatahubiov1.TrustyAIService{} err = r.Get(ctx, req.NamespacedName, trustyAIServiceService) if err != nil { return RequeueWithErrorMessage(ctx, err, "Could not fetch service.") @@ -281,7 +281,7 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ func (r *TrustyAIServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { // v1alpha1 as primary, but handle both versions return ctrl.NewControllerManagedBy(mgr). - For(&trustyaiopendatahubiov1alpha1.TrustyAIService{}). + For(&trustyaiopendatahubiov1.TrustyAIService{}). Owns(&appsv1.Deployment{}). Watches(&kservev1beta1.InferenceService{}, &handler.EnqueueRequestForObject{}). Complete(r) diff --git a/controllers/tas/virtual_service.go b/controllers/tas/virtual_service.go index 188c049ce..582a1f2ab 100644 --- a/controllers/tas/virtual_service.go +++ b/controllers/tas/virtual_service.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1" + trustyaiopendatahubiov1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1" templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/tas/templates" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -44,7 +44,7 @@ func (r *TrustyAIServiceReconciler) isVirtualServiceCRDPresent(ctx context.Conte return true, nil } -func (r *TrustyAIServiceReconciler) ensureVirtualService(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { +func (r *TrustyAIServiceReconciler) ensureVirtualService(ctx context.Context, instance *trustyaiopendatahubiov1.TrustyAIService) error { virtualServiceName := instance.Name + "-redirect" diff --git a/tests/smoke/manifests/trustyai-cr.yaml b/tests/smoke/manifests/trustyai-cr.yaml index 816316fea..d3523aa5e 100644 --- a/tests/smoke/manifests/trustyai-cr.yaml +++ b/tests/smoke/manifests/trustyai-cr.yaml @@ -1,4 +1,4 @@ -apiVersion: trustyai.opendatahub.io/v1alpha1 +apiVersion: trustyai.opendatahub.io/v1 kind: TrustyAIService metadata: name: trustyai-service