-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Fix saved object import missing reference #127760
[Fleet] Fix saved object import missing reference #127760
Conversation
Pinging @elastic/fleet (Team:Fleet) |
@elasticmachine merge upstream |
@nchaulet Do you know if this might affect 7.17 too? |
I need to test, but I guess it's probably good to backport it there too. the index template metricbeat-* was existing in 7.x and removed in 8.0 so for the AWS package this will not be a problem, but a package could still be malformed at some point and we get the same issue. |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: cc @nchaulet |
We didn't use the import API in 7.17, we made that switch in 8.0 so I don't believe this would impact the 7.x series. @hop-dev does that match your understanding as well? |
A couple questions before this PR is merged:
|
We had a mechanism to retry with allow missing reference, I agree that we could probably simplify that by removing the retry on missing reference and throw like we do for other errors. This will be a breaking change as it will result in existing package the AWS 1.13.0 one to not be installable. |
The AWS package is being fixed here: elastic/integrations#2826 so we may be able to move towards failing in the way you describe. My concern is that there may be other packages that are broken that we don't know about. Should we have a CI test that attempts to install the latest version of every package in the repository? It might be useful to throw up a draft PR now that changes the logic to fail on missing references and adds this test to see if there others we should fix. |
Yes it will be usefull, I can create that PR |
Regarding allowing reference errors, pre 8.x we didn't check for (or throw) reference errors, so when we moved to import I decided to keep the behaviour the same to prevent any issues installing historic packages etc. Taking a harder stance on the reference errors is appealing but in the AWS example I believe the dashboards do still work (if they are installed 😓 ) regardless of the error, so not broken to the user. |
Thanks for that info, Mark, that makes sense. In that case, I'm comfortable moving forward with merging this and investigating the overall problem separately as we make packages more rock solid. @nchaulet I'm going to merge this now so we can make the next 8.1.1 BC (there was a blocker so there should be another build). Would you mind opening an issue to investigate this problem more broadly? |
I do have a hacked together script for installing the latest versions of each package from when I was developing this if its any use install_all_packages.jsimport fetch from "node-fetch";
const SKIP_PACKAGES = ["kibana", "logstash", "microsoft", "fleet_server", "elastic_agent"]
async function installPackage(name, version) {
const start = Date.now()
const res = await fetch(`http://localhost:5601/mark/api/fleet/epm/packages/${name}-${version}`, {
"headers": {
"accept": "*/*",
"content-type": "application/json",
"kbn-xsrf": "xyz",
'Authorization': 'Basic ' + Buffer.from("elastic:changeme").toString('base64')
},
"body": null,
"method": "POST"
});
const end = Date.now()
const body = await res.json()
return { body, status: res.status, took : (end - start) / 1000 };
}
async function deletePackage(name, version) {
const res = await fetch(`http://localhost:5601/mark/api/fleet/epm/packages/${name}-${version}`, {
"headers": {
"accept": "*/*",
"content-type": "application/json",
"kbn-xsrf": "xyz",
'Authorization': 'Basic ' + Buffer.from("elastic:changeme").toString('base64')
},
"body": null,
"method": "DELETE"
});
const body = await res.json()
return { body, status: res.status };
}
async function getAllPackages() {
const res = await fetch("https://epr-snapshot.elastic.co/search", {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
},
"body": null,
"method": "GET"
});
const body = await res.json()
return body;
}
function logResult(pkg, result){
const pre = `${pkg.name}-${pkg.version} ${result.took ? ` took ${result.took}s` : ""} : `;
if (result.status !== 200) {
console.log(pre + JSON.stringify(result))
} else {
console.log(pre + 200)
}
}
async function go() {
const allPackages = await getAllPackages()
console.log("INSTALLING ------");
for (const pkg of allPackages) {
if (SKIP_PACKAGES.includes(pkg.name)) {
console.log(`Skipping ${pkg.name}`)
continue;
}
const result = await installPackage(pkg.name, pkg.version);
logResult(pkg,result)
}
const deletePackages = process.argv.includes("--delete")
if(!deletePackages) return;
console.log("DELETING ------");
for (const pkg of allPackages) {
if (SKIP_PACKAGES.includes(pkg.name)) {
console.log(`Skipping ${pkg.name}`)
continue;
}
const result = await deletePackage(pkg.name, pkg.version);
logResult(pkg,result)
}
}
go() |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 4f3022e)
Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 4f3022e) Co-authored-by: Nicolas Chaulet <[email protected]>
Summary
Resolve #127664
We had some special case to retry when we have missing reference in kibana assets but we were considering that other assets were correctly imported, according to the doc
That PR fix by including all the saved object in the retry call for missing reference.
How to test?
You can try to install the AWS integration in the
1.13.0
version before that fix after install you should see only one dashboard in the assets tab of the integration after you should see 24.