Skip to content

Commit

Permalink
Merge pull request opendatahub-io#470 from opendatahub-io/sync__main_…
Browse files Browse the repository at this point in the history
…_v1.9-branch__20241126102910

RHOAIENG-16202: Sync main into v1.9-branch
  • Loading branch information
openshift-merge-bot[bot] authored Nov 26, 2024
2 parents cb7d54b + 8f00304 commit de53637
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 114 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/notebook-controller-images-updater.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
echo "Updating files in VERSION=${VERSION} with COMMIT_ID=${COMMIT_ID}"
sed -E "s/(odh-kf-notebook-controller-image=quay\.io\/opendatahub\/kubeflow-notebook-controller:)[^: -]+(-)[^ ]+/\1$VERSION\2$COMMIT_ID/" -i components/notebook-controller/config/overlays/openshift/params.env
sed -E "s/(odh-notebook-controller-image=quay\.io\/opendatahub\/odh-notebook-controller:)[^: -]+(-)[^ ]+/\1$VERSION\2$COMMIT_ID/" -i components/odh-notebook-controller/config/base/params.env
sed -E "s/(KF_TAG \?= )[^\-]+(-)[^ ]+/\1$VERSION\2$COMMIT_ID/" -i components/odh-notebook-controller/Makefile
sed -E "s/(KF_TAG \?= )[^\-]+(-)[^ ]+/\1$VERSION\2$COMMIT_ID/" -i components/odh-notebook-controller/makefile-vars.mk
git status
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
Expand All @@ -82,8 +82,8 @@ jobs:
git pull origin ${{ env.TEMP_UPDATER_BRANCH }}
git add components/notebook-controller/config/overlays/openshift/params.env
git add components/odh-notebook-controller/config/base/params.env
git add components/odh-notebook-controller/Makefile
git commit -m "Update odh and notebook-controller with image ${VERSION}-${COMMIT_ID}"
git add components/odh-notebook-controller/makefile-vars.mk
git commit -m ":robot: Update odh and notebook-controller with image ${VERSION}-${COMMIT_ID}"
git push origin ${{ env.TEMP_UPDATER_BRANCH }}
git log --oneline
else
Expand All @@ -106,4 +106,5 @@ jobs:
Have been updated the following related files:
- components/notebook-controller/config/overlays/openshift/params.env
- components/odh-notebook-controller/config/base/params.env
- components/odh-notebook-controller/Makefile
- components/odh-notebook-controller/makefile-vars.mk
103 changes: 68 additions & 35 deletions .github/workflows/sync-branches-through-pr.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,80 @@
---
name: Sync branches through Pull Request
name: Sync Branches

on: # yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
source:
description: Source branch
description: "From:"
required: true
type: string
target:
description: Target branch
description: "To:"
required: true
type: string

jobs:
sync:
permissions:
contents: write
pull-requests: write
sync-branches:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target }}
fetch-depth: 0

- name: Prepare sync branch
id: prepare
run: |
git fetch origin ${{ github.event.inputs.source }}
git reset --hard origin/${{ github.event.inputs.source }}
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
SYNC_BRANCH=sync__${{ github.event.inputs.source }}__${{ github.event.inputs.target }}__${TIMESTAMP}
echo "branch=$SYNC_BRANCH" >> $GITHUB_OUTPUT
- name: Create pull request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
branch: ${{ steps.prepare.outputs.branch }}
title: "Sync `${{ github.event.inputs.target }}` branch with `${{ github.event.inputs.source }}` branch"
body: |
:robot: This is an automated Pull Request created by `/.github/workflows/sync-branches-through-pr.yml`.
It merges all commits from `${{ github.event.inputs.source }}` branch into `${{ github.event.inputs.target }}` branch.
:warning: **IMPORTANT NOTE**: Remember to delete the `${{ steps.prepare.outputs.branch }}` branch after merging the changes.
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full history is fetched for merging

- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Merge source branch into target with conflict resolution
id: merge
run: |
set -e
SOURCE_BRANCH="${{ github.event.inputs.source }}"
TARGET_BRANCH="${{ github.event.inputs.target }}"
git fetch origin ${TARGET_BRANCH}:${TARGET_BRANCH}
git checkout ${TARGET_BRANCH}
git fetch origin ${SOURCE_BRANCH}:${SOURCE_BRANCH}
git merge --no-commit origin/${SOURCE_BRANCH} || true
# Resolve conflicts for specific files
FILES=(
"components/notebook-controller/config/overlays/openshift/params.env"
"components/odh-notebook-controller/config/base/params.env"
"components/odh-notebook-controller/makefile-vars.mk"
)
for FILE in "${FILES[@]}"; do
if [[ -f "$FILE" && "$(git status --porcelain=v1 2>/dev/null | grep -c "$FILE")" -gt 0 ]]; then
echo "Resolving conflict for $FILE by keeping target branch version."
git checkout --ours "$FILE"
git add "$FILE"
fi
done
# Commit the merge changes
git commit -m "Merge ${SOURCE_BRANCH} into ${TARGET_BRANCH} with resolved conflicts" || echo "Nothing to commit"
# Create a new branch for the sync
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
SYNC_BRANCH="sync__${SOURCE_BRANCH}__${TARGET_BRANCH}__${TIMESTAMP}"
git checkout -b $SYNC_BRANCH
git push origin $SYNC_BRANCH
echo "branch=$SYNC_BRANCH" >> $GITHUB_OUTPUT
- name: Create a Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SOURCE_BRANCH="${{ github.event.inputs.source }}"
TARGET_BRANCH="${{ github.event.inputs.target }}"
SYNC_BRANCH=$(echo "${{ steps.merge.outputs.branch }}")
gh pr create \
--title "Sync ${SOURCE_BRANCH} into ${TARGET_BRANCH}" \
--body ":robot: This is an automated PR" \
--base "${{ github.event.inputs.target }}" \
--head "${SYNC_BRANCH}"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
odh-kf-notebook-controller-image=quay.io/opendatahub/kubeflow-notebook-controller:main-363bcdb
odh-kf-notebook-controller-image=quay.io/opendatahub/kubeflow-notebook-controller:main
4 changes: 2 additions & 2 deletions components/notebook-controller/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ var _ = BeforeSuite(func() {
ErrorIfCRDPathMissing: true,
}

cfg, err := testEnv.Start()
var err error
cfg, err = testEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

Expand Down Expand Up @@ -91,7 +92,6 @@ var _ = BeforeSuite(func() {
Expect(err).ToNot(HaveOccurred(), "failed to run manager")
}()

k8sClient = k8sManager.GetClient()
Expect(k8sClient).ToNot(BeNil())

}, 60)
Expand Down
19 changes: 8 additions & 11 deletions components/odh-notebook-controller/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

include makefile-vars.mk

# Image URL to use all building/pushing image targets
IMG ?= quay.io/opendatahub/odh-notebook-controller
TAG ?= $(shell git describe --tags --always)

KF_IMG ?= quay.io/opendatahub/kubeflow-notebook-controller
KF_TAG ?= main-363bcdb
KF_TAG ?= $(KF_TAG)

CONTAINER_ENGINE ?= podman

Expand Down Expand Up @@ -132,16 +134,13 @@ endif
setup-kf: kustomize ## Replace Kustomize manifests with your environment configuration.
sed -i'' -e 's,namespace: .*,namespace: '"${K8S_NAMESPACE}"',' \
../notebook-controller/config/overlays/openshift/kustomization.yaml
sed -i'' -e 's,newName: .*,newName: '"${KF_IMG}"',' \
../notebook-controller/config/overlays/openshift/kustomization.yaml
sed -i'' -e 's,newTag: .*,newTag: '"${KF_TAG}"',' \
../notebook-controller/config/overlays/openshift/kustomization.yaml
sed -i'' -e "s,odh-kf-notebook-controller-image=.*,odh-kf-notebook-controller-image=${KF_IMG}:${KF_TAG}," \
../notebook-controller/config/overlays/openshift/params.env

.PHONY: setup
setup: manifests kustomize ## Replace Kustomize manifests with your environment configuration.
sed -i'' -e 's,namespace: .*,namespace: '"${K8S_NAMESPACE}"',' ./config/default/kustomization.yaml
sed -i'' -e 's,newName: .*,newName: '"${IMG}"',' ./config/base/kustomization.yaml
sed -i'' -e 's,newTag: .*,newTag: '"${TAG}"',' ./config/base/kustomization.yaml
sed -i'' -e "s,odh-notebook-controller-image=.*,odh-notebook-controller-image=${IMG}:${TAG}," ./config/base/params.env

.PHONY: setup-service-mesh
setup-service-mesh: kustomize ## Replace Kustomize manifests with your environment configuration.
Expand All @@ -151,10 +150,8 @@ setup-service-mesh: kustomize ## Replace Kustomize manifests with your environme
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e 's,ISTIO_GATEWAY=.*,ISTIO_GATEWAY='"${K8S_NAMESPACE}/odh-gateway"',' \
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e 's,newName: .*,newName: '"${KF_IMG}"',' \
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e 's,newTag: .*,newTag: '"${KF_TAG}"',' \
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e "s,odh-kf-notebook-controller-image=.*,odh-kf-notebook-controller-image=${KF_IMG}:${KF_TAG}," \
../notebook-controller/config/overlays/openshift/params.env
sed -i'' -e 's,host: .*,host: opendatahub.'"$(shell kubectl get ingress.config.openshift.io cluster -o 'jsonpath={.spec.domain}')"',' \
../notebook-controller/config/overlays/standalone-service-mesh/gateway-route.yaml

Expand Down
15 changes: 15 additions & 0 deletions components/odh-notebook-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ Run the following command to execute them:
make test
```

Useful options for running tests (that are already included in the above `make` command) are

| Option | Description |
|----------------------------|-----------------------------------------------------------------------------------------------|
| KUBEBUILDER_ASSETS | Environment variable that specifies path to where Kubebuilder has downloaded envtest binaries |
| -ginkgo.v -ginkgo.progress | Enables verbose output from Ginkgo |
| -test.v | Enables verbose output from Go tests (*testing.T) |

The following environment variables are used to enable additional debug options for the tests

| Environment variable | Description |
|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| DEBUG_WRITE_KUBECONFIG | Writes a Kubeconfig file to disk. It can be used with `kubectl` or `k9s` to examine the envtest cluster when test is paused on a breakpoint. |
| DEBUG_WRITE_AUDITLOG | Writes kube-apiserver auditlogs to disk. The config is in `envtest-audit-policy.yaml`, set the namespace of interest there. |

### Run locally

Install the `notebooks.kubeflow.org` CRD from the [Kubeflow notebook
Expand Down
2 changes: 1 addition & 1 deletion components/odh-notebook-controller/config/base/params.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
odh-notebook-controller-image=quay.io/opendatahub/odh-notebook-controller:main-363bcdb
odh-notebook-controller-image=quay.io/opendatahub/odh-notebook-controller:main
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ func (r *OpenshiftNotebookReconciler) CreateNotebookCertConfigMap(notebook *nbv1
for _, certFile := range configMapFileNames[configMapName] {

certData, ok := configMap.Data[certFile]
// RHOAIENG-15743: opendatahub-operator#1339 started adding '\n' unconditionally, which
// is breaking our `== ""` checks below. Trim the certData again.
certData = strings.TrimSpace(certData)
// If ca-bundle.crt is not found in the ConfigMap odh-trusted-ca-bundle
// no need to create the workbench-trusted-ca-bundle, as it is created
// by annotation inject-ca-bundle: "true"
Expand Down
Loading

0 comments on commit de53637

Please sign in to comment.