Skip to content

Commit

Permalink
Merge branch 'main' of github.com:temporalio/temporal into cg/reset_b…
Browse files Browse the repository at this point in the history
…ug_fix
  • Loading branch information
gow committed Jan 24, 2025
2 parents 621f30d + 0682c47 commit 5dc530c
Show file tree
Hide file tree
Showing 54 changed files with 476 additions and 1,410 deletions.
12 changes: 0 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,6 @@ Please don't use very generic titles like "bug fixes".
All PR titles should start with Upper case and have no dot at the end.
## Go build and run tags
Prior to Server version v1.23.0 our protobuf code generator allowed invalid UTF-8 data to be stored as proto strings. This isn't actually allowed by the proto3 spec, so we need to specify `-tags protolegacy` when building against the server. Our Makefile does this, but if you're using temporal as a library you'll need to enable that yourself.

Example:

```shell
$ go build -tags protolegacy ./cmd/server
```

If you see an error like `grpc: error unmarshalling request: string field contains invalid UTF-8` then you've forgotten to specify this flag.
## Go version update
1. In this repository, update `go` in `go.mod`.
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ PERSISTENCE_DRIVER ?= cassandra
TEMPORAL_DB ?= temporal
VISIBILITY_DB ?= temporal_visibility

# Always use "protolegacy" tag to allow disabling utf-8 validation on proto messages
# during proto library transition.
ALL_BUILD_TAGS := protolegacy,$(BUILD_TAG)
ALL_BUILD_TAGS := $(BUILD_TAG),
ALL_TEST_TAGS := $(ALL_BUILD_TAGS),test_dep,$(TEST_TAG)
BUILD_TAG_FLAG := -tags $(ALL_BUILD_TAGS)
TEST_TAG_FLAG := -tags $(ALL_TEST_TAGS)
Expand Down
5 changes: 3 additions & 2 deletions cmd/tools/gendynamicconfig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ var (
},
{
Name: "NamespaceID",
GoArgs: "namespaceID string",
Expr: "[]Constraints{{NamespaceID: namespaceID}, {}}",
GoArgs: "namespaceID namespace.ID",
Expr: "[]Constraints{{NamespaceID: namespaceID.String()}, {}}",
},
{
Name: "TaskQueue",
Expand Down Expand Up @@ -308,6 +308,7 @@ import (
enumspb "go.temporal.io/api/enums/v1"
enumsspb "go.temporal.io/server/api/enums/v1"
"go.temporal.io/server/common/namespace"
)
const PrecedenceUnknown Precedence = 0
Expand Down
5 changes: 0 additions & 5 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ const (
CriticalLongPollTimeout = time.Second * 20
)

const (
// MaxWorkflowTaskStartToCloseTimeout sets the Max Workflow Task start to close timeout for a Workflow
MaxWorkflowTaskStartToCloseTimeout = 120 * time.Second
)

const (
// Limit for schedule notes field
ScheduleNotesSizeLimit = 1000
Expand Down
5 changes: 3 additions & 2 deletions common/dynamicconfig/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
enumsspb "go.temporal.io/server/api/enums/v1"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/namespace"
)

const (
Expand Down Expand Up @@ -119,7 +120,7 @@ func (s *collectionSuite) TestGetStringPropertyFnFilteredByNamespace() {

func (s *collectionSuite) TestGetStringPropertyFnFilteredByNamespaceID() {
setting := dynamicconfig.NewNamespaceIDStringSetting(testGetStringPropertyFilteredByNamespaceIDKey, "abc", "")
namespaceID := "testNamespaceID"
namespaceID := namespace.ID("testNamespaceID")
value := setting.Get(s.cln)
s.Equal("abc", value(namespaceID))
s.client.SetValue(testGetStringPropertyFilteredByNamespaceIDKey, "efg")
Expand Down Expand Up @@ -158,7 +159,7 @@ func (s *collectionSuite) TestGetBoolProperty() {

func (s *collectionSuite) TestGetBoolPropertyFilteredByNamespaceID() {
setting := dynamicconfig.NewNamespaceIDBoolSetting(testGetBoolPropertyFilteredByNamespaceIDKey, true, "")
namespaceID := "testNamespaceID"
namespaceID := namespace.ID("testNamespaceID")
value := setting.Get(s.cln)
s.Equal(true, value(namespaceID))
s.client.SetValue(testGetBoolPropertyFilteredByNamespaceIDKey, false)
Expand Down
33 changes: 0 additions & 33 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,39 +288,6 @@ operator API calls (highest priority). Should be >0.0 and <= 1.0 (defaults to 20
`How many extra goroutines can be created per root.`,
)

// utf-8 validation

ValidateUTF8SampleRPCRequest = NewGlobalFloatSetting(
"system.validateUTF8.sample.rpcRequest",
0.0,
`Sample rate of utf-8 string validation for rpc requests`,
)
ValidateUTF8SampleRPCResponse = NewGlobalFloatSetting(
"system.validateUTF8.sample.rpcResponse",
0.0,
`Sample rate of utf-8 string validation for rpc responses`,
)
ValidateUTF8SamplePersistence = NewGlobalFloatSetting(
"system.validateUTF8.sample.persistence",
0.0,
`Sample rate of utf-8 string validation for persistence [de]serialization`,
)
ValidateUTF8FailRPCRequest = NewGlobalBoolSetting(
"system.validateUTF8.fail.rpcRequest",
false,
`Whether to fail rpcs on utf-8 string validation errors`,
)
ValidateUTF8FailRPCResponse = NewGlobalBoolSetting(
"system.validateUTF8.fail.rpcResponse",
false,
`Whether to fail rpcs on utf-8 string validation errors`,
)
ValidateUTF8FailPersistence = NewGlobalBoolSetting(
"system.validateUTF8.fail.persistence",
false,
`Whether to fail persistence [de]serialization on utf-8 string validation errors`,
)

// keys for size limit

BlobSizeLimitError = NewNamespaceIntSetting(
Expand Down
17 changes: 9 additions & 8 deletions common/dynamicconfig/setting_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions common/metrics/metric_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,6 @@ var (
"wf_too_many_pending_external_workflow_signals",
WithDescription("The number of Workflow Tasks failed because they would cause the limit on the number of pending signals to external workflows to be exceeded. See https://t.mp/limits for more information."),
)
UTF8ValidationErrors = NewCounterDef(
"utf8_validation_errors",
WithDescription("Number of times the service encountered a proto message with invalid UTF-8 in a string field"),
)

// Frontend
AddSearchAttributesWorkflowSuccessCount = NewCounterDef("add_search_attributes_workflow_success")
Expand Down
60 changes: 41 additions & 19 deletions common/namespace/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,70 +26,92 @@ package namespace

import (
namespacepb "go.temporal.io/api/namespace/v1"
"go.temporal.io/server/common/persistence"
persistencespb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/common"
"google.golang.org/protobuf/types/known/durationpb"
)

type mutationFunc func(*persistence.GetNamespaceResponse)
type mutationFunc func(*Namespace)

func (f mutationFunc) apply(ns *persistence.GetNamespaceResponse) {
func (f mutationFunc) apply(ns *Namespace) {
f(ns)
}

// WithActiveCluster assigns the active cluster to a Namespace during a Clone
// operation.
func WithActiveCluster(name string) Mutation {
return mutationFunc(
func(ns *persistence.GetNamespaceResponse) {
ns.Namespace.ReplicationConfig.ActiveClusterName = name
func(ns *Namespace) {
ns.replicationConfig.ActiveClusterName = name
})
}

// WithBadBinary adds a bad binary checksum to a Namespace during a Clone
// operation.
func WithBadBinary(chksum string) Mutation {
return mutationFunc(
func(ns *persistence.GetNamespaceResponse) {
if ns.Namespace.Config.BadBinaries.Binaries == nil {
ns.Namespace.Config.BadBinaries.Binaries = make(map[string]*namespacepb.BadBinaryInfo)
func(ns *Namespace) {
if ns.config.BadBinaries.Binaries == nil {
ns.config.BadBinaries.Binaries = make(map[string]*namespacepb.BadBinaryInfo)
}
ns.Namespace.Config.BadBinaries.Binaries[chksum] =
ns.config.BadBinaries.Binaries[chksum] =
&namespacepb.BadBinaryInfo{}
})
}

// WithID assigns the ID to a Namespace during a Clone operation.
func WithID(id string) Mutation {
return mutationFunc(
func(ns *persistence.GetNamespaceResponse) {
ns.Namespace.Info.Id = id
func(ns *Namespace) {
ns.info.Id = id
})
}

// WithGlobalFlag sets whether or not this Namespace is global.
func WithGlobalFlag(b bool) Mutation {
return mutationFunc(
func(ns *persistence.GetNamespaceResponse) {
ns.IsGlobalNamespace = b
func(ns *Namespace) {
ns.isGlobalNamespace = b
})
}

// WithNotificationVersion assigns a notification version to the Namespace.
func WithNotificationVersion(v int64) Mutation {
return mutationFunc(
func(ns *Namespace) {
ns.notificationVersion = v
})
}

// WithRetention assigns the retention duration to a Namespace during a Clone
// operation.
func WithRetention(dur *durationpb.Duration) Mutation {
return mutationFunc(
func(ns *persistence.GetNamespaceResponse) {
ns.Namespace.Config.Retention = dur
func(ns *Namespace) {
ns.config.Retention = dur
})
}

// WithData adds a key-value pair to a Namespace during a Clone operation.
func WithData(key, value string) Mutation {
return mutationFunc(
func(ns *persistence.GetNamespaceResponse) {
if ns.Namespace.Info.Data == nil {
ns.Namespace.Info.Data = make(map[string]string)
func(ns *Namespace) {
if ns.info.Data == nil {
ns.info.Data = make(map[string]string)
}
ns.info.Data[key] = value
})
}

func WithPretendLocalNamespace(localClusterName string) Mutation {
return mutationFunc(
func(ns *Namespace) {
ns.isGlobalNamespace = false
ns.replicationConfig = &persistencespb.NamespaceReplicationConfig{
ActiveClusterName: localClusterName,
Clusters: []string{localClusterName},
}
ns.Namespace.Info.Data[key] = value
ns.failoverVersion = common.EmptyVersion
})

}
Loading

0 comments on commit 5dc530c

Please sign in to comment.