Skip to content

Commit

Permalink
chore: nim tp cleanup should remove api key secret
Browse files Browse the repository at this point in the history
Signed-off-by: Tomer Figenblat <[email protected]>
  • Loading branch information
TomerFi committed Nov 13, 2024
1 parent e808e82 commit 0483894
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,23 @@ func cleanupNimIntegrationTechPreview(ctx context.Context, cli client.Client, ol

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

job := &batchv1.CronJob{}
if err := cli.Get(ctx, types.NamespacedName{Name: nimCronjob, Namespace: applicationNS}, job); err != nil {
if !k8serr.IsNotFound(err) {
logger.V(1).Error(err, "failed to get NIM cronjob "+nimCronjob)
}
} else {
if dErr := cli.Delete(ctx, job); dErr != nil {
logger.Error(dErr, "failed to remove NIM cronjob "+nimCronjob)
errs = multierror.Append(errs, dErr)
} else {
logger.Info("removed NIM cronjob successfully")
}
}

cm := &corev1.ConfigMap{}
if err := cli.Get(ctx, types.NamespacedName{Name: nimConfigMap, Namespace: applicationNS}, cm); err != nil {
Expand All @@ -630,17 +645,17 @@ func cleanupNimIntegrationTechPreview(ctx context.Context, cli client.Client, ol
}
}

job := &batchv1.CronJob{}
if err := cli.Get(ctx, types.NamespacedName{Name: nimCronjob, Namespace: applicationNS}, job); err != nil {
sec := &corev1.Secret{}
if err := cli.Get(ctx, types.NamespacedName{Name: nimAPISec, Namespace: applicationNS}, sec); err != nil {
if !k8serr.IsNotFound(err) {
logger.V(1).Error(err, "failed to get NIM cronjob "+nimCronjob)
logger.V(1).Error(err, "failed to get NIM API key secret "+nimAPISec)
}
} else {
if dErr := cli.Delete(ctx, job); dErr != nil {
logger.Error(dErr, "failed to remove NIM cronjob "+nimCronjob)
if dErr := cli.Delete(ctx, sec); dErr != nil {
logger.Error(dErr, "failed to remove NIM API key secret "+nimAPISec)
errs = multierror.Append(errs, dErr)
} else {
logger.Info("removed NIM cronjob successfully")
logger.V(1).Info("removed NIM API key secret successfully")
}
}
}
Expand Down

0 comments on commit 0483894

Please sign in to comment.