From ad36664a4ee847add84946a553c6954234646a9b Mon Sep 17 00:00:00 2001 From: Agi K Thomas <101976829+agithomas@users.noreply.github.com> Date: Thu, 3 Nov 2022 14:17:43 +0530 Subject: [PATCH] Fix to correct policy assignment to unhealthy agents when using custom agents (#1024) * Fix to correct policy assignement to unhealthy agents when using custom-agent service deployer --- .ci/Jenkinsfile | 1 - Makefile | 5 +---- internal/testrunner/runners/system/runner.go | 20 +++++++++---------- .../oracle/_dev/build/build.yml | 0 .../oracle/_dev/build/docs/README.md | 0 .../oracle/changelog.yml | 0 .../memory/_dev/deploy/agent/Dockerfile | 0 .../memory/_dev/deploy/agent/custom-agent.yml | 0 .../_dev/test/system/test-memory-config.yml | 0 .../memory/agent/stream/stream.yml.hbs | 0 .../elasticsearch/ingest_pipeline/default.yml | 0 .../data_stream/memory/fields/base-fields.yml | 0 .../oracle/data_stream/memory/fields/ecs.yml | 0 .../data_stream/memory/fields/fields.yml | 0 .../oracle/data_stream/memory/manifest.yml | 0 .../data_stream/memory/sample_event.json | 0 .../oracle/docs/README.md | 0 .../oracle/img/oracle_logo.svg | 0 .../oracle/install.md | 0 ...-55661160-08c7-11ed-9abf-15e60715cfab.json | 0 ...-59eeb380-08d7-11ed-9abf-15e60715cfab.json | 0 ...-6b4866c0-1599-11ed-9607-2ba0819b3835.json | 0 ...-9e19fb00-08e1-11ed-9abf-15e60715cfab.json | 0 ...-b6b2c9f0-13a7-11ed-9607-2ba0819b3835.json | 0 ...-bdb780f0-156a-11ed-9607-2ba0819b3835.json | 0 .../oracle/manifest.yml | 0 26 files changed, 11 insertions(+), 15 deletions(-) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/_dev/build/build.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/_dev/build/docs/README.md (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/changelog.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/_dev/deploy/agent/Dockerfile (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/_dev/deploy/agent/custom-agent.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/_dev/test/system/test-memory-config.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/agent/stream/stream.yml.hbs (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/elasticsearch/ingest_pipeline/default.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/fields/base-fields.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/fields/ecs.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/fields/fields.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/manifest.yml (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/data_stream/memory/sample_event.json (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/docs/README.md (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/img/oracle_logo.svg (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/install.md (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/kibana/dashboard/oracle-55661160-08c7-11ed-9abf-15e60715cfab.json (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/kibana/dashboard/oracle-59eeb380-08d7-11ed-9abf-15e60715cfab.json (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/kibana/dashboard/oracle-6b4866c0-1599-11ed-9607-2ba0819b3835.json (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/kibana/dashboard/oracle-9e19fb00-08e1-11ed-9abf-15e60715cfab.json (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/kibana/dashboard/oracle-b6b2c9f0-13a7-11ed-9607-2ba0819b3835.json (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/kibana/dashboard/oracle-bdb780f0-156a-11ed-9607-2ba0819b3835.json (100%) rename test/packages/{custom-agent-multiservice => with-custom-agent}/oracle/manifest.yml (100%) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index aaa0f243c..278b4f8b7 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -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') diff --git a/Makefile b/Makefile index 8b3f2f258..e7389b7e5 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index bf8d2ec01..14b2e59c5 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -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") @@ -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...") diff --git a/test/packages/custom-agent-multiservice/oracle/_dev/build/build.yml b/test/packages/with-custom-agent/oracle/_dev/build/build.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/_dev/build/build.yml rename to test/packages/with-custom-agent/oracle/_dev/build/build.yml diff --git a/test/packages/custom-agent-multiservice/oracle/_dev/build/docs/README.md b/test/packages/with-custom-agent/oracle/_dev/build/docs/README.md similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/_dev/build/docs/README.md rename to test/packages/with-custom-agent/oracle/_dev/build/docs/README.md diff --git a/test/packages/custom-agent-multiservice/oracle/changelog.yml b/test/packages/with-custom-agent/oracle/changelog.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/changelog.yml rename to test/packages/with-custom-agent/oracle/changelog.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/_dev/deploy/agent/Dockerfile b/test/packages/with-custom-agent/oracle/data_stream/memory/_dev/deploy/agent/Dockerfile similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/_dev/deploy/agent/Dockerfile rename to test/packages/with-custom-agent/oracle/data_stream/memory/_dev/deploy/agent/Dockerfile diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/_dev/deploy/agent/custom-agent.yml b/test/packages/with-custom-agent/oracle/data_stream/memory/_dev/deploy/agent/custom-agent.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/_dev/deploy/agent/custom-agent.yml rename to test/packages/with-custom-agent/oracle/data_stream/memory/_dev/deploy/agent/custom-agent.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/_dev/test/system/test-memory-config.yml b/test/packages/with-custom-agent/oracle/data_stream/memory/_dev/test/system/test-memory-config.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/_dev/test/system/test-memory-config.yml rename to test/packages/with-custom-agent/oracle/data_stream/memory/_dev/test/system/test-memory-config.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/agent/stream/stream.yml.hbs b/test/packages/with-custom-agent/oracle/data_stream/memory/agent/stream/stream.yml.hbs similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/agent/stream/stream.yml.hbs rename to test/packages/with-custom-agent/oracle/data_stream/memory/agent/stream/stream.yml.hbs diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/elasticsearch/ingest_pipeline/default.yml b/test/packages/with-custom-agent/oracle/data_stream/memory/elasticsearch/ingest_pipeline/default.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/elasticsearch/ingest_pipeline/default.yml rename to test/packages/with-custom-agent/oracle/data_stream/memory/elasticsearch/ingest_pipeline/default.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/fields/base-fields.yml b/test/packages/with-custom-agent/oracle/data_stream/memory/fields/base-fields.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/fields/base-fields.yml rename to test/packages/with-custom-agent/oracle/data_stream/memory/fields/base-fields.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/fields/ecs.yml b/test/packages/with-custom-agent/oracle/data_stream/memory/fields/ecs.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/fields/ecs.yml rename to test/packages/with-custom-agent/oracle/data_stream/memory/fields/ecs.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/fields/fields.yml b/test/packages/with-custom-agent/oracle/data_stream/memory/fields/fields.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/fields/fields.yml rename to test/packages/with-custom-agent/oracle/data_stream/memory/fields/fields.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/manifest.yml b/test/packages/with-custom-agent/oracle/data_stream/memory/manifest.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/manifest.yml rename to test/packages/with-custom-agent/oracle/data_stream/memory/manifest.yml diff --git a/test/packages/custom-agent-multiservice/oracle/data_stream/memory/sample_event.json b/test/packages/with-custom-agent/oracle/data_stream/memory/sample_event.json similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/data_stream/memory/sample_event.json rename to test/packages/with-custom-agent/oracle/data_stream/memory/sample_event.json diff --git a/test/packages/custom-agent-multiservice/oracle/docs/README.md b/test/packages/with-custom-agent/oracle/docs/README.md similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/docs/README.md rename to test/packages/with-custom-agent/oracle/docs/README.md diff --git a/test/packages/custom-agent-multiservice/oracle/img/oracle_logo.svg b/test/packages/with-custom-agent/oracle/img/oracle_logo.svg similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/img/oracle_logo.svg rename to test/packages/with-custom-agent/oracle/img/oracle_logo.svg diff --git a/test/packages/custom-agent-multiservice/oracle/install.md b/test/packages/with-custom-agent/oracle/install.md similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/install.md rename to test/packages/with-custom-agent/oracle/install.md diff --git a/test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-55661160-08c7-11ed-9abf-15e60715cfab.json b/test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-55661160-08c7-11ed-9abf-15e60715cfab.json similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-55661160-08c7-11ed-9abf-15e60715cfab.json rename to test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-55661160-08c7-11ed-9abf-15e60715cfab.json diff --git a/test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-59eeb380-08d7-11ed-9abf-15e60715cfab.json b/test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-59eeb380-08d7-11ed-9abf-15e60715cfab.json similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-59eeb380-08d7-11ed-9abf-15e60715cfab.json rename to test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-59eeb380-08d7-11ed-9abf-15e60715cfab.json diff --git a/test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-6b4866c0-1599-11ed-9607-2ba0819b3835.json b/test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-6b4866c0-1599-11ed-9607-2ba0819b3835.json similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-6b4866c0-1599-11ed-9607-2ba0819b3835.json rename to test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-6b4866c0-1599-11ed-9607-2ba0819b3835.json diff --git a/test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-9e19fb00-08e1-11ed-9abf-15e60715cfab.json b/test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-9e19fb00-08e1-11ed-9abf-15e60715cfab.json similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-9e19fb00-08e1-11ed-9abf-15e60715cfab.json rename to test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-9e19fb00-08e1-11ed-9abf-15e60715cfab.json diff --git a/test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-b6b2c9f0-13a7-11ed-9607-2ba0819b3835.json b/test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-b6b2c9f0-13a7-11ed-9607-2ba0819b3835.json similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-b6b2c9f0-13a7-11ed-9607-2ba0819b3835.json rename to test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-b6b2c9f0-13a7-11ed-9607-2ba0819b3835.json diff --git a/test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-bdb780f0-156a-11ed-9607-2ba0819b3835.json b/test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-bdb780f0-156a-11ed-9607-2ba0819b3835.json similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/kibana/dashboard/oracle-bdb780f0-156a-11ed-9607-2ba0819b3835.json rename to test/packages/with-custom-agent/oracle/kibana/dashboard/oracle-bdb780f0-156a-11ed-9607-2ba0819b3835.json diff --git a/test/packages/custom-agent-multiservice/oracle/manifest.yml b/test/packages/with-custom-agent/oracle/manifest.yml similarity index 100% rename from test/packages/custom-agent-multiservice/oracle/manifest.yml rename to test/packages/with-custom-agent/oracle/manifest.yml