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

Old format of stored scripts is not dropped #47593

Closed
jdconrad opened this issue Oct 4, 2019 · 3 comments
Closed

Old format of stored scripts is not dropped #47593

jdconrad opened this issue Oct 4, 2019 · 3 comments
Assignees
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v7.4.1 v7.5.0 v8.0.0-alpha1

Comments

@jdconrad
Copy link
Contributor

jdconrad commented Oct 4, 2019

In 5.6 there are two types of id's for stored scripts. 1) lang#id and 2) id -- The first one was deprecated; however, since both could be referenced during script usage when a put stored script request was issued, both types were added for the same script. Example:

POST _scripts/foo
{
  "script": {
    "lang": "painless",
    "source": "def hello=\"world\""
  }
}

GET /_cluster/state?filter_path=metadata.stored_scripts

results in the following:

{
  "metadata": {
    "stored_scripts": {
      "foo": {
        "lang": "painless",
        "source": """def hello="world"""",
        "options": {}
      },
      "painless#foo": {
        "lang": "painless",
        "source": """def hello="world"""",
        "options": {}
      }
    }
  }
}

When upgrading to 6.0, though, it's no longer possible to get/put/delete stored scripts with the deprecated id format (lang#id), but we still load the scripts saved in the cluster state from the previous version with that format and never convert it to the id only type. This means legacy scripts exist in the cluster state that cannot be accessed or deleted. The potential fix is to convert the old style scripts to the new style in all situations.

@jdconrad jdconrad added >bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v8.0.0 v7.5.0 v6.8.4 v7.4.1 labels Oct 4, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

@jdconrad jdconrad removed the v6.8.4 label Oct 4, 2019
@jdconrad
Copy link
Contributor Author

jdconrad commented Oct 7, 2019

After some more consideration, the best fix is to simply drop all old-style format scripts from the cluster state. As they were already inaccessible there is no expectation any consumers would want old scripts popping back into view along with the fact they may no longer match possibly conflicting newer versions in the new-style format.

@jdconrad jdconrad self-assigned this Oct 14, 2019
jdconrad added a commit that referenced this issue Oct 16, 2019
This PR fixes (#47593). Stored scripts with the old-style id of lang#id are 
saved through the upgrade process but are no longer accessible in recent 
versions. This fix will drop those scripts altogether since there is no way for 
a user to access them.
jdconrad added a commit that referenced this issue Oct 16, 2019
This PR fixes (#47593). Stored scripts with the old-style id of lang#id are 
saved through the upgrade process but are no longer accessible in recent 
versions. This fix will drop those scripts altogether since there is no way for 
a user to access them.
@jdconrad
Copy link
Contributor Author

Fixed by #48078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v7.4.1 v7.5.0 v8.0.0-alpha1
Projects
None yet
Development

No branches or pull requests

3 participants