Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…b-operator into sync-dashboard
  • Loading branch information
maroroman committed Apr 14, 2023
2 parents 5a00c2b + 621364a commit 0e1f6c3
Show file tree
Hide file tree
Showing 16 changed files with 695 additions and 125 deletions.
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/major-release.md

This file was deleted.

11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/minor-release.md

This file was deleted.

11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/patch-release.md

This file was deleted.

13 changes: 0 additions & 13 deletions .github/ISSUE_TEMPLATE/redeliver_container_image.md

This file was deleted.

5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ VERSION ?= 0.0.1
IMG ?= quay.io/opendatahub/opendatahub-operator:dev-$(VERSION)
IMAGE_BUILDER ?= podman
OPERATOR_NAMESPACE ?= opendatahub-operator-system

CHANNELS="stable,rolling"
DEFAULT_CHANNEL="rolling"
# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
Expand Down Expand Up @@ -239,7 +240,7 @@ endif
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
$(OPM) index add --container-tool $(IMAGE_BUILDER) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)

# Push the catalog image.
.PHONY: catalog-push
Expand Down
3 changes: 2 additions & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=opendatahub-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channels.v1=stable,rolling
LABEL operators.operatorframework.io.bundle.channel.default.v1=rolling
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.24.1
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
Expand Down
308 changes: 283 additions & 25 deletions bundle/manifests/opendatahub-operator.clusterserviceversion.yaml

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions bundle/manifests/opendatahub.io_odhdashboardconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ spec:
type: boolean
disableInfo:
type: boolean
disableModelServing:
type: boolean
disableProjects:
type: boolean
disableSupport:
type: boolean
disableTracking:
Expand All @@ -35,6 +39,8 @@ spec:
type: boolean
enablement:
type: boolean
modelMetricsNamespace:
type: string
type: object
groupsConfig:
properties:
Expand All @@ -46,10 +52,43 @@ spec:
- adminGroups
- allowedGroups
type: object
modelServerSizes:
items:
properties:
name:
type: string
resources:
properties:
limits:
properties:
cpu:
type: string
memory:
type: string
type: object
requests:
properties:
cpu:
type: string
memory:
type: string
type: object
type: object
required:
- name
- resources
type: object
type: array
notebookController:
properties:
enabled:
type: boolean
gpuSetting:
description: Configure how the GPU field works on the Jupyter
tile. One of 'autodetect' (default, fetches for information),
'hidden' (remove the field) or a number-string (eg '5') to specify
a hardcoded 0 to that number options
type: string
notebookNamespace:
type: string
notebookTolerationSettings:
Expand Down
3 changes: 2 additions & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ annotations:
operators.operatorframework.io.bundle.manifests.v1: manifests/
operators.operatorframework.io.bundle.metadata.v1: metadata/
operators.operatorframework.io.bundle.package.v1: opendatahub-operator
operators.operatorframework.io.bundle.channels.v1: alpha
operators.operatorframework.io.bundle.channels.v1: stable,rolling
operators.operatorframework.io.bundle.channel.default.v1: rolling
operators.operatorframework.io.metrics.builder: operator-sdk-v1.24.1
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
type: boolean
disableModelServing:
type: boolean
modelMetricsNamespace:
type: string
groupsConfig:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/opendatahub/opendatahub-operator
newTag: dev-v0.0.1
newTag: dev-0.0.1
358 changes: 336 additions & 22 deletions config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions controllers/kfdef.apps.kubeflow.org/kfdef_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func (r *KfDefReconciler) SetupWithManager(mgr ctrl.Manager) error {
Watches(&source.Kind{Type: &rbacv1.RoleBinding{}}, watchedHandler, builder.WithPredicates(ownedResourcePredicates)).
Watches(&source.Kind{Type: &rbacv1.ClusterRole{}}, watchedHandler, builder.WithPredicates(ownedResourcePredicates)).
Watches(&source.Kind{Type: &rbacv1.ClusterRoleBinding{}}, watchedHandler, builder.WithPredicates(ownedResourcePredicates)).
Watches(&source.Kind{Type: &ofapi.Subscription{}}, watchedHandler, builder.WithPredicates(ownedResourcePredicates)).
Complete(r)

if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions pkg/kfapp/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -1559,16 +1559,18 @@ func GenerateYamlWithOwnerReference(resMap resmap.ResMap, instance *unstructured
},
}

