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

Various bug and performance fixes #1282

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
github.com/mhale/smtpd v0.8.3
github.com/oauth2-proxy/oauth2-proxy/v7 v7.0.0-00010101000000-000000000000
github.com/obot-platform/kinm v0.0.0-20250110042456-3848b881955b
github.com/obot-platform/nah v0.0.0-20241217120500-e9169e4a999f
github.com/obot-platform/kinm v0.0.0-20250116162656-270198b40c6d
github.com/obot-platform/nah v0.0.0-20250116162537-3bafada8cfb4
github.com/obot-platform/namegenerator v0.0.0-20241217121223-fc58bdb7dca2
github.com/obot-platform/obot/apiclient v0.0.0-00010101000000-000000000000
github.com/obot-platform/obot/logger v0.0.0-20241217130503-4004a5c69f32
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,10 @@ github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
github.com/oauth2-proxy/mockoidc v0.0.0-20240214162133-caebfff84d25 h1:9bCMuD3TcnjeqjPT2gSlha4asp8NvgcFRYExCaikCxk=
github.com/oauth2-proxy/mockoidc v0.0.0-20240214162133-caebfff84d25/go.mod h1:eDjgYHYDJbPLBLsyZ6qRaugP0mX8vePOhZ5id1fdzJw=
github.com/obot-platform/kinm v0.0.0-20250110042456-3848b881955b h1:1OzOajUTN+OQcffpFmr11e2NB4sjT/u4mSGYYzUs/D8=
github.com/obot-platform/kinm v0.0.0-20250110042456-3848b881955b/go.mod h1:RzrH0geIlbiTHDGZ8bpCk5k1hwdU9uu3l4zJn9n0pZU=
github.com/obot-platform/nah v0.0.0-20241217120500-e9169e4a999f h1:yyexIHgaPtNrfaPLxDx+xbnibJTKKJK05jDDlIqXC04=
github.com/obot-platform/nah v0.0.0-20241217120500-e9169e4a999f/go.mod h1:KG1jLO9FeYvCPGI0iDqe5oqDqOFLd3/dt/iwuMianmI=
github.com/obot-platform/kinm v0.0.0-20250116162656-270198b40c6d h1:GzMvRkssr4jAa2YvQiv9eXhjuNpaZVab3GajE7+cQ3s=
github.com/obot-platform/kinm v0.0.0-20250116162656-270198b40c6d/go.mod h1:RzrH0geIlbiTHDGZ8bpCk5k1hwdU9uu3l4zJn9n0pZU=
github.com/obot-platform/nah v0.0.0-20250116162537-3bafada8cfb4 h1:T5m+KSIXx0wTL1HdWngu1I6sCWI3tdfcJ+4Ud/vkHu4=
github.com/obot-platform/nah v0.0.0-20250116162537-3bafada8cfb4/go.mod h1:KG1jLO9FeYvCPGI0iDqe5oqDqOFLd3/dt/iwuMianmI=
github.com/obot-platform/namegenerator v0.0.0-20241217121223-fc58bdb7dca2 h1:jiyBM/TYxU6UNVS9ff8Y8n55DOKDYohKkIZjfHpjfTY=
github.com/obot-platform/namegenerator v0.0.0-20241217121223-fc58bdb7dca2/go.mod h1:isbKX6EfvvG/ojjFB2ZLyz27+2xoG3yRmpTSE+ytWEs=
github.com/obot-platform/oauth2-proxy/v7 v7.0.0-20241008204315-265dabe17f43 h1:mlwIf3/uOo0ISweKuyFHhvPzSut4oQeWWpTkzsmTPgE=
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/handlers/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (a *CronJobHandler) Execute(req api.Context) error {

func convertCronJob(cronJob v1.CronJob) types.CronJob {
var nextRunAt *time.Time
if next, err := gronx.NextTick(cronjob.GetSchedule(cronJob), true); err == nil {
if next, err := gronx.NextTick(cronjob.GetSchedule(cronJob), false); err == nil {
nextRunAt = &next
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/handlers/cronjob/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (h *Handler) Run(req router.Request, resp router.Response) error {
lastRun = &cj.CreationTimestamp
}

next, err := gronx.NextTickAfter(GetSchedule(*cj), lastRun.Time, true)
next, err := gronx.NextTickAfter(GetSchedule(*cj), lastRun.Time, false)
if err != nil {
return fmt.Errorf("failed to parse schedule: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/handlers/knowledgesource/reschedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (k *Handler) Reschedule(req router.Request, _ router.Response) error {
return nil
}

tick, err := gronx.NextTickAfter(source.Spec.Manifest.SyncSchedule, source.Status.LastSyncStartTime.Time, true)
tick, err := gronx.NextTickAfter(source.Spec.Manifest.SyncSchedule, source.Status.LastSyncStartTime.Time, false)
if err != nil {
source.Status.Error = fmt.Sprintf("failed to calculate next sync time: %v", err)
source.Status.SyncState = types.KnowledgeSourceStateError
Expand Down
26 changes: 10 additions & 16 deletions pkg/controller/handlers/workspace/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"github.com/gptscript-ai/go-gptscript"
"github.com/obot-platform/nah/pkg/router"
v1 "github.com/obot-platform/obot/pkg/storage/apis/obot.obot.ai/v1"
"github.com/obot-platform/obot/pkg/wait"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kclient "sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -23,23 +21,19 @@ func New(gClient *gptscript.GPTScript, wp string) *Handler {
}
}

func getWorkspaceIDs(ctx context.Context, c kclient.WithWatch, ws *v1.Workspace) (wsIDs []string, _ error) {
func getWorkspaceIDs(ctx context.Context, c kclient.WithWatch, ws *v1.Workspace) ([]string, bool, error) {
var (
wsIDs []string
dependentWS v1.Workspace
)
for _, wsName := range ws.Spec.FromWorkspaceNames {
ws, err := wait.For(ctx, c, &v1.Workspace{
ObjectMeta: metav1.ObjectMeta{
Namespace: ws.Namespace,
Name: wsName,
},
}, func(ws *v1.Workspace) (bool, error) {
return ws.Status.WorkspaceID != "", nil
})
if err != nil {
return nil, err
if err := c.Get(ctx, router.Key(ws.Namespace, wsName), &dependentWS); err != nil || dependentWS.Status.WorkspaceID == "" {
return nil, false, err
}
wsIDs = append(wsIDs, ws.Status.WorkspaceID)
}

return
return wsIDs, true, nil
}

func (a *Handler) CreateWorkspace(req router.Request, _ router.Response) error {
Expand All @@ -49,8 +43,8 @@ func (a *Handler) CreateWorkspace(req router.Request, _ router.Response) error {
}

providerType := a.workspaceProvider
wsIDs, err := getWorkspaceIDs(req.Ctx, req.Client, ws)
if err != nil {
wsIDs, allReady, err := getWorkspaceIDs(req.Ctx, req.Client, ws)
if err != nil || !allReady {
return err
}

Expand Down