mirror of
https://github.com/paralus/paralus.git
synced 2026-02-14 17:49:51 +00:00
retrying for kratos to be up during init and possible fix for leaderelection issue
This commit is contained in:
2
main.go
2
main.go
@@ -616,7 +616,7 @@ func runEventHandlers(wg *sync.WaitGroup, ctx context.Context) {
|
||||
cs.AddEventHandler(ceh.ClusterHook())
|
||||
|
||||
if !dev {
|
||||
rl, err := leaderelection.NewConfigMapLock("cluster-scheduler", schedulerNamespace, xid.New().String())
|
||||
rl, err := leaderelection.NewConfigMapLock("rcloud-base-config", schedulerNamespace, xid.New().String())
|
||||
if err != nil {
|
||||
_log.Fatalw("unable to create configmap lock", "error", err)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/RafayLabs/rcloud-base/internal/dao"
|
||||
"github.com/RafayLabs/rcloud-base/internal/models"
|
||||
@@ -250,21 +251,6 @@ func main() {
|
||||
log.Fatal("unable to create default group", err)
|
||||
}
|
||||
|
||||
// should we directly interact with kratos and create a user with a password?
|
||||
orgA, err := us.Create(context.Background(), &userv3.User{
|
||||
Metadata: &commonv3.Metadata{Name: *oae, Partner: *partner, Organization: *org, Description: "..."},
|
||||
Spec: &userv3.UserSpec{
|
||||
FirstName: *oafn,
|
||||
LastName: *oaln,
|
||||
Groups: []string{admingrp.Metadata.Name, localUsersGrp.Metadata.Name},
|
||||
ProjectNamespaceRoles: []*userv3.ProjectNamespaceRole{{Role: "ADMIN", Group: &admingrp.Metadata.Name}}},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
log.Fatal("unable to bind user to role", err)
|
||||
}
|
||||
|
||||
//default project with name "default" should be created with default flag true
|
||||
prs.Create(context.Background(), &systemv3.Project{
|
||||
Metadata: &commonv3.Metadata{
|
||||
@@ -278,5 +264,29 @@ func main() {
|
||||
},
|
||||
})
|
||||
|
||||
retry:
|
||||
numOfRetries := 0
|
||||
// should we directly interact with kratos and create a user with a password?
|
||||
orgA, err := us.Create(context.Background(), &userv3.User{
|
||||
Metadata: &commonv3.Metadata{Name: *oae, Partner: *partner, Organization: *org, Description: "..."},
|
||||
Spec: &userv3.UserSpec{
|
||||
FirstName: *oafn,
|
||||
LastName: *oaln,
|
||||
Groups: []string{admingrp.Metadata.Name, localUsersGrp.Metadata.Name},
|
||||
ProjectNamespaceRoles: []*userv3.ProjectNamespaceRole{{Role: "ADMIN", Group: &admingrp.Metadata.Name}}},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
numOfRetries = +1
|
||||
if numOfRetries > 20 {
|
||||
log.Fatal("unable to bind user to role", err)
|
||||
}
|
||||
time.Sleep(10 * time.Second)
|
||||
fmt.Println("retrying ... ")
|
||||
goto retry
|
||||
}
|
||||
|
||||
fmt.Println("Org Admin signup URL: ", orgA.Spec.RecoveryUrl)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user