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

[sync]: change from incubation to rhoai + dummy change #1357

Merged
merged 3 commits into from
Nov 11, 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
1 change: 1 addition & 0 deletions config/manager/kustomization.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ resources:

generatorOptions:
disableNameSuffixHash: true

4 changes: 4 additions & 0 deletions pkg/trustedcabundle/trustedcabundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"strconv"
"strings"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -47,6 +48,9 @@ func HasCABundleAnnotationDisabled(ns client.Object) bool {
// or update existing odh-trusted-ca-bundle configmap if already exists with new content of .data.odh-ca-bundle.crt
// this is certificates for the cluster trusted CA Cert Bundle.
func CreateOdhTrustedCABundleConfigMap(ctx context.Context, cli client.Client, namespace string, customCAData string) error {
// Adding newline breaker if user input does not have it
customCAData = strings.TrimSpace(customCAData) + "\n"

// Expected configmap for the given namespace
desiredConfigMap := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Expand Down
38 changes: 38 additions & 0 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/components/workbenches"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster/gvk"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels"
)

type ResourceSpec struct {
Expand Down Expand Up @@ -275,6 +276,12 @@ func CleanupExistingResource(ctx context.Context,
return err
}
}
// remove modelreg proxy container from deployment in ODH
if platform == cluster.OpenDataHub {
if err := removeRBACProxyModelRegistry(ctx, cli, "model-registry-operator", "kube-rbac-proxy", dscApplicationsNamespace); err != nil {
return err
}
}

// to take a reference
toDelete := getDashboardWatsonResources(dscApplicationsNamespace)
Expand Down Expand Up @@ -482,6 +489,37 @@ func updateODCModelRegistry(ctx context.Context, cli client.Client, instanceName
return nil
}

// workaround for RHOAIENG-15328
// TODO: this can be removed from ODH 2.22.
func removeRBACProxyModelRegistry(ctx context.Context, cli client.Client, componentName string, containerName string, applicationNS string) error {
deploymentList := &appsv1.DeploymentList{}
if err := cli.List(ctx, deploymentList, client.InNamespace(applicationNS), client.HasLabels{labels.ODH.Component(componentName)}); err != nil {
return fmt.Errorf("error fetching list of deployments: %w", err)
}

if len(deploymentList.Items) != 1 { // ModelRegistry operator is not deployed
return nil
}
mrDeployment := deploymentList.Items[0]
mrContainerList := mrDeployment.Spec.Template.Spec.Containers
// if only one container in deployment, we are already on newer deployment, no need more action
if len(mrContainerList) == 1 {
return nil
}

ctrl.Log.Info("Upgrade force ModelRegistry to remove container from deployment")
for i, container := range mrContainerList {
if container.Name == containerName {
removeUnusedKubeRbacProxy := []byte(fmt.Sprintf("[{\"op\": \"remove\", \"path\": \"/spec/template/spec/containers/%d\"}]", i))
if err := cli.Patch(ctx, &mrDeployment, client.RawPatch(types.JSONPatchType, removeUnusedKubeRbacProxy)); err != nil {
return fmt.Errorf("error removing ModelRegistry %s container from deployment: %w", containerName, err)
}
break
}
}
return nil
}

func RemoveLabel(ctx context.Context, cli client.Client, objectName string, labelKey string) error {
foundNamespace := &corev1.Namespace{}
if err := cli.Get(ctx, client.ObjectKey{Name: objectName}, foundNamespace); err != nil {
Expand Down
Loading