Skip to content

Commit

Permalink
Dsc creation postpone (opendatahub-io#1041)
Browse files Browse the repository at this point in the history
* main: move DSC creation after DSCIs one

Reorder a bit to keep definition of cleanExistingResourceFunc next
to the Add() call.

Signed-off-by: Yauheni Kaliuta <[email protected]>

* main: convert DSC creation to RunableFunc

DSC creation is checked by the webhook so will not work from the
main before manager starts if webhook is enabled.

The same as DSCI. It also requires CreateWithRetry() for the same
reasons as

e26100e ("upgrade: retry if default DSCI creation fails (opendatahub-io#1008)")

Signed-off-by: Yauheni Kaliuta <[email protected]>

---------

Signed-off-by: Yauheni Kaliuta <[email protected]>
  • Loading branch information
ykaliuta authored Jun 12, 2024
1 parent 8921839 commit 835959a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@ func main() { //nolint:funlen
}
}

// Create default DSC CR for managed RHODS
if platform == cluster.ManagedRhods {
var createDefaultDSCFunc manager.RunnableFunc = func(ctx context.Context) error {
err := upgrade.CreateDefaultDSC(context.TODO(), setupClient)
if err != nil {
setupLog.Error(err, "unable to create default DSC CR by the operator")
}
return err
}
err := mgr.Add(createDefaultDSCFunc)
if err != nil {
setupLog.Error(err, "error scheduling DSC creation")
os.Exit(1)
}
}
// Cleanup resources from previous v2 releases
var cleanExistingResourceFunc manager.RunnableFunc = func(ctx context.Context) error {
if err = upgrade.CleanupExistingResource(ctx, setupClient, platform, dscApplicationsNamespace, dscMonitoringNamespace); err != nil {
Expand All @@ -222,13 +237,6 @@ func main() { //nolint:funlen
return err
}

// Create default DSC CR for managed RHODS
if platform == cluster.ManagedRhods {
if err := upgrade.CreateDefaultDSC(context.TODO(), setupClient); err != nil {
setupLog.Error(err, "unable to create default DSC CR by the operator")
os.Exit(1)
}
}
err = mgr.Add(cleanExistingResourceFunc)
if err != nil {
setupLog.Error(err, "error remove deprecated resources from previous version")
Expand Down
2 changes: 1 addition & 1 deletion pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func CreateDefaultDSC(ctx context.Context, cli client.Client) error {
},
},
}
err := cli.Create(ctx, releaseDataScienceCluster)
err := cluster.CreateWithRetry(ctx, cli, releaseDataScienceCluster, 1) // 1 min timeout
switch {
case err == nil:
fmt.Printf("created DataScienceCluster resource\n")
Expand Down

0 comments on commit 835959a

Please sign in to comment.