[Security] Remove orphaned unmaintained Temporal component (#3252)

Signed-off-by: Bernd Verst <github@bernd.dev>
This commit is contained in:
Bernd Verst 2023-11-28 18:36:33 -08:00 committed by GitHub
parent 9095b0e7e7
commit 15fa6d186f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 2 additions and 2415 deletions

View File

@ -1,39 +0,0 @@
Use `docker.yaml` file to override the default dynamic config value (they are specified
when creating the service config).
Each key can have zero or more values and each value can have zero or more
constraints. There are only three types of constraint:
1. `namespace`: `string`
2. `taskQueueName`: `string`
3. `taskType`: `int` (`1`:`Workflow`, `2`:`Activity`)
A value will be selected and returned if all its has exactly the same constraints
as the ones specified in query filters (including the number of constraints).
Please use the following format:
```
testGetBoolPropertyKey:
- value: false
- value: true
constraints:
namespace: "global-samples-namespace"
- value: false
constraints:
namespace: "samples-namespace"
testGetDurationPropertyKey:
- value: "1m"
constraints:
namespace: "samples-namespace"
taskQueueName: "longIdleTimeTaskqueue"
testGetFloat64PropertyKey:
- value: 12.0
constraints:
namespace: "samples-namespace"
testGetMapPropertyKey:
- value:
key1: 1
key2: "value 2"
key3:
- false
- key4: true
key5: 2.0
```

View File

@ -1,3 +0,0 @@
system.forceSearchAttributesCacheRefreshOnRead:
- value: true # Dev setup only. Please don't turn this on in production.
constraints: {}

View File

@ -1,6 +0,0 @@
limit.maxIDLength:
- value: 255
constraints: {}
system.forceSearchAttributesCacheRefreshOnRead:
- value: true # Dev setup only. Please don't turn this on in production.
constraints: {}

View File

@ -1,20 +0,0 @@
# The base go-image
FROM golang:1.18-alpine
# Create a directory for the app
RUN mkdir /app
# Copy all files from the current directory to the app directory
COPY . /app
# Set working directory
WORKDIR /app
RUN go get
# Run command as described:
# go build will build an executable file named server in the current directory
RUN go build -o server .
# Run the server executable
CMD [ "/app/server" ]

View File

@ -1,35 +0,0 @@
module github/dapr/workflow/worker
go 1.20
require (
github.com/zouyx/agollo/v3 v3.4.5
go.temporal.io/sdk v1.21.1
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/status v1.1.1 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/testify v1.8.2 // indirect
go.temporal.io/api v1.18.1 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

File diff suppressed because it is too large Load Diff

View File

@ -1,91 +0,0 @@
/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"context"
"time"
"github.com/zouyx/agollo/v3/component/log"
"go.temporal.io/sdk/activity"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/worker"
"go.temporal.io/sdk/workflow"
)
func main() {
// Sleep for a bit so the docker container can spin up
time.Sleep(30 * time.Second)
TaskQueueString := "TestTaskQueue"
// construct client here
cOpt := client.Options{}
cOpt.HostPort = "temporal:7233"
cOpt.Identity = "TemporalTestClient"
// Create the workflow client
clientTwo, err := client.Dial(cOpt)
if err != nil {
log.Error("Unable to create client.")
return
}
wOpt := worker.Options{}
// Make default options for task q and worker options and workflow options
w := worker.New(clientTwo, TaskQueueString, wOpt)
// Register workflows and activities
w.RegisterWorkflow(TestWorkflow)
w.RegisterActivity(ExampleActivity)
err = w.Start()
if err != nil {
log.Error("Unable to start worker.")
return
}
w.Run(worker.InterruptCh())
}
func TestWorkflow(ctx workflow.Context, runtimeSeconds int) error {
options := workflow.ActivityOptions{
TaskQueue: "TestTaskQueue",
ScheduleToCloseTimeout: time.Second * 60,
ScheduleToStartTimeout: time.Second * 60,
StartToCloseTimeout: time.Second * 60,
HeartbeatTimeout: time.Second * 5,
WaitForCancellation: false,
}
ctx = workflow.WithActivityOptions(ctx, options)
err := workflow.ExecuteActivity(ctx, ExampleActivity, runtimeSeconds).Get(ctx, nil)
if err != nil {
log.Error("Unable to execute activity.")
return err
}
return nil
}
func ExampleActivity(ctx context.Context, runtimeSeconds int) error {
counter := 0
for i := 0; i <= runtimeSeconds; i++ {
select {
case <-time.After(1 * time.Second):
counter++
activity.RecordHeartbeat(ctx, "")
case <-ctx.Done():
return nil
}
}
return nil
}

View File

@ -1,40 +0,0 @@
version: "3.5"
services:
worker:
build: ./conformance/temporal/worker
networks:
- temporal-network
depends_on:
- temporal
postgresql:
container_name: temporal-postgresql
environment:
POSTGRES_PASSWORD: temporal
POSTGRES_USER: temporal
image: postgres:13
networks:
- temporal-network
ports:
- 5432:5432
temporal:
container_name: temporal
depends_on:
- postgresql
environment:
- DB=postgresql
- DB_PORT=5432
- POSTGRES_USER=temporal
- POSTGRES_PWD=temporal
- POSTGRES_SEEDS=postgresql
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development-sql.yaml
image: temporalio/auto-setup:1.17.1
networks:
- temporal-network
ports:
- 7233:7233
volumes:
- ./conformance/temporal/server/dynamicconfig:/etc/temporal/config/dynamicconfig
networks:
temporal-network:
driver: bridge
name: temporal-network

View File

@ -743,10 +743,6 @@ const components = {
requireGCPCredentials: true,
certificationSetup: 'certification-state.gcp.firestore-setup.sh',
},
'workflows.temporal': {
conformance: true,
conformanceSetup: 'docker-compose.sh temporal',
},
}
/**

9
go.mod
View File

@ -109,8 +109,6 @@ require (
github.com/xdg-go/scram v1.1.2
go.etcd.io/etcd/client/v3 v3.5.9
go.mongodb.org/mongo-driver v1.12.1
go.temporal.io/api v1.18.1
go.temporal.io/sdk v1.21.1
go.uber.org/multierr v1.11.0
go.uber.org/ratelimit v0.3.0
golang.org/x/crypto v0.14.0
@ -199,7 +197,6 @@ require (
github.com/eapache/queue v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gavv/httpexpect v2.0.0+incompatible // indirect
@ -226,9 +223,7 @@ require (
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/gogap/errors v0.0.0-20200228125012-531a6449b28c // indirect
github.com/gogap/stack v0.0.0-20150131034635-fef68dddd4f8 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/status v1.1.1 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
@ -246,7 +241,7 @@ require (
github.com/google/s2a-go v0.1.5 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
@ -313,7 +308,6 @@ require (
github.com/oleiade/lane v1.0.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/panjf2000/ants/v2 v2.8.1 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
@ -329,7 +323,6 @@ require (
github.com/prometheus/statsd_exporter v0.22.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rs/zerolog v1.28.0 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect

630
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: temporal
spec:
type: workflows.temporal
version: v1
metadata:
- name: Identity
value: TemporalTestClient
- name: HostPort
value: localhost:7233

View File

@ -1,5 +1,3 @@
# Supported additional operations: (none)
componentType: workflows
components:
- component: temporal
operations: []

View File

@ -24,7 +24,6 @@ import (
conf_workflows "github.com/dapr/components-contrib/tests/conformance/workflows"
"github.com/dapr/components-contrib/workflows"
wf_temporal "github.com/dapr/components-contrib/workflows/temporal"
)
func TestWorkflowsConformance(t *testing.T) {
@ -53,8 +52,6 @@ func TestWorkflowsConformance(t *testing.T) {
func loadWorkflow(name string) workflows.Workflow {
switch name {
case "temporal":
return wf_temporal.NewTemporalWorkflow(testLogger)
default:
return nil
}

View File

@ -6,10 +6,6 @@ A workflow is custom application logic that consists of a set of tasks and or st
A compliant workflow needs to implement the `Workflow` interface included in the [`workflow.go`](workflow.go) file.
## Using Temporal
When using temporal as the workflow, the task queue must be provided as an Option in the start request struct with the key: `task_queue`
## Associated Information
The following link to the workflow proposal will provide more information on this feature area: https://github.com/dapr/dapr/issues/4576
The following link to the workflow proposal will provide more information on this feature area: https://github.com/dapr/dapr/issues/4576

View File

@ -1,212 +0,0 @@
/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package temporal
import (
"context"
"encoding/json"
"errors"
"fmt"
"reflect"
"time"
"go.temporal.io/api/enums/v1"
"go.temporal.io/sdk/client"
"github.com/dapr/components-contrib/metadata"
"github.com/dapr/components-contrib/workflows"
"github.com/dapr/kit/logger"
kitmd "github.com/dapr/kit/metadata"
)
type TemporalWF struct {
client client.Client
logger logger.Logger
}
type temporalMetadata struct {
Identity string `json:"identity" mapstructure:"identity"`
HostPort string `json:"hostport" mapstructure:"hostport"`
Namespace string `json:"namespace" mapstructure:"namespace"`
}
// NewTemporalWorkflow returns a new workflow.
func NewTemporalWorkflow(logger logger.Logger) workflows.Workflow {
s := &TemporalWF{
logger: logger,
}
return s
}
func (c *TemporalWF) Init(metadata workflows.Metadata) error {
c.logger.Debugf("Temporal init start")
m, err := c.parseMetadata(metadata)
if err != nil {
return err
}
cOpt := client.Options{}
if m.HostPort != "" {
cOpt.HostPort = m.HostPort
}
if m.Identity != "" {
cOpt.Identity = m.Identity
}
if m.Namespace != "" {
cOpt.Namespace = m.Namespace
}
// Create the workflow client
newClient, err := client.Dial(cOpt)
if err != nil {
return err
}
c.client = newClient
return nil
}
func (c *TemporalWF) Start(ctx context.Context, req *workflows.StartRequest) (*workflows.StartResponse, error) {
c.logger.Debugf("starting workflow")
if len(req.Options) == 0 {
c.logger.Debugf("no options provided")
return nil, errors.New("no options provided. At the very least, a task queue is needed")
}
if _, ok := req.Options["task_queue"]; !ok {
c.logger.Debugf("no task queue provided")
return nil, errors.New("no task queue provided")
}
taskQ := req.Options["task_queue"]
opt := client.StartWorkflowOptions{ID: req.InstanceID, TaskQueue: taskQ}
var inputArgs interface{}
if err := decodeInputData(req.WorkflowInput, &inputArgs); err != nil {
return nil, fmt.Errorf("error decoding workflow input data: %w", err)
}
run, err := c.client.ExecuteWorkflow(ctx, opt, req.WorkflowName, inputArgs)
if err != nil {
return nil, fmt.Errorf("error executing workflow: %w", err)
}
wfStruct := workflows.StartResponse{InstanceID: run.GetID()}
return &wfStruct, nil
}
func (c *TemporalWF) Terminate(ctx context.Context, req *workflows.TerminateRequest) error {
c.logger.Debugf("terminating workflow")
err := c.client.TerminateWorkflow(ctx, req.InstanceID, "", "")
if err != nil {
return fmt.Errorf("error terminating workflow: %w", err)
}
return nil
}
func (c *TemporalWF) Get(ctx context.Context, req *workflows.GetRequest) (*workflows.StateResponse, error) {
c.logger.Debugf("getting workflow data")
resp, err := c.client.DescribeWorkflowExecution(ctx, req.InstanceID, "")
if err != nil {
return nil, err
}
var createdAtTime time.Time
if resp.WorkflowExecutionInfo.StartTime != nil {
createdAtTime = *resp.WorkflowExecutionInfo.StartTime
}
// Build the output struct
outputStruct := workflows.StateResponse{
Workflow: &workflows.WorkflowState{
InstanceID: req.InstanceID,
CreatedAt: createdAtTime,
LastUpdatedAt: createdAtTime,
RuntimeStatus: lookupStatus(resp.WorkflowExecutionInfo.Status),
Properties: map[string]string{
"task_queue": resp.WorkflowExecutionInfo.GetTaskQueue(),
},
},
}
return &outputStruct, nil
}
func (c *TemporalWF) RaiseEvent(ctx context.Context, req *workflows.RaiseEventRequest) error {
var decodedEventData interface{}
if err := decodeInputData(req.EventData, &decodedEventData); err != nil {
return fmt.Errorf("error decoding workflow event data: %w", err)
}
return c.client.SignalWorkflow(ctx, req.InstanceID, "", req.EventName, decodedEventData)
}
func (c *TemporalWF) Purge(ctx context.Context, req *workflows.PurgeRequest) error {
// Unimplemented
return nil
}
func (c *TemporalWF) Close() {
c.client.Close()
}
func (c *TemporalWF) Pause(ctx context.Context, req *workflows.PauseRequest) error {
return workflows.ErrNotImplemented
}
func (c *TemporalWF) Resume(ctx context.Context, req *workflows.ResumeRequest) error {
return workflows.ErrNotImplemented
}
func (c *TemporalWF) parseMetadata(meta workflows.Metadata) (*temporalMetadata, error) {
var m temporalMetadata
err := kitmd.DecodeMetadata(meta.Properties, &m)
return &m, err
}
func (c *TemporalWF) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadataStruct := temporalMetadata{}
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.WorkflowType)
return
}
func lookupStatus(status enums.WorkflowExecutionStatus) string {
switch status {
case 0:
return "Unspecified"
case 1:
return "Running"
case 2:
return "Completed"
case 3:
return "Failed"
case 4:
return "Canceled"
case 5:
return "Terminated"
case 6:
return "ContinuedAsNew"
case 7:
return "TimedOut"
default:
return "status unknown"
}
}
func decodeInputData(data []byte, result interface{}) error {
if len(data) == 0 {
return nil
}
// NOTE: We assume all inputs are JSON values
return json.Unmarshal(data, result)
}