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

fix auth: init-store no auth context and graphs-list with non STATUS-READ permission #1115

Merged
merged 2 commits into from
Jul 28, 2020

Conversation

javeme
Copy link
Contributor

@javeme javeme commented Jul 28, 2020

Change-Id: I6a05e06509caf0ea525fb57ca8352e53ced584aa

because main thread don't set admin-context before init-store, then
scheduler thread can't save anything

Change-Id: Id74b47ad31719266c9b03356f8807d25c7a9531d
Change-Id: I6a05e06509caf0ea525fb57ca8352e53ced584aa
@javeme
Copy link
Contributor Author

javeme commented Jul 28, 2020

init-store error when enabled auth (related https://github.com/hugegraph/hugegraph/pull/1111#issuecomment-664425761):

2020-07-27 22:13:35 48976 [main] [INFO ] com.baidu.hugegraph.HugeGraph [] - Close graph standardhugegraph[hugegraph]
Exception in thread "main" com.baidu.hugegraph.HugeException: Failed to update/query server info: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Missing authentication context when verifying resource permission
	at com.baidu.hugegraph.task.ServerInfoManager.call(ServerInfoManager.java:320)
	at com.baidu.hugegraph.task.ServerInfoManager.initialized(ServerInfoManager.java:208)
	at com.baidu.hugegraph.task.ServerInfoManager.removeSelfServerInfo(ServerInfoManager.java:341)
	at com.baidu.hugegraph.task.ServerInfoManager.close(ServerInfoManager.java:121)
	at com.baidu.hugegraph.task.StandardTaskScheduler.close(StandardTaskScheduler.java:478)
	at com.baidu.hugegraph.task.TaskManager.closeScheduler(TaskManager.java:112)
	at com.baidu.hugegraph.StandardHugeGraph.close(StandardHugeGraph.java:696)
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.close(HugeGraphAuthProxy.java:479)
	at com.baidu.hugegraph.auth.StandardAuthenticator.initAdminUser(StandardAuthenticator.java:55)
	at com.baidu.hugegraph.auth.StandardAuthenticator.initAdminUser(StandardAuthenticator.java:122)
	at com.baidu.hugegraph.cmd.InitStore.main(InitStore.java:99)
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Missing authentication context when verifying resource permission
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at com.baidu.hugegraph.task.ServerInfoManager.call(ServerInfoManager.java:318)
	... 10 more
Caused by: java.lang.IllegalStateException: Missing authentication context when verifying resource permission
	at com.google.common.base.Preconditions.checkState(Preconditions.java:531)
	at com.baidu.hugegraph.util.E.checkState(E.java:68)
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:774)
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:765)
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyPermission(HugeGraphAuthProxy.java:638)
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyAdminPermission(HugeGraphAuthProxy.java:624)
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.backendStoreSystemInfo(HugeGraphAuthProxy.java:543)
	at com.baidu.hugegraph.task.ServerInfoManager.lambda$2(ServerInfoManager.java:208)
	at com.baidu.hugegraph.task.TaskManager$ContextCallable.call(TaskManager.java:374)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

@javeme
Copy link
Contributor Author

javeme commented Jul 28, 2020

start error after fix init-store error:
(this is because the first time init-store fails, but not init server-info schema due to bug the above, still no schema even set admin pass success after bugfix. clear and re init is ok)

2020-07-28 00:06:34 76567 [task-scheduler-1] [ERROR] com.baidu.hugegraph.task.TaskManager [] - Exception occurred when schedule job
com.baidu.hugegraph.HugeException: Failed to update/query server info: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Undefined vertex label: '~server'
	at com.baidu.hugegraph.task.ServerInfoManager.call(ServerInfoManager.java:320) ~[classes/:?]
	at com.baidu.hugegraph.task.ServerInfoManager.serverInfos(ServerInfoManager.java:383) ~[classes/:?]
	at com.baidu.hugegraph.task.ServerInfoManager.serverInfos(ServerInfoManager.java:378) ~[classes/:?]
	at com.baidu.hugegraph.task.ServerInfoManager.allServerInfos(ServerInfoManager.java:369) ~[classes/:?]
	at com.baidu.hugegraph.task.StandardTaskScheduler.scheduleTasks(StandardTaskScheduler.java:329) ~[classes/:?]
	at com.baidu.hugegraph.task.TaskManager.scheduleOrExecuteJobForGraph(TaskManager.java:329) ~[classes/:?]
	at com.baidu.hugegraph.task.TaskManager.scheduleOrExecuteJob(TaskManager.java:288) ~[classes/:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_111]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_111]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_111]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_111]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_111]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_111]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Undefined vertex label: '~server'
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_111]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_111]
	at com.baidu.hugegraph.task.ServerInfoManager.call(ServerInfoManager.java:318) ~[classes/:?]
	... 13 more