if len(m.GetOwnerReferences()) == 0 {
// Do not add ownerreference to subscription, since it can be created in another namespace
// than the KfDef instance
if len(m.GetOwnerReferences()) == 0 && m.GetKind() != "Subscription" {
m.SetOwnerReferences(owner)
log.Infof("ownerReferences added for resource %v.%v", m.GetName(), m.GetNamespace())
}

out, err := yaml.Marshal(m)
if err != nil {
return nil, err
}

log.Infof("ownerReferences added for resource %v.%v", m.GetName(), m.GetNamespace())
if firstObj {
firstObj = false
} else {
Expand Down
11 changes: 6 additions & 5 deletions tests/e2e/odh_controller_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ func NewTestContext() (*testContext, error) {
testKfDefContextList := []kfDefContext{setupCoreKfdef()}

return &testContext{
cfg: config,
kubeClient: kc,
customClient: custClient,
testNamespace: kfdefTestNamespace,
resourceCreationTimeout: time.Minute * 2,
cfg: config,
kubeClient: kc,
customClient: custClient,
testNamespace: kfdefTestNamespace,
// Set high timeout for CI environment
resourceCreationTimeout: time.Minute * 3,
resourceRetryInterval: time.Second * 10,
ctx: context.TODO(),
testKfDefs: testKfDefContextList,
Expand Down
36 changes: 16 additions & 20 deletions tests/e2e/odh_creation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func creationTestSuite(t *testing.T) {
})
}
})
t.Run("Validate KfDef Annotation is added", func(t *testing.T) {
err = testCtx.testKfDefAnnotation(kfContext)
require.NoError(t, err, "error testing KfDef annotation ")
t.Run("Validate KfDef OwnerReference is added", func(t *testing.T) {
err = testCtx.testKfDefOwnerReference(kfContext)
require.NoError(t, err, "error testing KfDef OwnerReference ")
})
t.Run("Validate Controller Reverts Updates", func(t *testing.T) {
err = testCtx.testUpdateManagedResource(kfContext)
Expand Down Expand Up @@ -120,8 +120,8 @@ func (tc *testContext) testKfDefApplications(kfmeta *metav1.ObjectMeta, appName
return err
}

// This test verifies all resources of an application have the kfdef annotation added by the operator
func (tc *testContext) testKfDefAnnotation(kfContext kfDefContext) error {
// This test verifies all resources of an application have the kfdef ownerReference added by the operator
func (tc *testContext) testKfDefOwnerReference(kfContext kfDefContext) error {
testapp := kfContext.kfSpec.Applications[0].Name

appDeployments, err := tc.kubeClient.AppsV1().Deployments(kfContext.kfObjectMeta.Namespace).List(context.TODO(), metav1.ListOptions{
Expand All @@ -130,12 +130,11 @@ func (tc *testContext) testKfDefAnnotation(kfContext kfDefContext) error {
if err != nil {
return fmt.Errorf("error list application deployments %v", err)
} else {
// test any one deployment for annotation
if len(appDeployments.Items) != 0 && appDeployments.Items[0].Annotations["kfctl.kubeflow.io/kfdef-instance"] !=
kfContext.kfObjectMeta.Name+"."+kfContext.kfObjectMeta.Namespace {
// test any one deployment for ownerreference
if len(appDeployments.Items) != 0 && appDeployments.Items[0].OwnerReferences[0].Kind != "KfDef" {

return fmt.Errorf("expected annotation not found. Got annotation: %v",
appDeployments.Items[0].Annotations["kfctl.kubeflow.io/kfdef-instance"])
return fmt.Errorf("expected ownerreference not found. Got ownereferrence: %v",
appDeployments.Items[0].OwnerReferences)
}
}

Expand All @@ -146,26 +145,23 @@ func (tc *testContext) testKfDefAnnotation(kfContext kfDefContext) error {
return fmt.Errorf("error list application secrets %v", err)
} else {
// test any one secret for annotation
if len(appSecrets.Items) != 0 && appSecrets.Items[0].Annotations["kfctl.kubeflow.io/kfdef-instance"] !=
kfContext.kfObjectMeta.Name+"."+kfContext.kfObjectMeta.Namespace {
if len(appSecrets.Items) != 0 && appSecrets.Items[0].OwnerReferences[0].Kind != "KfDef" {

return fmt.Errorf("expected annotation not found. Got annotation: %v",
appSecrets.Items[0].Annotations["kfctl.kubeflow.io/kfdef-instance"])
return fmt.Errorf("expected ownerreference not found. Got ownereferrence: %v",
appDeployments.Items[0].OwnerReferences)
}
}

appConfigMaps, err := tc.kubeClient.CoreV1().ConfigMaps(kfContext.kfObjectMeta.Namespace).List(context.TODO(), metav1.ListOptions{
LabelSelector: "app=" + testapp,
})
if err != nil {
return fmt.Errorf("error list application secrets %v", err)
return fmt.Errorf("error list application configmaps %v", err)
} else {
// test any one configmap for annotation
if len(appConfigMaps.Items) != 0 && appConfigMaps.Items[0].Annotations["kfctl.kubeflow.io/kfdef-instance"] !=
kfContext.kfObjectMeta.Name+"."+kfContext.kfObjectMeta.Namespace {

return fmt.Errorf("expected annotation not found. Got annotation: %v",
appConfigMaps.Items[0].Annotations["kfctl.kubeflow.io/kfdef-instance"])
if len(appConfigMaps.Items) != 0 && appConfigMaps.Items[0].OwnerReferences[0].Kind != "KfDef" {
return fmt.Errorf("expected ownerreference not found. Got ownereferrence: %v",
appDeployments.Items[0].OwnerReferences)
}
}

Expand Down

0 comments on commit 0e1f6c3

Please sign in to comment.