Skip to content

Commit

Permalink
Fix to correct policy assignment to unhealthy agents when using custo…
Browse files Browse the repository at this point in the history
…m agents (#1024)

* Fix to correct policy assignement to unhealthy agents when using custom-agent service deployer
  • Loading branch information
agithomas authored Nov 3, 2022
1 parent 315df8e commit ad36664
Show file tree
Hide file tree
Showing 26 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ pipeline {
'check-packages-with-kind': generateTestCommandStage(command: 'test-check-packages-with-kind', artifacts: ['build/test-results/*.xml', 'build/kubectl-dump.txt', 'build/elastic-stack-dump/check-*/logs/*.log', 'build/elastic-stack-dump/check-*/logs/fleet-server-internal/*'], junitArtifacts: true, publishCoverage: true),
'check-packages-other': generateTestCommandStage(command: 'test-check-packages-other', artifacts: ['build/test-results/*.xml', 'build/elastic-stack-dump/check-*/logs/*.log', 'build/elastic-stack-dump/check-*/logs/fleet-server-internal/*'], junitArtifacts: true, publishCoverage: true),
'check-packages-with-custom-agent': generateTestCommandStage(command: 'test-check-packages-with-custom-agent', artifacts: ['build/test-results/*.xml', 'build/elastic-stack-dump/check-*/logs/*.log', 'build/elastic-stack-dump/check-*/logs/fleet-server-internal/*'], junitArtifacts: true, publishCoverage: true),
'check-packages-custom-agent-multiservice': generateTestCommandStage(command: 'test-check-packages-custom-agent-multiservice', artifacts: ['build/test-results/*.xml', 'build/elastic-stack-dump/check-*/logs/*.log', 'build/elastic-stack-dump/check-*/logs/fleet-server-internal/*'], junitArtifacts: true, publishCoverage: true),
'check-packages-benchmarks': generateTestCommandStage(command: 'test-check-packages-benchmarks', artifacts: ['build/test-results/*.xml', 'build/elastic-stack-dump/check-*/logs/*.log', 'build/elastic-stack-dump/check-*/logs/fleet-server-internal/*'], junitArtifacts: true, publishCoverage: false),
'build-zip': generateTestCommandStage(command: 'test-build-zip', artifacts: ['build/elastic-stack-dump/build-zip/logs/*.log', 'build/packages/*.sig']),
'profiles-command': generateTestCommandStage(command: 'test-profiles-command')
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test-stack-command-8x:

test-stack-command: test-stack-command-default test-stack-command-7x test-stack-command-800 test-stack-command-8x

test-check-packages: test-check-packages-with-kind test-check-packages-other test-check-packages-parallel test-check-packages-with-custom-agent test-check-packages-benchmarks test-check-packages-custom-agent-multiservice
test-check-packages: test-check-packages-with-kind test-check-packages-other test-check-packages-parallel test-check-packages-with-custom-agent test-check-packages-benchmarks

test-check-packages-with-kind:
PACKAGE_TEST_TYPE=with-kind ./scripts/test-check-packages.sh
Expand All @@ -82,9 +82,6 @@ test-check-packages-parallel:
test-check-packages-with-custom-agent:
PACKAGE_TEST_TYPE=with-custom-agent ./scripts/test-check-packages.sh

test-check-packages-custom-agent-multiservice:
PACKAGE_TEST_TYPE=custom-agent-multiservice ./scripts/test-check-packages.sh

test-build-zip:
./scripts/test-build-zip.sh

Expand Down
20 changes: 10 additions & 10 deletions internal/testrunner/runners/system/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,6 @@ func (r *runner) runTest(config *testConfig, ctxt servicedeployer.ServiceContext
return result.WithError(errors.Wrap(err, "can't create Kibana client"))
}

agents, err := checkEnrolledAgents(kib, ctxt)
if err != nil {
return result.WithError(errors.Wrap(err, "can't check enrolled agents"))
}
agent := agents[0]
origPolicy := kibana.Policy{
ID: agent.PolicyID,
Revision: agent.PolicyRevision,
}

// Configure package (single data stream) via Ingest Manager APIs.
logger.Debug("creating test policy...")
testTime := time.Now().Format("20060102T15:04:05Z")
Expand Down Expand Up @@ -401,6 +391,16 @@ func (r *runner) runTest(config *testConfig, ctxt servicedeployer.ServiceContext
return result.WithError(err)
}

agents, err := checkEnrolledAgents(kib, ctxt)
if err != nil {
return result.WithError(errors.Wrap(err, "can't check enrolled agents"))
}
agent := agents[0]
origPolicy := kibana.Policy{
ID: agent.PolicyID,
Revision: agent.PolicyRevision,
}

// Assign policy to agent
r.resetAgentPolicyHandler = func() error {
logger.Debug("reassigning original policy back to agent...")
Expand Down

0 comments on commit ad36664

Please sign in to comment.