Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
  • Loading branch information
ItalyPaleAle committed Jan 4, 2024
1 parent 8027d5c commit 5304c2b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 47 deletions.
6 changes: 6 additions & 0 deletions charts/dapr/charts/dapr_rbac/templates/placement.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if and (eq .Values.global.actors.enabled true) (eq .Values.global.actors.serviceName "placement") }}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand All @@ -7,7 +8,9 @@ metadata:
{{- range $key, $value := .Values.global.k8sLabels }}
{{ $key }}: {{ tpl $value $ }}
{{- end }}
{{- end }}
---
{{- if and (eq .Values.global.actors.enabled true) (eq .Values.global.actors.serviceName "placement") }}
{{- if eq .Values.global.rbac.namespaced true }}
kind: Role
{{- else }}
Expand All @@ -21,7 +24,9 @@ metadata:
{{ $key }}: {{ tpl $value $ }}
{{- end }}
rules: []
{{- end }}
---
{{- if and (eq .Values.global.actors.enabled true) (eq .Values.global.actors.serviceName "placement") }}
{{- if eq .Values.global.rbac.namespaced true }}
kind: RoleBinding
{{- else }}
Expand All @@ -46,3 +51,4 @@ roleRef:
kind: ClusterRole
{{- end }}
name: dapr-placement
{{- end }}
3 changes: 3 additions & 0 deletions pkg/actors/providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func TestConfig_GetRemindersProvider(t *testing.T) {
remindersProviders["custom"] = func(config Config, placement internal.PlacementService) (remindersProviderFactory, error) {
return nilProvider, nil
}
t.Cleanup(func() {
delete(remindersProviders, "custom")
})

c := Config{
Config: internal.Config{
Expand Down
15 changes: 7 additions & 8 deletions pkg/runtime/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ type Options struct {
// PodName is the name of the pod.
PodName string

// PlacementEnabled indicates whether placement service is enabled in this
// Dapr cluster.
PlacementEnabled bool
// ActorsEnabled indicates whether placement service is enabled in this Dapr cluster.
ActorsEnabled bool

// IsHTTP indicates whether the connection to the application is using the
// HTTP protocol.
Expand Down Expand Up @@ -144,11 +143,11 @@ func New(opts Options) *Processor {
})

state := state.New(state.Options{
PlacementEnabled: opts.PlacementEnabled,
Registry: opts.Registry.StateStores(),
ComponentStore: opts.ComponentStore,
Meta: opts.Meta,
Outbox: ps.Outbox(),
ActorsEnabled: opts.ActorsEnabled,
Registry: opts.Registry.StateStores(),
ComponentStore: opts.ComponentStore,
Meta: opts.Meta,
Outbox: ps.Outbox(),
})

secret := secret.New(secret.Options{
Expand Down
24 changes: 12 additions & 12 deletions pkg/runtime/processor/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const (
var log = logger.NewLogger("dapr.runtime.processor.state")

type Options struct {
Registry *compstate.Registry
ComponentStore *compstore.ComponentStore
Meta *meta.Meta
PlacementEnabled bool
Outbox outbox.Outbox
Registry *compstate.Registry
ComponentStore *compstore.ComponentStore
Meta *meta.Meta
ActorsEnabled bool
Outbox outbox.Outbox
}

type state struct {
Expand All @@ -54,17 +54,17 @@ type state struct {
lock sync.RWMutex

actorStateStoreName *string
placementEnabled bool
actorsEnabled bool
outbox outbox.Outbox
}

func New(opts Options) *state {
return &state{
registry: opts.Registry,
compStore: opts.ComponentStore,
meta: opts.Meta,
placementEnabled: opts.PlacementEnabled,
outbox: opts.Outbox,
registry: opts.Registry,
compStore: opts.ComponentStore,
meta: opts.Meta,
actorsEnabled: opts.ActorsEnabled,
outbox: opts.Outbox,
}
}

Expand Down Expand Up @@ -120,7 +120,7 @@ func (s *state) Init(ctx context.Context, comp compapi.Component) error {
s.outbox.AddOrUpdateOutbox(comp)

// when placement address list is not empty, set specified actor store.
if s.placementEnabled {
if s.actorsEnabled {
// set specified actor store if "actorStateStore" is true in the spec.
actorStoreSpecified := false
for k, v := range props {
Expand Down
30 changes: 15 additions & 15 deletions pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ func newDaprRuntime(ctx context.Context,
})

processor := processor.New(processor.Options{
ID: runtimeConfig.id,
Namespace: namespace,
IsHTTP: runtimeConfig.appConnectionConfig.Protocol.IsHTTP(),
PlacementEnabled: len(runtimeConfig.actorsService) > 0,
Registry: runtimeConfig.registry,
ComponentStore: compStore,
Meta: meta,
GlobalConfig: globalConfig,
Resiliency: resiliencyProvider,
Mode: runtimeConfig.mode,
PodName: podName,
Standalone: runtimeConfig.standalone,
OperatorClient: operatorClient,
GRPC: grpc,
Channels: channels,
ID: runtimeConfig.id,
Namespace: namespace,
IsHTTP: runtimeConfig.appConnectionConfig.Protocol.IsHTTP(),
ActorsEnabled: len(runtimeConfig.actorsService) > 0,
Registry: runtimeConfig.registry,
ComponentStore: compStore,
Meta: meta,
GlobalConfig: globalConfig,
Resiliency: resiliencyProvider,
Mode: runtimeConfig.mode,
PodName: podName,
Standalone: runtimeConfig.standalone,
OperatorClient: operatorClient,
GRPC: grpc,
Channels: channels,
})

var reloader *hotreload.Reloader
Expand Down
24 changes: 12 additions & 12 deletions pkg/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1961,18 +1961,18 @@ func TestGracefulShutdownPubSub(t *testing.T) {
mockAppChannel.On("InvokeMethod", mock.MatchedBy(daprt.MatchContextInterface), matchDaprRequestMethod("dapr/subscribe")).Return(fakeResp, nil)
// Create new processor with mocked app channel.
rt.processor = processor.New(processor.Options{
ID: rt.runtimeConfig.id,
IsHTTP: rt.runtimeConfig.appConnectionConfig.Protocol.IsHTTP(),
PlacementEnabled: len(rt.runtimeConfig.actorsService) > 0,
Registry: rt.runtimeConfig.registry,
ComponentStore: rt.compStore,
Meta: rt.meta,
GlobalConfig: rt.globalConfig,
Resiliency: rt.resiliency,
Mode: rt.runtimeConfig.mode,
Standalone: rt.runtimeConfig.standalone,
Channels: rt.channels,
GRPC: rt.grpc,
ID: rt.runtimeConfig.id,
IsHTTP: rt.runtimeConfig.appConnectionConfig.Protocol.IsHTTP(),
ActorsEnabled: len(rt.runtimeConfig.actorsService) > 0,
Registry: rt.runtimeConfig.registry,
ComponentStore: rt.compStore,
Meta: rt.meta,
GlobalConfig: rt.globalConfig,
Resiliency: rt.resiliency,
Mode: rt.runtimeConfig.mode,
Standalone: rt.runtimeConfig.standalone,
Channels: rt.channels,
GRPC: rt.grpc,
})

require.NoError(t, rt.processor.Init(context.Background(), cPubSub))
Expand Down

0 comments on commit 5304c2b

Please sign in to comment.