Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to import few saved objects via the kbn archiver. Missing reference error #103009

Closed
rashmivkulkarni opened this issue Jun 22, 2021 · 4 comments
Labels
bug Fixes for quality problems that affect the customer experience [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation Team:Operations Team label for Operations Team test_xpack_functional

Comments

@rashmivkulkarni
Copy link
Contributor

rashmivkulkarni commented Jun 22, 2021

Trying to migrate es_archiver to kbn_archiver for Maps tests

Part of #102552

Steps:
1 ) load esArchiver of Maps tests for .kibana data : x-pack/test/functional/es_archives/maps/kibana

NODE_TLS_REJECT_UNAUTHORIZED=0 node --no-warnings scripts/es_archiver load x-pack/test/functional/es_archives/maps/kibana  --config test/functional/config.js  --es-url=http://elastic:changeme@localhost:9220 --kibana-url=http://elastic:changeme@localhost:5620
  1. Find all the different types of saved objects in .kibana loaded in the first step by running
2. cat  x-pack/test/functional/es_archives/maps/kibana/data.json | awk '{$1=$1};1' | fgrep '"type":' | fgrep -v '"type": "doc"' | sort | uniq

resulted in:

"filters": [{"meta":{"index":"b15b1d40-a8bb-11e9-98cf-2bb06ef63e0b","alias":null,"negate":false,"type":"phrase","key":"extension.raw","value":"jpg","params":{"query":"jpg"},"disabled":false},"query":{"match":{"extension.raw":{"query":"jpg","type":"phrase"}}},"$state":{"store":"appState"}}]
"type": "dashboard",
"type": "envelope"
"type": "index-pattern"
"type": "map"
"type": "map",
"type": "polygon"
"type": "query",
"type": "space"
"type":"index-pattern"
  1. Now save .kibana json into KBN archiver by running (please feed the types from step 2 here - dashboard,index-pattern,map)
node scripts/kbn_archiver.js --config x-pack/test/functional/config.js save x-pack/test/functional/fixtures/kbn_archiver/maps/data.json  --type dashboard,index-pattern,map 

Resulted in :

 succ Exported 33 saved objects to /Users/rashmikulkarni/Documents/kibana/x-pack/test/functional/fixtures/kbn_archiver/maps.json

rest of the type (s) - gave errors

ERROR 400 resp: '{"statusCode":400,"error":"Bad Request","message":"Trying to export non-exportable type(s): envelope, polygon, space"}'
  1. Make the changes in the index file of Maps test - Replace esArchiver loading .kibana and unloading:
     await kibanaServer.importExport.load(
        'x-pack/test/functional/fixtures/kbn_archiver/maps.json'
      );
  1. Run the tests. node scripts/functional_test_runner.js
1)    maps app
 │       "before all" hook in "maps app":
 │
 │      Error: failed to import all saved objects: {
 │   errors: [
 │     {
 │       error: {
 │         references: [
 │           {
 │             id: 'idThatDoesNotExitForESGeoGridSource',
 │             type: 'index-pattern'
 │           },
 │           {
 │             id: 'idThatDoesNotExitForESSearchSource',
 │             type: 'index-pattern'
 │           },
 │           {
 │             id: 'idThatDoesNotExitForESJoinSource',
 │             type: 'index-pattern'
 │           }
 │         ],
 │         type: 'missing_references'
 │       },
 │       id: '745c98b0-23e1-11e9-a048-6fef5a3e0d1e',
 │       meta: {
 │         icon: 'gisApp',
 │         title: 'layer with errors'
 │       },
 │       title: 'layer with errors',
 │       type: 'map'
 │     }
 │   ],
 │   success: false,
 │   successCount: 32,

tried to find the referenced id in the original es_archiver and newly saved kbn_archiver, they do have the references.

@rashmivkulkarni rashmivkulkarni added bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation test_xpack_functional labels Jun 22, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

@tylersmalley
Copy link
Contributor

This isn't a bug, and something we discussed already. One of the tests is validating a case where there is a missing index pattern, so the esArchive has just that - a missing index pattern. You can't do that with the import API since it validates that all the references exist. You will need to populate the reference and can delete it after it's been successfully imported.

@rashmivkulkarni
Copy link
Contributor Author

identifying the missing references and adding them to the kbnArchiver- data.json resolves this issue. Also added the logic in the maps index.js file to delete them using the API after successful import .

Ref PR: #103028

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation Team:Operations Team label for Operations Team test_xpack_functional
Projects
None yet
Development

No branches or pull requests

3 participants