Caused by: java.lang.IllegalArgumentException: Undefined vertex label: '~server'
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:163) ~[guava-25.1-jre.jar:?]
	at com.baidu.hugegraph.util.E.checkArgument(E.java:56) ~[hugegraph-common-1.7.8.jar:1.7.8.0]
	at com.baidu.hugegraph.StandardHugeGraph.vertexLabel(StandardHugeGraph.java:578) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.lambda$2(HugeGraphAuthProxy.java:221) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.lambda$23(HugeGraphAuthProxy.java:754) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:779) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:765) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifySchemaPermission(HugeGraphAuthProxy.java:752) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifySchemaPermission(HugeGraphAuthProxy.java:745) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.vertexLabel(HugeGraphAuthProxy.java:220) ~[classes/:?]
	at com.baidu.hugegraph.task.ServerInfoManager.lambda$7(ServerInfoManager.java:390) ~[classes/:?]
	at com.baidu.hugegraph.task.TaskManager$ContextCallable.call(TaskManager.java:374) ~[classes/:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_111]
	... 3 more
2020-07-28 00:06:34 76576 [gremlin-server-stop] [WARN ] org.apache.tinkerpop.gremlin.server.GremlinServer [] - Exception while closing Graph instance [hugegraph]
java.lang.IllegalStateException: Ensure tx closed in all threads when closing graph 'hugegraph'
	at com.google.common.base.Preconditions.checkState(Preconditions.java:531) ~[guava-25.1-jre.jar:?]
	at com.baidu.hugegraph.util.E.checkState(E.java:68) ~[hugegraph-common-1.7.8.jar:1.7.8.0]
	at com.baidu.hugegraph.StandardHugeGraph.close(StandardHugeGraph.java:705) ~[classes/:?]
	at com.baidu.hugegraph.auth.HugeGraphAuthProxy.close(HugeGraphAuthProxy.java:479) ~[classes/:?]
	at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$null$7(GremlinServer.java:298) ~[gremlin-server-3.4.3.jar:3.4.3]
	at java.util.concurrent.ConcurrentHashMap$KeySetView.forEach(ConcurrentHashMap.java:4649) ~[?:1.8.0_111]
	at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$stop$8(GremlinServer.java:295) ~[gremlin-server-3.4.3.jar:3.4.3]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]

@codecov
Copy link

codecov bot commented Jul 28, 2020

Codecov Report

Merging #1115 into master will increase coverage by 0.05%.
The diff coverage is 55.55%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1115      +/-   ##
============================================
+ Coverage     66.43%   66.49%   +0.05%     
- Complexity     5646     5650       +4     
============================================
  Files           347      347              
  Lines         28521    28527       +6     
  Branches       4028     4029       +1     
============================================
+ Hits          18947    18968      +21     
+ Misses         7716     7697      -19     
- Partials       1858     1862       +4     
Impacted Files Coverage Δ Complexity Δ
...om/baidu/hugegraph/auth/StandardAuthenticator.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...c/main/java/com/baidu/hugegraph/cmd/InitStore.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ava/com/baidu/hugegraph/api/profile/GraphsAPI.java 29.72% <80.00%> (+3.25%) 0.00 <0.00> (ø)
...va/com/baidu/hugegraph/auth/HugeAuthenticator.java 19.07% <100.00%> (+4.56%) 0.00 <0.00> (ø)
...in/java/com/baidu/hugegraph/StandardHugeGraph.java 80.40% <100.00%> (+0.10%) 108.00 <0.00> (ø)
...va/com/baidu/hugegraph/task/ServerInfoManager.java 74.43% <100.00%> (+4.37%) 52.00 <1.00> (+4.00)
...om/baidu/hugegraph/task/StandardTaskScheduler.java 79.39% <100.00%> (ø) 90.00 <1.00> (ø)
...ugegraph/backend/store/BackendStoreSystemInfo.java 75.60% <0.00%> (-4.88%) 9.00% <0.00%> (-1.00%)
...ain/java/com/baidu/hugegraph/task/TaskManager.java 75.67% <0.00%> (+1.35%) 30.00% <0.00%> (ø%)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df1d89b...30cd1fd. Read the comment docs.

@Linary Linary merged commit 4474a4a into master Jul 28, 2020
@Linary Linary deleted the graph-list-auth-bug branch July 28, 2020 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants