Skip to content

Commit

Permalink
Merge pull request #345 from israel-hdez/v0121-cherry-picks
Browse files Browse the repository at this point in the history
[release-0.12.1] Cherry picks - Fixes for ODH
  • Loading branch information
openshift-merge-bot[bot] authored May 6, 2024
2 parents c6fb96d + 4e537e7 commit 8d736ad
Show file tree
Hide file tree
Showing 67 changed files with 4,680 additions and 4,462 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/create-release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Create Tag and Release with Changelog

on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the new release'
required: true

permissions:
contents: write
packages: write
pull-requests: write

jobs:
fetch-tag:
runs-on: ubuntu-latest
outputs:
old_tag: ${{ steps.get_tag.outputs.old_tag_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Get latest tag
id: get_tag
run: |
echo "old_tag_name=$(git ls-remote --tags origin | awk -F'/' '{print $3}' | grep -v '{}' | sort -V | tail -n1)" >> $GITHUB_OUTPUT
- name: print tag
id: print_tag
run: |
echo "Old Tag=${{ steps.get_tag.outputs.old_tag_name }}"
echo "NEW_TAG=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
echo "$(basename ${{ github.ref }})"
- name: Check if tag exists
id: check_tag
run: |
import sys
import subprocess
tag_name = "${{ github.event.inputs.tag_name }}"
command = ['git', 'tag', '-l', tag_name]
output = subprocess.check_output(command, stderr=subprocess.STDOUT)
if output.decode() != "":
print(f"Error: Tag '{tag_name}' already exists.", file=sys.stderr)
sys.exit(1)
else:
print(f"Tag '{tag_name}' does not exists.")
shell: python
continue-on-error: false

#this works only if params.env contains image:tag_version_number
update-params-env:
runs-on: ubuntu-latest
needs: fetch-tag
outputs:
param_env: ${{ steps.read_params_env.outputs.params_env }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Update params.env with new release version
run: |
sed -i 's|:v[0-9.]*\b|:${{ github.event.inputs.tag_name }}|gm' config/overlays/odh/params.env
- name: Commit changes
run: |
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
git add config/overlays/odh/params.env
git commit -m "Update image refs for odh release."
- name: Create Tag
id: create_tag
run: |
git tag -a ${{ github.event.inputs.tag_name }} -m "Prepare for ODH release ${{ github.event.inputs.tag_name }}"
git push origin ${{ github.event.inputs.tag_name }}
changelog:
name: Changelog
needs: [fetch-tag,update-params-env]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ github.token }}
tag_name: ${{ github.event.inputs.tag_name }}
prerelease: false
draft: false
#this takes the path of payload to upload as an asset in the changelog
files: bin/*
generate_release_notes: true
name: ${{ github.event.inputs.tag_name }}
103 changes: 103 additions & 0 deletions .github/workflows/odh-create-release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Create Tag and Release with Changelog

on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the new release'
required: true

permissions:
contents: write
packages: write
pull-requests: write

jobs:
fetch-tag:
runs-on: ubuntu-latest
outputs:
old_tag: ${{ steps.get_tag.outputs.old_tag_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Get latest tag
id: get_tag
run: |
echo "old_tag_name=$(git ls-remote --tags origin | awk -F'/' '{print $3}' | grep -v '{}' | sort -V | tail -n1)" >> $GITHUB_OUTPUT
- name: print tag
id: print_tag
run: |
echo "Old Tag=${{ steps.get_tag.outputs.old_tag_name }}"
echo "NEW_TAG=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
echo "$(basename ${{ github.ref }})"
- name: Check if tag exists
id: check_tag
run: |
import sys
import subprocess
tag_name = "${{ github.event.inputs.tag_name }}"
command = ['git', 'tag', '-l', tag_name]
output = subprocess.check_output(command, stderr=subprocess.STDOUT)
if output.decode() != "":
print(f"Error: Tag '{tag_name}' already exists.", file=sys.stderr)
sys.exit(1)
else:
print(f"Tag '{tag_name}' does not exists.")
shell: python
continue-on-error: false

#this works only if params.env contains image:tag_version_number
update-params-env:
runs-on: ubuntu-latest
needs: fetch-tag
outputs:
param_env: ${{ steps.read_params_env.outputs.params_env }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Update params.env with new release version
run: |
sed -i 's|:v[0-9.]*\b|:${{ github.event.inputs.tag_name }}|gm' config/overlays/odh/params.env
- name: Commit changes
run: |
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
git add config/overlays/odh/params.env
git commit -m "Update image refs for odh release."
- name: Create Tag
id: create_tag
run: |
git tag -a ${{ github.event.inputs.tag_name }} -m "Prepare for ODH release ${{ github.event.inputs.tag_name }}"
git push origin ${{ github.event.inputs.tag_name }}
changelog:
name: Changelog
needs: [fetch-tag,update-params-env]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ github.token }}
tag_name: ${{ github.event.inputs.tag_name }}
prerelease: false
draft: false
#this takes the path of payload to upload as an asset in the changelog
files: bin/*
generate_release_notes: true
name: ${{ github.event.inputs.tag_name }}
2 changes: 1 addition & 1 deletion .github/workflows/storage-initializer-docker-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
TAGS=$IMAGE_ID:$VERSION
# If a vX.Y.Z release is being built, also update the vX.Y tag.
[[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && MINOR_VERSION=$(echo $VERSION | sed 's/\(.*\)\.[[:digit:]]\+$/\1/')
[ ! -z "env.MINOR_VERSION" ] && TAGS=$TAGS,$IMAGE_ID:$MINOR_VERSION
[ ! -z "$MINOR_VERSION" ] && TAGS=$TAGS,$IMAGE_ID:$MINOR_VERSION
echo TAGS=$TAGS >> $GITHUB_ENV
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# Binaries for programs and plugins
.tekton
*.exe
*.exe~
*.dll
Expand Down
6 changes: 0 additions & 6 deletions charts/kserve-resources/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ rules:
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -102,18 +100,14 @@ rules:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
Expand Down
61 changes: 30 additions & 31 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ import (
"os"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
"github.com/kserve/kserve/pkg/apis/serving/v1beta1"
"github.com/kserve/kserve/pkg/constants"
graphcontroller "github.com/kserve/kserve/pkg/controller/v1alpha1/inferencegraph"
trainedmodelcontroller "github.com/kserve/kserve/pkg/controller/v1alpha1/trainedmodel"
"github.com/kserve/kserve/pkg/controller/v1alpha1/trainedmodel/reconcilers/modelconfig"
v1beta1controller "github.com/kserve/kserve/pkg/controller/v1beta1/inferenceservice"
"github.com/kserve/kserve/pkg/webhook/admission/pod"
"github.com/kserve/kserve/pkg/webhook/admission/servingruntime"
istio_networking "istio.io/api/networking/v1beta1"
istioclientv1beta1 "istio.io/client-go/pkg/apis/networking/v1beta1"
v1 "k8s.io/api/core/v1"
Expand All @@ -41,13 +32,22 @@ import (
"k8s.io/client-go/tools/record"
knservingv1 "knative.dev/serving/pkg/apis/serving/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

"github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
"github.com/kserve/kserve/pkg/apis/serving/v1beta1"
"github.com/kserve/kserve/pkg/constants"
graphcontroller "github.com/kserve/kserve/pkg/controller/v1alpha1/inferencegraph"
trainedmodelcontroller "github.com/kserve/kserve/pkg/controller/v1alpha1/trainedmodel"
"github.com/kserve/kserve/pkg/controller/v1alpha1/trainedmodel/reconcilers/modelconfig"
v1beta1controller "github.com/kserve/kserve/pkg/controller/v1beta1/inferenceservice"
"github.com/kserve/kserve/pkg/webhook/admission/pod"
"github.com/kserve/kserve/pkg/webhook/admission/servingruntime"
)

var (
Expand Down Expand Up @@ -111,6 +111,13 @@ func main() {
os.Exit(1)
}

// Setup clientset to directly talk to the api server
clientSet, err := kubernetes.NewForConfig(cfg)
if err != nil {
setupLog.Error(err, "unable to create clientSet")
os.Exit(1)
}

// Create a new Cmd to provide shared dependencies and start components
setupLog.Info("Setting up manager")
mgr, err := manager.New(cfg, manager.Options{
Expand Down Expand Up @@ -141,17 +148,12 @@ func main() {
os.Exit(1)
}

kubeClient, err := client.New(mgr.GetConfig(), client.Options{Scheme: mgr.GetScheme()})
if err != nil {
setupLog.Error(err, "unable to create new client.")
}

deployConfig, err := v1beta1.NewDeployConfig(kubeClient)
deployConfig, err := v1beta1.NewDeployConfig(clientSet)
if err != nil {
setupLog.Error(err, "unable to get deploy config.")
os.Exit(1)
}
ingressConfig, err := v1beta1.NewIngressConfig(kubeClient)
ingressConfig, err := v1beta1.NewIngressConfig(clientSet)
if err != nil {
setupLog.Error(err, "unable to get ingress config.")
os.Exit(1)
Expand Down Expand Up @@ -180,16 +182,12 @@ func main() {
// Setup all Controllers
setupLog.Info("Setting up v1beta1 controller")
eventBroadcaster := record.NewBroadcaster()
clientSet, err := kubernetes.NewForConfig(mgr.GetConfig())
if err != nil {
setupLog.Error(err, "unable to create clientSet")
os.Exit(1)
}
eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: clientSet.CoreV1().Events("")})
if err = (&v1beta1controller.InferenceServiceReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("v1beta1Controllers").WithName("InferenceService"),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Clientset: clientSet,
Log: ctrl.Log.WithName("v1beta1Controllers").WithName("InferenceService"),
Scheme: mgr.GetScheme(),
Recorder: eventBroadcaster.NewRecorder(
mgr.GetScheme(), v1.EventSource{Component: "v1beta1Controllers"}),
}).SetupWithManager(mgr, deployConfig, ingressConfig); err != nil {
Expand All @@ -206,7 +204,7 @@ func main() {
Log: ctrl.Log.WithName("v1beta1Controllers").WithName("TrainedModel"),
Scheme: mgr.GetScheme(),
Recorder: eventBroadcaster.NewRecorder(mgr.GetScheme(), v1.EventSource{Component: "v1beta1Controllers"}),
ModelConfigReconciler: modelconfig.NewModelConfigReconciler(mgr.GetClient(), mgr.GetScheme()),
ModelConfigReconciler: modelconfig.NewModelConfigReconciler(mgr.GetClient(), clientSet, mgr.GetScheme()),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "v1beta1Controllers", "TrainedModel")
os.Exit(1)
Expand All @@ -217,10 +215,11 @@ func main() {
setupLog.Info("Setting up InferenceGraph controller")
inferenceGraphEventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: clientSet.CoreV1().Events("")})
if err = (&graphcontroller.InferenceGraphReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("v1alpha1Controllers").WithName("InferenceGraph"),
Scheme: mgr.GetScheme(),
Recorder: eventBroadcaster.NewRecorder(mgr.GetScheme(), v1.EventSource{Component: "InferenceGraphController"}),
Client: mgr.GetClient(),
Clientset: clientSet,
Log: ctrl.Log.WithName("v1alpha1Controllers").WithName("InferenceGraph"),
Scheme: mgr.GetScheme(),
Recorder: eventBroadcaster.NewRecorder(mgr.GetScheme(), v1.EventSource{Component: "InferenceGraphController"}),
}).SetupWithManager(mgr, deployConfig); err != nil {
setupLog.Error(err, "unable to create controller", "v1alpha1Controllers", "InferenceGraph")
os.Exit(1)
Expand All @@ -231,7 +230,7 @@ func main() {

setupLog.Info("registering webhooks to the webhook server")
hookServer.Register("/mutate-pods", &webhook.Admission{
Handler: &pod.Mutator{Client: mgr.GetClient(), Decoder: admission.NewDecoder(mgr.GetScheme())},
Handler: &pod.Mutator{Client: mgr.GetClient(), Clientset: clientSet, Decoder: admission.NewDecoder(mgr.GetScheme())},
})

//log.Info("registering cluster serving runtime validator webhook to the webhook server")
Expand Down
Loading

0 comments on commit 8d736ad

Please sign in to comment.