Skip to content

Commit

Permalink
main: convert DSC creation to RunableFunc
Browse files Browse the repository at this point in the history
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 (#1008)")

Signed-off-by: Yauheni Kaliuta <[email protected]>
  • Loading branch information
ykaliuta committed Jun 6, 2024
1 parent 6c8923f commit 1ae7cc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,19 @@ func main() { //nolint:funlen

// 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")
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 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 1ae7cc7

Please sign in to comment.