Skip to content

Commit d99355b

Browse files
authored
Allow adding a Search Attribute to fail, but warn. (#75)
* Allow adding a Search Attribute to fail, but warn. This allows running Omes against Cloud which does not permit search attributes to be added via the WorkflowService API. Also make cleanup-scenario job IDs unique so that cleanup can be run multiples times on the same namespace.
1 parent 7a8f3d1 commit d99355b

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

cmd/cleanup_scenario.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os/user"
88
"time"
99

10+
"github.com/google/uuid"
1011
"github.com/spf13/cobra"
1112
"github.com/spf13/pflag"
1213
"github.com/temporalio/omes/cmd/cmdoptions"
@@ -68,7 +69,7 @@ func (c *scenarioCleaner) run(ctx context.Context) error {
6869
client := c.clientOptions.MustDial(metrics, c.logger)
6970
defer client.Close()
7071
taskQueue := loadgen.TaskQueueForRun(c.scenario, c.runID)
71-
jobID := "omes-cleanup-" + taskQueue
72+
jobID := "omes-cleanup-" + taskQueue + "-" + uuid.New().String()
7273
username, hostname := "anonymous", "unknown"
7374
if user, err := user.Current(); err == nil {
7475
username = user.Name

scenarios/throughput_stress.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,23 @@ func (t *tpsExecutor) Run(ctx context.Context, info loadgen.ScenarioInfo) error
3434
attribMap := map[string]enums.IndexedValueType{
3535
ThroughputStressScenarioIdSearchAttribute: enums.INDEXED_VALUE_TYPE_KEYWORD,
3636
}
37+
3738
_, err := info.Client.OperatorService().AddSearchAttributes(ctx,
3839
&operatorservice.AddSearchAttributesRequest{
3940
Namespace: info.Namespace,
4041
SearchAttributes: attribMap,
4142
})
42-
var svcErr *serviceerror.AlreadyExists
43-
if !errors.As(err, &svcErr) {
44-
return fmt.Errorf("failed adding search attribute: %w", err)
43+
var deniedErr *serviceerror.PermissionDenied
44+
var alreadyErr *serviceerror.AlreadyExists
45+
46+
if errors.As(err, &deniedErr) {
47+
info.Logger.Warnf("Failed to add Search Attribute %s: %v", ThroughputStressScenarioIdSearchAttribute, err)
48+
} else if !errors.As(err, &alreadyErr) {
49+
info.Logger.Info("Search Attribute %s already exists", ThroughputStressScenarioIdSearchAttribute)
50+
51+
return err
52+
} else {
53+
info.Logger.Info("Search Attribute %s added", ThroughputStressScenarioIdSearchAttribute)
4554
}
4655

4756
// Complain if there are already existing workflows with the provided run id

0 commit comments

Comments
 (0)