From 6c18b48b1a1e92212fcc7aa583cb6b9810ce4a1f Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Tue, 26 Nov 2024 08:07:22 -0500 Subject: [PATCH] fix: don't assume uncached.Get works in the invoker The uncached.Get works when calling the invoker from a controller, but not when calling from the API. This change also includes some generated changes that were left out of a previous change. Signed-off-by: Donnie Adams --- apiclient/types/zz_generated.deepcopy.go | 10 ++++ pkg/invoke/invoker.go | 7 ++- .../openapi/generated/openapi_generated.go | 56 +++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/apiclient/types/zz_generated.deepcopy.go b/apiclient/types/zz_generated.deepcopy.go index e6c496f37..75c2898f3 100644 --- a/apiclient/types/zz_generated.deepcopy.go +++ b/apiclient/types/zz_generated.deepcopy.go @@ -693,6 +693,16 @@ func (in *KnowledgeSourceManifest) DeepCopyInto(out *KnowledgeSourceManifest) { *out = new(bool) **out = **in } + if in.FilePathPrefixInclude != nil { + in, out := &in.FilePathPrefixInclude, &out.FilePathPrefixInclude + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.FilePathPrefixExclude != nil { + in, out := &in.FilePathPrefixExclude, &out.FilePathPrefixExclude + *out = make([]string, len(*in)) + copy(*out, *in) + } in.KnowledgeSourceInput.DeepCopyInto(&out.KnowledgeSourceInput) } diff --git a/pkg/invoke/invoker.go b/pkg/invoke/invoker.go index 52c0c3f96..3f96cda60 100644 --- a/pkg/invoke/invoker.go +++ b/pkg/invoke/invoker.go @@ -383,8 +383,13 @@ func (i *Invoker) createRun(ctx context.Context, c kclient.WithWatch, thread *v1 if !thread.Spec.SystemTask { err = retry.RetryOnConflict(retry.DefaultBackoff, func() error { + // Ensure that, regardless of which client is being used, we get an uncached version of the thread for updating. + // The first uncached.Get method ensures that we get an uncached version when calling this from a controller. + // That will fail when calling this outside a controller, so try a "bare" get in that case. if err := c.Get(ctx, kclient.ObjectKeyFromObject(thread), uncached.Get(thread)); err != nil { - return err + if err := c.Get(ctx, kclient.ObjectKeyFromObject(thread), thread); err != nil { + return err + } } thread.Status.CurrentRunName = run.Name return c.Status().Update(ctx, thread) diff --git a/pkg/storage/openapi/generated/openapi_generated.go b/pkg/storage/openapi/generated/openapi_generated.go index c7c348ed1..399952155 100644 --- a/pkg/storage/openapi/generated/openapi_generated.go +++ b/pkg/storage/openapi/generated/openapi_generated.go @@ -1376,6 +1376,34 @@ func schema_otto8_ai_otto8_apiclient_types_KnowledgeSource(ref common.ReferenceC Format: "", }, }, + "filePathPrefixInclude": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "filePathPrefixExclude": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "onedriveConfig": { SchemaProps: spec.SchemaProps{ Ref: ref("github.com/otto8-ai/otto8/apiclient/types.OneDriveConfig"), @@ -1521,6 +1549,34 @@ func schema_otto8_ai_otto8_apiclient_types_KnowledgeSourceManifest(ref common.Re Format: "", }, }, + "filePathPrefixInclude": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "filePathPrefixExclude": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "onedriveConfig": { SchemaProps: spec.SchemaProps{ Ref: ref("github.com/otto8-ai/otto8/apiclient/types.OneDriveConfig"),