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

plugin: support dynamic enable/disable plugins #11122

Merged
merged 7 commits into from
Jul 9, 2019
Merged

plugin: support dynamic enable/disable plugins #11122

merged 7 commits into from
Jul 9, 2019

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Jul 8, 2019

What problem does this PR solve?

  • support dynamic disable/enable a loaded plugins.
  • have ablity to observe plugin's enable/disable state
  • enable/disable operation will affect all nodes in the cluster

What is changed and how it works?

need use parser's new syntax pingcap/parser#374

then just change current disable flag and broadcast change via etcd

attention: we also need update plugins to let plugin's go.mod dep on new parser...

Check List

Tests

  • Manual test (add detailed scripts or steps below)
./bin/tidb-server -store tikv -path 127.0.0.1:2379 -plugin-dir=$GOPATH/src/github.com/pingcap/enterprise-plugin/audit -plugin-load=audit-1

mysql> show plugins;
+-------+--------------+-------+------------------------------------------------------------------------------+---------+---------+
| Name  | Status       | Type  | Library                                                                      | License | Version |
+-------+--------------+-------+------------------------------------------------------------------------------+---------+---------+
| audit | Ready-enable | Audit | /home/robi/code/go/src/github.com/pingcap/enterprise-plugin/audit/audit-1.so |         | 1       |
+-------+--------------+-------+------------------------------------------------------------------------------+---------+---------+
1 row in set (0.01 sec)

mysql> admin plugins disable audit;
Query OK, 0 rows affected (0.01 sec)

mysql> show plugins;
+-------+---------------+-------+------------------------------------------------------------------------------+---------+---------+
| Name  | Status        | Type  | Library                                                                      | License | Version |
+-------+---------------+-------+------------------------------------------------------------------------------+---------+---------+
| audit | Ready-disable | Audit | /home/robi/code/go/src/github.com/pingcap/enterprise-plugin/audit/audit-1.so |         | 1       |
+-------+---------------+-------+------------------------------------------------------------------------------+---------+---------+
1 row in set (0.00 sec)

mysql> admin plugins enable audit;
Query OK, 0 rows affected (0.00 sec)

mysql> show plugins;
+-------+--------------+-------+------------------------------------------------------------------------------+---------+---------+
| Name  | Status       | Type  | Library                                                                      | License | Version |
+-------+--------------+-------+------------------------------------------------------------------------------+---------+---------+
| audit | Ready-enable | Audit | /home/robi/code/go/src/github.com/pingcap/enterprise-plugin/audit/audit-1.so |         | 1       |
+-------+--------------+-------+------------------------------------------------------------------------------+---------+---------+
1 row in set (0.00 sec)

Code changes

  • impl change

Side effects

  • N/A

Related changes

  • Need to cherry-pick to the release 3.0/2.1

This change is Reviewable

@lysu lysu added type/enhancement The issue or PR belongs to an enhancement. component/plugin labels Jul 8, 2019
@lysu lysu requested review from jackysp and tiancaiamao July 8, 2019 07:54
@codecov
Copy link

codecov bot commented Jul 8, 2019

Codecov Report

Merging #11122 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11122   +/-   ##
===========================================
  Coverage   81.3541%   81.3541%           
===========================================
  Files           421        421           
  Lines         90948      90948           
===========================================
  Hits          73990      73990           
  Misses        11702      11702           
  Partials       5256       5256

@lysu
Copy link
Contributor Author

lysu commented Jul 8, 2019

plugin build CI will be fixed after https://github.com/pingcap/enterprise-plugin/pull/8 be merged

Copy link
Contributor

@tiancaiamao tiancaiamao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

plugin/plugin.go Outdated Show resolved Hide resolved
plugin/plugin.go Outdated Show resolved Hide resolved
@lysu lysu added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 9, 2019
@lysu
Copy link
Contributor Author

lysu commented Jul 9, 2019

/run-all-tests

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jackysp
Copy link
Member

jackysp commented Jul 9, 2019

/rebuild

@jackysp jackysp merged commit 8104494 into pingcap:master Jul 9, 2019
ngaut pushed a commit that referenced this pull request Jul 15, 2019
#11189)

* plugin: add unit test for plugin (#10506)

* plugin: setup connection info in session when audit plugin be enabled (#10923)

*  plugin: support dynamic enable/disable plugins (#11122)

* update parser version & fix cp compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/plugin status/LGT1 Indicates that a PR has LGTM 1. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants