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

[WIP] [Upgrade Assistant] Deprecations plugin #90957

Conversation

alisonelizabeth
Copy link
Contributor

@alisonelizabeth alisonelizabeth commented Feb 10, 2021

[WIP] This PR creates a new deprecations plugin where other Kibana plugins can register its deprecations to be surfaced in Upgrade Assistant.

For testing purposes, this PR is registering deprecations for the timelion and security plugins.

How it works

Each plugin will be responsible for registering any deprecations during setup:

    deprecations.registerDeprecations({
      pluginId: 'security',
      getDeprecations,
    });

To register, a plugin must provide a plugin id and a function that will return an array of deprecated features currently being used by the user.

interface DeprecationContext {
  pluginId: string;
  getDeprecations: Promise<DeprecationInfo[]>;
}

interface DeprecationInfo {
  message: string;
  level: 'warning' | 'critical';
  documentationUrl?: string;
  correctionActions: {
    api?: {
      path: string;
      method: 'POST' | 'PUT';
      body?: {
        [key: string]: any;
      };
    };
    manualSteps?: string[];
  }; 
}

The deprecations plugin exposes an API route, which will be consumed by Upgrade Assistant:

GET /api/deprecations

Sample response:

{
    "deprecations": [
        {
            "message": "You have 2 Timelion worksheets. The Timelion app will be removed in 8.0. To continue using your Timelion worksheets, migrate them to a dashboard.",
            "documentationUrl": "https://www.elastic.co/guide/en/kibana/master/dashboard.html#timelion-deprecation",
            "level": "warning",
            "correctiveActions": {
                "manualSteps": [
                    "Navigate to the Kibana Dashboard and click \"Create dashboard\".",
                    "Select Timelion from the \"New Visualization\" window.",
                    "Open a new tab, open the Timelion app, select the chart you want to copy, then copy the chart expression.",
                    "Go to Timelion, paste the chart expression in the Timelion expression field, then click Update.",
                    "In the toolbar, click Save.",
                    "On the Save visualization window, enter the visualization Title, then click Save and return."
                ]
            },
            "pluginId": "timelion"
        },
        {
            "message": "User 'test_dashboard_user' is using a deprecated role: 'kibana_user'",
            "correctiveActions": {
                "api": {
                    "path": "/internal/security/users/test_dashboard_user",
                    "method": "POST",
                    "body": {
                        "username": "test_dashboard_user",
                        "roles": [
                            "machine_learning_user",
                            "enrich_user",
                            "kibana_admin"
                        ],
                        "full_name": "Alison Goryachev",
                        "email": "[email protected]",
                        "metadata": {},
                        "enabled": true
                    }
                },
                "manualSteps": [
                    "Using Kibana user management, change all users using the kibana_user role to the kibana_admin role.",
                    "Using Kibana role-mapping management, change all role-mappings which assing the kibana_user role to the kibana_admin role."
                ]
            },
            "documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html",
            "level": "critical",
            "pluginId": "security"
        },
        {
            "message": "User 'test' is using a deprecated role: 'kibana_dashboard_only_user'",
            "correctiveActions": {
                "manualSteps": [
                    "Using Kibana role management, create a new custom role.",
                    "Assign read-only access to the Dashboard feature.",
                    "Assign this role in place of the dashboard_only role."
                ]
            },
            "documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html",
            "level": "critical",
            "pluginId": "security"
        },
        {
            "message": "User 'kibana' has been deprecated.",
            "correctiveActions": {
                "manualSteps": [
                    "Using Kibana user management, set the password for the kibana_system user",
                    "Update all kibana.yml files to use this username and password for elasticsearch.username and elasticsearch.password"
                ]
            },
            "documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html",
            "level": "critical",
            "pluginId": "security"
        }
    ]
}

TODO

  • Implement ability for plugin to provide an optional correctiveAction to autofix deprecations. Need to also support providing instructions, if fix needs to be completed manually by the user.
  • Error handling
  • Permissions
  • Determine if we need to add the ability to cancel or track status.
  • Add tests
  • Add mock
  • Update readme
  • Update codeowners file

@kibanamachine
Copy link
Contributor

kibanamachine commented Feb 17, 2021

💔 Build Failed

Failed CI Steps

Metrics [docs]

‼️ ERROR: metrics for dc51be5 were not reported

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@Bamieh Bamieh self-requested a review February 18, 2021 14:46
@Bamieh
Copy link
Member

Bamieh commented Feb 24, 2021

Just syncing our discussions into github:

I'll be moving this feature into core during 7.13. I'll start working on it early in this releases to allow some wiggle room for feedback and changes.

  • Moving this into core allows core itself to use this feature for some core features deprecations.
  • Allow us to have better control over what telemetry we want to get from it.
  • Allows us to extend this configurations api required by each plugin instead of figuring out ways to expose internal plugin configs to enable just this feature.
  • It also makes sense having it in core since we already expose a deprecations method in the Plugin class.

@alisonelizabeth
Copy link
Contributor Author

Closing this PR in favor of #94845.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants