From 3e0652f7c57af8f5502eda77da2d8cb9053a7ed0 Mon Sep 17 00:00:00 2001 From: Sergey Vilgelm Date: Thu, 16 Apr 2026 20:33:08 -0700 Subject: [PATCH 1/2] [V2] Expand contextutils with org, service_name, cluster_id keys and logKeys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shared interceptor chain in Union Cloud sets context values using v1 contextutils.Key types, but v2 services (actions, leaseworker, leasor, events-proxy, executorv2) use the v2 logger which reads v2 contextutils.Key. Both are `type Key string` but are different Go types, so context.Value() lookups fail silently and all context-propagated log fields are missing from v2 service logs. Add OrganizationKey, ServiceNameKey, and ClusterNameKey constants to v2 contextutils, and expand logKeys with ProjectKey, DomainKey, and the three new keys so that GetLogFields() includes them in structured log output. This is one half of the fix — the other half is a context bridge interceptor in the cloud repo that copies v1 values onto v2 keys at request time. Assisted-by: Claude Opus 4.6 (1M context) Signed-off-by: Sergey Vilgelm --- flytestdlib/contextutils/context.go | 8 ++++++++ flytestdlib/contextutils/context_test.go | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/flytestdlib/contextutils/context.go b/flytestdlib/contextutils/context.go index 504ce767e9b..b613acd67a4 100644 --- a/flytestdlib/contextutils/context.go +++ b/flytestdlib/contextutils/context.go @@ -29,6 +29,9 @@ const ( ResourceVersionKey Key = "res_ver" SignalIDKey Key = "signal" RequestIDKey Key = "x-request-id" + OrganizationKey Key = "org" + ServiceNameKey Key = "service_name" + ClusterNameKey Key = "cluster_id" ) func (k Key) String() string { @@ -39,6 +42,7 @@ var logKeys = []Key{ AppNameKey, JobIDKey, NamespaceKey, + OrganizationKey, ExecIDKey, NodeIDKey, WorkflowIDKey, @@ -48,6 +52,10 @@ var logKeys = []Key{ LaunchPlanIDKey, ResourceVersionKey, RequestIDKey, + ProjectKey, + DomainKey, + ServiceNameKey, + ClusterNameKey, } // MetricKeysFromStrings is a convenience method to convert a slice of strings into a slice of Keys diff --git a/flytestdlib/contextutils/context_test.go b/flytestdlib/contextutils/context_test.go index 976a2184bea..89aafe62425 100644 --- a/flytestdlib/contextutils/context_test.go +++ b/flytestdlib/contextutils/context_test.go @@ -112,10 +112,19 @@ func TestWithSignalID(t *testing.T) { func TestGetFields(t *testing.T) { ctx := context.Background() ctx = WithRequestID(WithJobID(WithNamespace(ctx, "ns123"), "job123"), "req123") + ctx = WithProjectDomain(ctx, "proj1", "dev") + ctx = context.WithValue(ctx, OrganizationKey, "org1") + ctx = context.WithValue(ctx, ServiceNameKey, "svc1") + ctx = context.WithValue(ctx, ClusterNameKey, "cluster1") m := GetLogFields(ctx) assert.Equal(t, "ns123", m[NamespaceKey.String()]) assert.Equal(t, "job123", m[JobIDKey.String()]) assert.Equal(t, "req123", m[RequestIDKey.String()]) + assert.Equal(t, "proj1", m[ProjectKey.String()]) + assert.Equal(t, "dev", m[DomainKey.String()]) + assert.Equal(t, "org1", m[OrganizationKey.String()]) + assert.Equal(t, "svc1", m[ServiceNameKey.String()]) + assert.Equal(t, "cluster1", m[ClusterNameKey.String()]) } func TestValues(t *testing.T) { From 1bc5683a9971d069464420941d3b5e646805347b Mon Sep 17 00:00:00 2001 From: Sergey Vilgelm Date: Thu, 16 Apr 2026 21:30:19 -0700 Subject: [PATCH 2/2] make gen Signed-off-by: Sergey Vilgelm --- buf.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buf.lock b/buf.lock index c6b7e8e3b3a..5e8e6b51fb8 100644 --- a/buf.lock +++ b/buf.lock @@ -8,5 +8,5 @@ deps: commit: 62f35d8aed1149c291d606d958a7ce32 digest: b5:d66bf04adc77a0870bdc9328aaf887c7188a36fb02b83a480dc45ef9dc031b4d39fc6e9dc6435120ccf4fe5bfd5c6cb6592533c6c316595571f9a31420ab47fe - name: buf.build/grpc-ecosystem/grpc-gateway - commit: 6467306b4f624747aaf6266762ee7a1c - digest: b5:c2caa61467d992749812c909f93c07e9a667da33c758a7c1973d63136c23b3cafcc079985b12cdf54a10049ed3297418f1eda42cdffdcf34113792dcc3a990af + commit: 4836b6d552304e1bbe47e66a523f0daa + digest: b5:c3fefd4d3dfa9b0478bbb1a4ad87d7b38146e3ce6eff4214e32f2c5834c2e4afc3be218316f0fbd53e925a001c3ed1e2fc99fb76b3121ede642989f0d0d7c71c