Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from kubeflow:main #151

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ gen: deps gen/grpc gen/openapi gen/openapi-server gen/converter

.PHONY: lint
lint:
${GOLANGCI_LINT} run main.go
${GOLANGCI_LINT} run cmd/... internal/... ./pkg/...
${GOLANGCI_LINT} run main.go --timeout 3m
${GOLANGCI_LINT} run cmd/... internal/... ./pkg/... --timeout 3m

.PHONY: test
test: gen bin/envtest
Expand Down Expand Up @@ -256,12 +256,12 @@ ifeq ($(DOCKER),docker)
# docker uses builder containers
- $(DOCKER) buildx rm model-registry-builder
$(DOCKER) buildx create --use --name model-registry-builder --platform=$(PLATFORMS)
$(DOCKER) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f ${DOCKERFILE} .
$(DOCKER) buildx build --push --platform=$(PLATFORMS) --tag ${IMG}:$(IMG_VERSION) -f ${DOCKERFILE} .
$(DOCKER) buildx rm model-registry-builder
else ifeq ($(DOCKER),podman)
# podman uses image manifests
$(DOCKER) manifest create -a ${IMG}
$(DOCKER) buildx build --platform=$(PLATFORMS) --manifest ${IMG} -f ${DOCKERFILE} .
$(DOCKER) buildx build --platform=$(PLATFORMS) --manifest ${IMG}:$(IMG_VERSION) -f ${DOCKERFILE} .
$(DOCKER) manifest push ${IMG}
$(DOCKER) manifest rm ${IMG}
else
Expand Down
45 changes: 37 additions & 8 deletions pkg/inferenceservice-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package inferenceservicecontroller

import (
"context"
"crypto/tls"
"fmt"
"net/http"

Expand All @@ -18,37 +19,59 @@ import (

type InferenceServiceController struct {
client client.Client
customHTTPClient *http.Client
httpClient *http.Client
log logr.Logger
bearerToken string
inferenceServiceIDLabel string
registeredModelIDLabel string
modelVersionIDLabel string
modelRegistryNamespaceLabel string
modelRegistryNameLabel string
modelRegistryURLLabel string
modelRegistryURLAnnotation string
modelRegistryFinalizer string
defaultModelRegistryNamespace string
}

func NewInferenceServiceController(client client.Client, log logr.Logger, bearerToken, isIDLabel, regModelIDLabel, modelVerIDLabel, mrNamespaceLabel, mrNameLabel, mrURLLabel, mrFinalizer, defaultMRNamespace string) *InferenceServiceController {
func NewInferenceServiceController(
client client.Client,
log logr.Logger,
skipTLSVerify bool,
bearerToken,
isIDLabel,
regModelIDLabel,
modelVerIDLabel,
mrNamespaceLabel,
mrNameLabel,
mrURLAnnotation,
mrFinalizer,
defaultMRNamespace string,
) *InferenceServiceController {
httpClient := http.DefaultClient

if skipTLSVerify {
httpClient.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
}

return &InferenceServiceController{
client: client,
httpClient: httpClient,
log: log,
bearerToken: bearerToken,
inferenceServiceIDLabel: isIDLabel,
registeredModelIDLabel: regModelIDLabel,
modelVersionIDLabel: modelVerIDLabel,
modelRegistryNamespaceLabel: mrNamespaceLabel,
modelRegistryNameLabel: mrNameLabel,
modelRegistryURLLabel: mrURLLabel,
modelRegistryURLAnnotation: mrURLAnnotation,
modelRegistryFinalizer: mrFinalizer,
defaultModelRegistryNamespace: defaultMRNamespace,
}
}

func (r *InferenceServiceController) OverrideHTTPClient(client *http.Client) {
r.customHTTPClient = client
r.httpClient = client
}

// Reconcile performs the reconciliation of the model registry based on Kubeflow InferenceService CRs
Expand Down Expand Up @@ -80,14 +103,20 @@ func (r *InferenceServiceController) Reconcile(ctx context.Context, req ctrl.Req
registeredModelId, okRegisteredModelId := isvc.Labels[r.registeredModelIDLabel]
modelVersionId := isvc.Labels[r.modelVersionIDLabel]
mrName, okMrName := isvc.Labels[r.modelRegistryNameLabel]
mrUrl := isvc.Labels[r.modelRegistryURLLabel]
mrUrl, okMrUrl := isvc.Annotations[r.modelRegistryURLAnnotation]

if !okMrIsvcId && !okRegisteredModelId && !okMrName {
if !okMrIsvcId && !okRegisteredModelId {
// Early check: no model registry specific labels set in the ISVC, ignore the CR
log.Error(fmt.Errorf("missing model registry specific label, unable to link ISVC to Model Registry, skipping InferenceService"), "Stop ModelRegistry InferenceService reconciliation")
return ctrl.Result{}, nil
}

if !okMrName && !okMrUrl {
// Early check: it's required to have the model registry name or url set in the ISVC
log.Error(fmt.Errorf("missing model registry name or url, unable to link ISVC to Model Registry, skipping InferenceService"), "Stop ModelRegistry InferenceService reconciliation")
return ctrl.Result{}, nil
}

if mrNSFromISVC, ok := isvc.Labels[r.modelRegistryNamespaceLabel]; ok {
mrNamespace = mrNSFromISVC
}
Expand Down Expand Up @@ -210,7 +239,7 @@ func (r *InferenceServiceController) initModelRegistryService(ctx context.Contex
}

cfg := &openapi.Configuration{
HTTPClient: r.customHTTPClient,
HTTPClient: r.httpClient,
Servers: openapi.ServerConfigurations{
{
URL: url,
Expand Down
6 changes: 4 additions & 2 deletions pkg/inferenceservice-controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const (
modelVersionIDLabel = "modelregistry.kubeflow.org/model-version-id"
namespaceLabel = "modelregistry.kubeflow.org/namespace"
nameLabel = "modelregistry.kubeflow.org/name"
urlLabel = "modelregistry.kubeflow.org/url"
skipTLSVerify = true
urlAnnotation = "modelregistry.kubeflow.org/url"
finalizerLabel = "modelregistry.kubeflow.org/finalizer"
defaultNamespace = "default"
accessToken = ""
Expand Down Expand Up @@ -135,13 +136,14 @@ var _ = BeforeSuite(func() {
inferenceServiceController := inferenceservicecontroller.NewInferenceServiceController(
cli,
ctrl.Log.WithName("controllers").WithName("ModelRegistry-InferenceService-Controller"),
skipTLSVerify,
accessToken,
inferenceServiceIDLabel,
registeredModelIDLabel,
modelVersionIDLabel,
namespaceLabel,
nameLabel,
urlLabel,
urlAnnotation,
finalizerLabel,
defaultNamespace,
)
Expand Down
10 changes: 7 additions & 3 deletions scripts/install_protoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ if [[ ${OSTYPE,,} =~ darwin ]]; then
OS="osx"
fi

ARCH="x86_64"
if [[ $(uname -m) =~ arm ]]; then
ARCH="aarch_64"
ARCH=$(uname -m)
if [[ "$ARCH" == "arm"* ]]; then
ARCH="aarch_64"
elif [[ "$ARCH" == "s390x" ]]; then
ARCH="s390_64"
elif [[ "$ARCH" == "ppc64le" ]] ; then
ARCH="ppcle_64"
fi

PROJECT_ROOT=$(realpath "$(dirname "$0")"/..)
Expand Down
Loading