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] chore: cleanup static-named nim resources for switching to naming convention (#1472) #1474

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
58 changes: 40 additions & 18 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"github.com/hashicorp/go-multierror"
operatorv1 "github.com/openshift/api/operator/v1"
routev1 "github.com/openshift/api/route/v1"
templatev1 "github.com/openshift/api/template/v1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
Expand Down Expand Up @@ -288,8 +289,8 @@
toDelete := getDashboardWatsonResources(dscApplicationsNamespace)
multiErr = multierror.Append(multiErr, deleteResources(ctx, cli, &toDelete))

// cleanup nvidia nim integration remove tech preview
multiErr = multierror.Append(multiErr, cleanupNimIntegrationTechPreview(ctx, cli, oldReleaseVersion, dscApplicationsNamespace))
// cleanup nvidia nim integration
multiErr = multierror.Append(multiErr, cleanupNimIntegration(ctx, cli, oldReleaseVersion, dscApplicationsNamespace))

Check warning on line 293 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L292-L293

Added lines #L292 - L293 were not covered by tests

return multiErr.ErrorOrNil()
}
Expand Down Expand Up @@ -599,34 +600,55 @@
return cluster.Release{}, nil
}

func cleanupNimIntegrationTechPreview(ctx context.Context, cli client.Client, oldRelease cluster.Release, applicationNS string) error {
func cleanupNimIntegration(ctx context.Context, cli client.Client, oldRelease cluster.Release, applicationNS string) error {

Check warning on line 603 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L603

Added line #L603 was not covered by tests
var errs *multierror.Error

if oldRelease.Version.Minor >= 14 && oldRelease.Version.Minor <= 15 {
nimCronjob := "nvidia-nim-periodic-validator"
nimConfigMap := "nvidia-nim-validation-result"
nimAPISec := "nvidia-nim-access"

deleteObjs := []struct {
if oldRelease.Version.Minor >= 14 && oldRelease.Version.Minor <= 16 {
type objForDel struct {

Check warning on line 607 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L606-L607

Added lines #L606 - L607 were not covered by tests
obj client.Object
name, desc string
}{
{
obj: &batchv1.CronJob{},
name: nimCronjob,
desc: "validator CronJob",
},
}

// the following objects created by TP (14-15) and by the first GA (16)
deleteObjs := []objForDel{

Check warning on line 613 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L610-L613

Added lines #L610 - L613 were not covered by tests
{
obj: &corev1.ConfigMap{},
name: nimConfigMap,
name: "nvidia-nim-images-data",

Check warning on line 616 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L616

Added line #L616 was not covered by tests
desc: "data ConfigMap",
},
{
obj: &templatev1.Template{},
name: "nvidia-nim-serving-template",
desc: "runtime Template",
},

Check warning on line 623 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L619-L623

Added lines #L619 - L623 were not covered by tests
{
obj: &corev1.Secret{},
name: nimAPISec,
desc: "API key Secret",
name: "nvidia-nim-image-pull",
desc: "pull Secret",

Check warning on line 627 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L626-L627

Added lines #L626 - L627 were not covered by tests
},
}

// the following objects created by TP (14-15)
if oldRelease.Version.Minor < 16 {
deleteObjs = append(deleteObjs,
objForDel{
obj: &batchv1.CronJob{},
name: "nvidia-nim-periodic-validator",
desc: "validator CronJob",
},
objForDel{
obj: &corev1.ConfigMap{},
name: "nvidia-nim-validation-result",
desc: "validation result ConfigMap",
},
// the api key is also used by GA (16), but cleanup is only required for TP->GA switch
objForDel{
obj: &corev1.Secret{},
name: "nvidia-nim-access",
desc: "API key Secret",
})
}

Check warning on line 650 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L630-L650

Added lines #L630 - L650 were not covered by tests

for _, delObj := range deleteObjs {
if gErr := cli.Get(ctx, types.NamespacedName{Name: delObj.name, Namespace: applicationNS}, delObj.obj); gErr != nil {
if !k8serr.IsNotFound(gErr) {
Expand Down
Loading