Skip to content
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
8 changes: 8 additions & 0 deletions .github/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ linters:
enable:
- errcheck
- importas
- depguard
- revive
- staticcheck
- govet
Expand All @@ -35,6 +36,13 @@ linters:
msg: "Please use require.Eventually or assert.Eventually instead unless you've no other option"
- pattern: panic
msg: "Please avoid using panic in application code"
depguard:
rules:
main:
list-mode: lax
deny:
- pkg: github.com/pborman/uuid
desc: "Importing github.com/pborman/uuid is disallowed; use github.com/google/uuid instead"
importas:
# Enforce the aliases below.
no-unaliased: true
Expand Down
4 changes: 2 additions & 2 deletions chasm/lib/scheduler/backfiller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scheduler
import (
"time"

"github.com/pborman/uuid"
"github.com/google/uuid"
schedulespb "go.temporal.io/server/api/schedule/v1"
"go.temporal.io/server/chasm"
"go.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1"
Expand Down Expand Up @@ -33,7 +33,7 @@ func newBackfiller(
ctx chasm.MutableContext,
scheduler *Scheduler,
) *Backfiller {
id := uuid.New()
id := uuid.NewString()
backfiller := &Backfiller{
BackfillerState: &schedulerpb.BackfillerState{
BackfillId: id,
Expand Down
6 changes: 3 additions & 3 deletions common/checksum/crc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
commonpb "go.temporal.io/api/common/v1"
workflowpb "go.temporal.io/api/workflow/v1"
Expand All @@ -21,8 +21,8 @@ func TestCRC32OverProto(t *testing.T) {
// different set of serialized bytes
obj := &workflowpb.WorkflowExecutionInfo{
Execution: &commonpb.WorkflowExecution{
WorkflowId: uuid.New(),
RunId: uuid.New(),
WorkflowId: uuid.NewString(),
RunId: uuid.NewString(),
},
StartTime: timestamppb.New(time.Now().UTC()),
HistoryLength: 550,
Expand Down
38 changes: 19 additions & 19 deletions common/cluster/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
persistencespb "go.temporal.io/server/api/persistence/v1"
Expand Down Expand Up @@ -51,29 +51,29 @@ func (s *metadataSuite) SetupTest() {

s.isGlobalNamespaceEnabled = true
s.failoverVersionIncrement = 100
s.clusterName = uuid.New()
s.secondClusterName = uuid.New()
s.thirdClusterName = uuid.New()
s.clusterName = uuid.NewString()
s.secondClusterName = uuid.NewString()
s.thirdClusterName = uuid.NewString()

clusterInfo := map[string]ClusterInformation{
s.clusterName: {
Enabled: true,
InitialFailoverVersion: int64(1),
RPCAddress: uuid.New(),
RPCAddress: uuid.NewString(),
ShardCount: 1,
version: 1,
},
s.secondClusterName: {
Enabled: true,
InitialFailoverVersion: int64(4),
RPCAddress: uuid.New(),
RPCAddress: uuid.NewString(),
ShardCount: 2,
version: 1,
},
s.thirdClusterName: {
Enabled: true,
InitialFailoverVersion: int64(5),
RPCAddress: uuid.New(),
RPCAddress: uuid.NewString(),
ShardCount: 1,
version: 1,
},
Expand Down Expand Up @@ -135,7 +135,7 @@ func (s *metadataSuite) Test_RegisterMetadataChangeCallback() {
}

func (s *metadataSuite) Test_RefreshClusterMetadata_Success() {
id := uuid.New()
id := uuid.NewString()
s.metadata.clusterChangeCallback[id] = func(oldClusterMetadata map[string]*ClusterInformation, newClusterMetadata map[string]*ClusterInformation) {
oldMetadata, ok := oldClusterMetadata[id]
s.True(ok)
Expand Down Expand Up @@ -169,8 +169,8 @@ func (s *metadataSuite) Test_RefreshClusterMetadata_Success() {
IsConnectionEnabled: true,
InitialFailoverVersion: 1,
HistoryShardCount: 1,
ClusterAddress: uuid.New(),
HttpAddress: uuid.New(),
ClusterAddress: uuid.NewString(),
HttpAddress: uuid.NewString(),
},
Version: 1,
},
Expand All @@ -181,8 +181,8 @@ func (s *metadataSuite) Test_RefreshClusterMetadata_Success() {
IsConnectionEnabled: true,
InitialFailoverVersion: 1,
HistoryShardCount: 1,
ClusterAddress: uuid.New(),
HttpAddress: uuid.New(),
ClusterAddress: uuid.NewString(),
HttpAddress: uuid.NewString(),
Tags: map[string]string{"test": "test"},
},
Version: 2,
Expand All @@ -194,8 +194,8 @@ func (s *metadataSuite) Test_RefreshClusterMetadata_Success() {
IsConnectionEnabled: true,
InitialFailoverVersion: 2,
HistoryShardCount: 2,
ClusterAddress: uuid.New(),
HttpAddress: uuid.New(),
ClusterAddress: uuid.NewString(),
HttpAddress: uuid.NewString(),
Tags: map[string]string{"test": "test"},
},
Version: 2,
Expand All @@ -211,7 +211,7 @@ func (s *metadataSuite) Test_RefreshClusterMetadata_Success() {

func (s *metadataSuite) Test_ListAllClusterMetadataFromDB_Success() {
nextPageSizeToken := []byte{1}
newClusterName := uuid.New()
newClusterName := uuid.NewString()
s.mockClusterMetadataStore.EXPECT().ListClusterMetadata(gomock.Any(), &persistence.ListClusterMetadataRequest{
PageSize: defaultClusterMetadataPageSize,
NextPageToken: nil,
Expand All @@ -224,8 +224,8 @@ func (s *metadataSuite) Test_ListAllClusterMetadataFromDB_Success() {
IsConnectionEnabled: true,
InitialFailoverVersion: 1,
HistoryShardCount: 1,
ClusterAddress: uuid.New(),
HttpAddress: uuid.New(),
ClusterAddress: uuid.NewString(),
HttpAddress: uuid.NewString(),
},
Version: 1,
},
Expand All @@ -244,8 +244,8 @@ func (s *metadataSuite) Test_ListAllClusterMetadataFromDB_Success() {
IsConnectionEnabled: true,
InitialFailoverVersion: 2,
HistoryShardCount: 2,
ClusterAddress: uuid.New(),
HttpAddress: uuid.New(),
ClusterAddress: uuid.NewString(),
HttpAddress: uuid.NewString(),
},
Version: 2,
},
Expand Down
14 changes: 7 additions & 7 deletions common/collection/concurrent_tx_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync/atomic"
"testing"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -55,7 +55,7 @@ func (s *ConcurrentTxMapSuite) TestLen() {

func (s *ConcurrentTxMapSuite) TestGetAndDo() {
testMap := NewShardedConcurrentTxMap(1, UUIDHashCode)
key := uuid.New()
key := uuid.NewString()
var value intType
fnApplied := false

Expand Down Expand Up @@ -86,7 +86,7 @@ func (s *ConcurrentTxMapSuite) TestGetAndDo() {

func (s *ConcurrentTxMapSuite) TestPutOrDo() {
testMap := NewShardedConcurrentTxMap(1, UUIDHashCode)
key := uuid.New()
key := uuid.NewString()
var value intType
fnApplied := false

Expand Down Expand Up @@ -117,7 +117,7 @@ func (s *ConcurrentTxMapSuite) TestPutOrDo() {

func (s *ConcurrentTxMapSuite) TestRemoveIf() {
testMap := NewShardedConcurrentTxMap(1, UUIDHashCode)
key := uuid.New()
key := uuid.NewString()
value := intType(1)
testMap.Put(key, &value)

Expand All @@ -142,7 +142,7 @@ func (s *ConcurrentTxMapSuite) TestGetAfterPut() {
testMap := NewShardedConcurrentTxMap(1, UUIDHashCode)

for i := 0; i < 1024; i++ {
key := uuid.New()
key := uuid.NewString()
countMap[key] = 0
testMap.Put(key, boolType(true))
}
Expand Down Expand Up @@ -175,7 +175,7 @@ func (s *ConcurrentTxMapSuite) TestGetAfterPut() {

func (s *ConcurrentTxMapSuite) TestPutIfNotExist() {
testMap := NewShardedConcurrentTxMap(1, UUIDHashCode)
key := uuid.New()
key := uuid.NewString()
ok := testMap.PutIfNotExist(key, boolType(true))
s.True(ok, "PutIfNotExist failed to insert item")
ok = testMap.PutIfNotExist(key, boolType(true))
Expand All @@ -186,7 +186,7 @@ func (s *ConcurrentTxMapSuite) TestMapConcurrency() {
nKeys := 1024
keys := make([]string, nKeys)
for i := 0; i < nKeys; i++ {
keys[i] = uuid.New()
keys[i] = uuid.NewString()
}

var total int32
Expand Down
23 changes: 16 additions & 7 deletions common/membership/ringpop/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
"time"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/temporalio/ringpop-go"
"github.com/temporalio/ringpop-go/discovery/statichosts"
"github.com/temporalio/ringpop-go/swim"
Expand Down Expand Up @@ -64,7 +64,7 @@ type monitor struct {
logger log.Logger
metadataManager persistence.ClusterMetadataManager
broadcastHostPortResolver func() (string, error)
hostID uuid.UUID
hostID []byte
initialized *future.FutureImpl[struct{}]
}

Expand All @@ -87,6 +87,8 @@ func newMonitor(
lifecycleCtx,
headers.SystemBackgroundHighCallerInfo,
)
hostID, _ := uuid.New().MarshalBinary()
// MarshalBinary should never error.

rpo := &monitor{
status: common.DaemonStatusInitialized,
Expand All @@ -101,7 +103,7 @@ func newMonitor(
logger: logger,
metadataManager: metadataManager,
broadcastHostPortResolver: broadcastHostPortResolver,
hostID: uuid.NewUUID(),
hostID: hostID,
initialized: future.NewFuture[struct{}](),
maxJoinDuration: maxJoinDuration,
propagationTime: propagationTime,
Expand Down Expand Up @@ -251,10 +253,14 @@ func (rpo *monitor) upsertMyMembership(
err := rpo.metadataManager.UpsertClusterMembership(ctx, request)

if err == nil {
hostID, err := uuid.FromBytes(request.HostID)
if err != nil {
return err
}
rpo.logger.Debug("Membership heartbeat upserted successfully",
tag.Address(request.RPCAddress.String()),
tag.Port(int(request.RPCPort)),
tag.HostID(request.HostID.String()))
tag.HostID(hostID.String()))
}

return err
Expand Down Expand Up @@ -313,10 +319,14 @@ func (rpo *monitor) startHeartbeat(broadcastHostport string) error {
// read side by filtering on the last time a heartbeat was seen.
err = rpo.upsertMyMembership(rpo.lifecycleCtx, req)
if err == nil {
hostID, err := uuid.FromBytes(rpo.hostID)
if err != nil {
return err
}
rpo.logger.Info("Membership heartbeat upserted successfully",
tag.Address(broadcastAddress.String()),
tag.Port(int(broadcastPort)),
tag.HostID(rpo.hostID.String()))
tag.HostID(hostID.String()))

rpo.startHeartbeatUpsertLoop(req)
}
Expand Down Expand Up @@ -347,11 +357,10 @@ func (rpo *monitor) fetchCurrentBootstrapHostports() ([]string, error) {
for _, host := range resp.ActiveMembers {
set[net.JoinHostPort(host.RPCAddress.String(), convert.Uint16ToString(host.RPCPort))] = struct{}{}
}

nextPageToken = resp.NextPageToken

// Stop iterating once we have either 500 unique ip:port combos or there is no more results.
if nextPageToken == nil || len(set) >= 500 {
if len(nextPageToken) == 0 || len(set) >= 500 {
bootstrapHostPorts := make([]string, 0, len(set))
for k := range set {
bootstrapHostPorts = append(bootstrapHostPorts, k)
Expand Down
12 changes: 8 additions & 4 deletions common/membership/ringpop/test_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/temporalio/ringpop-go"
"github.com/temporalio/tchannel-go"
"go.temporal.io/server/common/config"
Expand Down Expand Up @@ -71,7 +71,7 @@ func newTestCluster(
logger.Error("tchannel listen failed", tag.Error(err))
return nil
}
cluster.hostUUIDs[i] = uuid.New()
cluster.hostUUIDs[i] = uuid.NewString()
cluster.hostAddrs[i], err = buildBroadcastHostPort(cluster.channels[i].PeerInfo(), broadcastAddress)
if err != nil {
logger.Error("Failed to build broadcast hostport", tag.Error(err))
Expand All @@ -91,8 +91,11 @@ func newTestCluster(
logger.Error("unable to split host port", tag.Error(err))
return nil
}
// MarshalBinary never fails for UUIDs
hostID, _ := uuid.New().MarshalBinary()

seedMember := &persistence.ClusterMember{
HostID: uuid.NewUUID(),
HostID: hostID,
RPCAddress: seedAddress,
RPCPort: seedPort,
SessionStart: time.Now().UTC(),
Expand All @@ -104,12 +107,13 @@ func newTestCluster(
func(_ context.Context, _ *persistence.GetClusterMembersRequest) (*persistence.GetClusterMembersResponse, error) {
res := &persistence.GetClusterMembersResponse{ActiveMembers: []*persistence.ClusterMember{seedMember}}

hostID, _ := uuid.New().MarshalBinary()
if firstGetClusterMemberCall {
// The first time GetClusterMembers is invoked, we simulate returning a stale/bad heartbeat.
// All subsequent calls only return the single "good" seed member
// This ensures that we exercise the retry path in bootstrap properly.
badSeedMember := &persistence.ClusterMember{
HostID: uuid.NewUUID(),
HostID: hostID,
RPCAddress: seedAddress,
RPCPort: seedPort + 1,
SessionStart: time.Now().UTC(),
Expand Down
4 changes: 2 additions & 2 deletions common/metrics/tally_metrics_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/uber-go/tally/v4"
)
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestTallyScope(t *testing.T) {
assert.EqualValues(t, map[time.Duration]int64(nil), histograms["test.transmission+"].Durations())
assert.EqualValues(t, map[string]string{}, histograms["test.transmission+"].Tags())

newTaggedHandler := mp.WithTags(NamespaceTag(uuid.New()))
newTaggedHandler := mp.WithTags(NamespaceTag(uuid.NewString()))
recordTallyMetrics(newTaggedHandler)
snap = scope.Snapshot()
counters = snap.Counters()
Expand Down
Loading
Loading