Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into merge19intomaster
Browse files Browse the repository at this point in the history
  • Loading branch information
berndverst committed Oct 13, 2022
2 parents 80b7527 + 81fc87d commit ea1e47e
Show file tree
Hide file tree
Showing 16 changed files with 591 additions and 319 deletions.
166 changes: 126 additions & 40 deletions .github/workflows/dapr-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
shell: bash
- name: Parse test payload
if: github.event_name == 'repository_dispatch'
uses: actions/github-script@0.3.0
uses: actions/github-script@v6.2.0
with:
github-token: ${{secrets.DAPR_BOT_TOKEN}}
script: |
Expand All @@ -73,8 +73,25 @@ jobs:
// Set environment variables
fs.appendFileSync(process.env.GITHUB_ENV,
`CHECKOUT_REPO=${testPayload.pull_head_repo}\n`+
`CHECKOUT_REF=${testPayload.pull_head_ref}`);
`CHECKOUT_REF=${testPayload.pull_head_ref}\n`+
`PR_NUMBER=${testPayload.issue.number}`
);
}
- name: Create PR comment
if: env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
hide: true
hide_classify: OUTDATED
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
# Dapr perf test
🔗 **[Link to Action run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})**
Commit ref: ${{ env.CHECKOUT_REF }}
- name: Check out code
if: env.CHECKOUT_REPO != ''
uses: actions/checkout@v2
Expand Down Expand Up @@ -106,6 +123,7 @@ jobs:
REGIONS_SIZE=${#REGIONS[@]}
REGIONS_IDX=$(($RANDOM % $REGIONS_SIZE))
REGION=${REGIONS[$REGIONS_IDX]}
echo "AZURE_REGION=${REGION}" >> $GITHUB_ENV
echo "Deploying to Azure region: ${REGION}"
# Tags
Expand All @@ -120,7 +138,8 @@ jobs:
# Deploy the test cluster, deploying AKS only
# Retry the deployment twice in case of transient failures (such as capacity constraints)
for i in 1 2; do
success=false
for i in 1 2 3; do
az deployment group create \
--resource-group "${{ env.TEST_RESOURCE_GROUP }}" \
--template-file ./tests/test-infra/azure-aks.bicep \
Expand All @@ -130,9 +149,42 @@ jobs:
linuxVMSize=Standard_D8s_v4 \
diagLogAnalyticsWorkspaceResourceId="${{ secrets.AZURE_DIAG_LOG_ANALYTICS_WORKSPACE_ID }}" \
diagStorageResourceId="${{ secrets.AZURE_DIAG_STORAGE_ID }}" \
&& break || sleep 120
&& success=true \
&& break \
|| sleep 120
done
# Exit with error if failed
$success || exit 1
shell: bash
- name: Update PR comment for success
if: success() && env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ✅ Infrastructure deployed
- Resource group name: `Dapr-Perf-${{ env.TEST_PREFIX }}`
- Azure region: ${{ env.AZURE_REGION }}
- name: Update PR comment for failure
if: failure() && env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ❌ Infrastructure deployment failed
- Resource group name: `Dapr-Perf-${{ env.TEST_PREFIX }}`
- Azure region: ${{ env.AZURE_REGION }}
Please check the logs for details on the failure.
build:
name: Build
Expand All @@ -151,7 +203,7 @@ jobs:
shell: bash
- name: Parse test payload
if: github.event_name == 'repository_dispatch'
uses: actions/github-script@0.3.0
uses: actions/github-script@v6.2.0
with:
github-token: ${{secrets.DAPR_BOT_TOKEN}}
script: |
Expand All @@ -161,7 +213,9 @@ jobs:
// Set environment variables
fs.appendFileSync(process.env.GITHUB_ENV,
`CHECKOUT_REPO=${testPayload.pull_head_repo}\n`+
`CHECKOUT_REF=${testPayload.pull_head_ref}`);
`CHECKOUT_REF=${testPayload.pull_head_ref}\n`+
`PR_NUMBER=${testPayload.issue.number}`
);
}
- name: Set up Go ${{ env.GOVER }}
if: env.CHECKOUT_REPO != ''
Expand Down Expand Up @@ -241,6 +295,31 @@ jobs:
run: |
make build-push-perf-app-all
shell: bash
- name: Update PR comment for success
if: success() && env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ✅ Build succeeded
- Image tag: `${{ env.DAPR_TAG }}`
- Test image tag: `${{ env.DAPR_TEST_TAG }}`
- name: Update PR comment for failure
if: failure() && env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ❌ Build failed
Please check the logs for details on the error.
test-perf:
name: Perf tests
Expand Down Expand Up @@ -273,7 +352,7 @@ jobs:
shell: bash
- name: Parse test payload
if: github.event_name == 'repository_dispatch'
uses: actions/github-script@0.3.0
uses: actions/github-script@v6.2.0
with:
github-token: ${{secrets.DAPR_BOT_TOKEN}}
script: |
Expand All @@ -283,7 +362,9 @@ jobs:
// Set environment variables
fs.appendFileSync(process.env.GITHUB_ENV,
`CHECKOUT_REPO=${testPayload.pull_head_repo}\n`+
`CHECKOUT_REF=${testPayload.pull_head_ref}`);
`CHECKOUT_REF=${testPayload.pull_head_ref}\n`+
`PR_NUMBER=${testPayload.issue.number}`
);
}
- name: Set up Go ${{ env.GOVER }}
if: env.CHECKOUT_REPO != ''
Expand Down Expand Up @@ -435,45 +516,50 @@ jobs:
with:
name: perf_test_logs
path: ${{ env.DAPR_TEST_LOG_PATH }}
- name: Add test result comment to PR
if: always() && github.event_name == 'repository_dispatch' && env.TEST_PREFIX != ''
env:
JOB_CONTEXT: ${{ toJson(job) }}
uses: actions/[email protected]
with:
github-token: ${{secrets.DAPR_BOT_TOKEN}}
script: |
const testPayload = context.payload.client_payload;
const jobContext = JSON.parse(process.env.JOB_CONTEXT);
const jobStatus = jobContext.status.toLowerCase();
console.log(`Current Job Status: ${jobStatus}`);
var message = "";
if (jobStatus == "cancelled") {
message = "Dapr Perf tests cancelled.";
} else if (jobStatus == "success") {
message = "All Dapr perf tests completed.";
} else if (jobStatus == "failure") {
message = "Dapr Perf tests failed.";
}
if (message) {
await github.issues.createComment({
owner: testPayload.issue.owner,
repo: testPayload.issue.repo,
issue_number: testPayload.issue.number,
body: message
});
}
- name: Upload test results
if: always()
uses: actions/upload-artifact@master
with:
#TODO: .json suffix can be removed from artifact name after test analytics scripts are updated
name: test_perf.json
path: ${{ env.TEST_OUTPUT_FILE_PREFIX }}_perf*.*
- name: Update PR comment for success
if: success() && env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ✅ Perf tests succeeded
- Image tag: `${{ env.DAPR_TAG }}`
- Test image tag: `${{ env.DAPR_TEST_TAG }}`
- name: Update PR comment for failure
if: failure() && env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ❌ Perf tests failed
Please check the logs for details on the error.
- name: Update PR comment for cancellation
if: cancelled() && env.PR_NUMBER != ''
uses: artursouza/[email protected]
with:
header: ${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
append: true
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
message: |
## ⚠️ Perf tests cancelled
The Action has been canceled
cleanup:
name: Clean up Azure resources
Expand Down
5 changes: 5 additions & 0 deletions docs/development/dapr-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ Dapr uses prometheus process and go collectors by default.
* dapr_runtime_actor_deactivated_total: The number of the successful actor deactivation.
* dapr_runtime_actor_deactivated_failed_total: The number of the failed actor deactivation.

#### Resiliency

* dapr_runtime_resiliency_loaded: The number of resiliency policies loaded.
* dapr_runtime_resiliency_count: The number of times a resiliency policy has been executed.

### gRPC monitoring metrics

Dapr leverages opencensus ocgrpc plugin to generate gRPC server and client metrics.
Expand Down
54 changes: 30 additions & 24 deletions pkg/actors/actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ type Actors interface {
GetActiveActorsCount(ctx context.Context) []ActiveActorsCount
}

// GRPCConnectionFn is the type of the function that returns a gRPC connection
type GRPCConnectionFn func(ctx context.Context, address, id string, namespace string, skipTLS, recreateIfExists, enableSSL bool, customOpts ...grpc.DialOption) (*grpc.ClientConn, func(), error)

type actorsRuntime struct {
appChannel channel.AppChannel
store state.Store
transactionalStore state.TransactionalStore
placement *internal.ActorPlacement
grpcConnectionFn func(ctx context.Context, address, id string, namespace string, skipTLS, recreateIfExists, enableSSL bool, customOpts ...grpc.DialOption) (*grpc.ClientConn, func(), error)
grpcConnectionFn GRPCConnectionFn
config Config
actorsTable *sync.Map
activeTimers *sync.Map
Expand Down Expand Up @@ -139,32 +142,39 @@ const (

var ErrDaprResponseHeader = errors.New("error indicated via actor header response")

// ActorsOpts contains options for NewActors.
type ActorsOpts struct {
StateStore state.Store
AppChannel channel.AppChannel
GRPCConnectionFn GRPCConnectionFn
Config Config
CertChain *daprCredentials.CertChain
TracingSpec configuration.TracingSpec
Features []configuration.FeatureSpec
Resiliency resiliency.Provider
StateStoreName string
}

// NewActors create a new actors runtime with given config.
func NewActors(
stateStore state.Store,
appChannel channel.AppChannel,
grpcConnectionFn func(ctx context.Context, address, id string, namespace string, skipTLS, recreateIfExists, enableSSL bool, customOpts ...grpc.DialOption) (*grpc.ClientConn, func(), error),
config Config,
certChain *daprCredentials.CertChain,
tracingSpec configuration.TracingSpec,
features []configuration.FeatureSpec,
resiliency resiliency.Provider,
stateStoreName string,
) Actors {
func NewActors(opts ActorsOpts) Actors {
var transactionalStore state.TransactionalStore
if stateStore != nil {
features := stateStore.Features()
if opts.StateStore != nil {
features := opts.StateStore.Features()
if state.FeatureETag.IsPresent(features) && state.FeatureTransactional.IsPresent(features) {
transactionalStore = stateStore.(state.TransactionalStore)
transactionalStore = opts.StateStore.(state.TransactionalStore)
}
}

return &actorsRuntime{
appChannel: appChannel,
config: config,
store: stateStore,
store: opts.StateStore,
appChannel: opts.AppChannel,
grpcConnectionFn: opts.GRPCConnectionFn,
config: opts.Config,
certChain: opts.CertChain,
tracingSpec: opts.TracingSpec,
resiliency: opts.Resiliency,
storeName: opts.StateStoreName,
transactionalStore: transactionalStore,
grpcConnectionFn: grpcConnectionFn,
actorsTable: &sync.Map{},
activeTimers: &sync.Map{},
activeTimersLock: &sync.RWMutex{},
Expand All @@ -177,11 +187,7 @@ func NewActors(
evaluationBusy: false,
evaluationChan: make(chan bool),
appHealthy: atomic.NewBool(true),
certChain: certChain,
tracingSpec: tracingSpec,
resiliency: resiliency,
storeName: stateStoreName,
isResiliencyEnabled: configuration.IsFeatureEnabled(features, configuration.Resiliency),
isResiliencyEnabled: configuration.IsFeatureEnabled(opts.Features, configuration.Resiliency),
}
}

Expand Down
Loading

0 comments on commit ea1e47e

Please sign in to comment.