Solr 8.4.0 で追加された”Untrusted Configsets”の制限について

Solr 8.4.0 の Changes には以下の項目があります。

SOLR-14071: Untrusted configsets (ones that are uploaded via unsecured configset API) cannot use <lib> directive. Consider enabling authentication/authorization so that the uploaded configsets are trusted. Note: If you already have a collection using untrusted configset that uses directive, it will not load after upgrading to 8.4. You can re-upload your configset using “bin/solr zk -upconfig ..” or place your libraries in the classpath and restart Solr.

「Untrusted configsets は lib ディレクティブを使えません」とあります。
configsets が trusted として扱われるためには、認証有りでアップロードしなければならないとのことです。Solr 8.4.0 では _default の solrconfig.xml から lib を使う設定が無くなったのもこの変更に合わせてのようです。

Untrusted configsets では lib ディレクティブが使えないというのが具体的にどういう意味なのかを確認してみました。

まず Solr 8.4.0 が起動した状態で sample_techproducts_configs (このサンプル設定には 8.4.0 でも lib ディレクティブが含まれます)を configsets_test という名前でアップロードします。

$ (cd solr-8.4.0/server/solr/configsets/sample_techproducts_configs/conf && zip -r - *) > configsets_test.zip
$ curl -X POST --header "Content-Type:application/octet-stream" --data-binary @configsets_test.zip "http://localhost:8983/solr/admin/configs?action=UPLOAD&name=configsets_test"

アップロードした configsets_test を使ってコレクションを作成します。

curl -s "http://localhost:8983/solr/admin/collections?action=CREATE&name=configsets_test&numShards=1&replicationFactor=1&collection.configName=configsets_test&omitHeader=true"
{
  "failure":{
    "127.0.1.1:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Error CREATEing SolrCore 'configsets_test_shard1_replica_n1': Unable to create core [configsets_test_shard1_replica_n1] Caused by: The configset for this collection was uploaded without any authentication in place, and use of  is not available for collections with untrusted configsets. To use this component, re-upload the configset after enabling authentication and authorization."},
  "Operation create caused exception:":"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Underlying core creation failed while creating collection: configsets_test",
  "exception":{
    "msg":"Underlying core creation failed while creating collection: configsets_test",
    "rspCode":400},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"Underlying core creation failed while creating collection: configsets_test",
    "code":400}}

アップロードはできましたが、その configsets を使ってコレクションを作成することろでエラーになりました。

次に BASIC 認証を設定してからコレクション作成してみます。

$ ./solr-8.4.0/server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:9983 -cmd put /security.json '{
"authentication":{
   "blockUnknown": true,
   "class":"solr.BasicAuthPlugin",
   "credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}
 }
}'

ここで Solr を再起動して BASIC 認証が有効になった状態で再度コレクション作成。

$ curl --user solr:SolrRocks -s "http://localhost:8983/solr/admin/collections?action=CREATE&name=configsets_test&numShards=1&replicationFactor=1&collection.configName=configsets_test&omitHeader=true"
{
  "failure":{
    "127.0.1.1:8983_solr":"org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Error CREATEing SolrCore 'configsets_test_shard1_replica_n1': Unable to create core [configsets_test_shard1_replica_n1] Caused by: The configset for this collection was uploaded without any authentication in place, and use of  is not available for collections with untrusted configsets. To use this component, re-upload the configset after enabling authentication and authorization."},
  "Operation create caused exception:":"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Underlying core creation failed while creating collection: configsets_test",
  "exception":{
    "msg":"Underlying core creation failed while creating collection: configsets_test",
    "rspCode":400},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"Underlying core creation failed while creating collection: configsets_test",
    "code":400}}

やはりエラーになります。

confitsets を trusted として扱ってもらうために、認証有りの状態で再度アップロードします。UPLOAD コマンドでは上書きできないので、DELETE してから UPLOAD します。

$ curl --user solr:SolrRocks -X POST --header "Content-Type:application/octet-stream" --data-binary @configsets_test.zip "http://localhost:8983/solr/admin/configs?action=DELETE&name=configsets_test"
{
  "responseHeader":{
    "status":0,
    "QTime":220}}
$ curl --user solr:SolrRocks -X POST --header "Content-Type:application/octet-stream" --data-binary @configsets_test.zip "http://localhost:8983/solr/admin/configs?action=UPLOAD&name=configsets_test"
{
  "responseHeader":{
    "status":0,
    "QTime":292}}

認証有りでアップロードした configsets を使ってコレクションを作成してみます。

$ curl --user solr:SolrRocks -s "http://localhost:8983/solr/admin/collections?action=CREATE&name=configsets_test&numShards=1&replicationFactor=1&collection.configName=configsets_test&omitHeader=true"
{
  "success":{
    "127.0.1.1:8983_solr":{
      "responseHeader":{
        "status":0,
        "QTime":2126},
      "core":"configsets_test_shard1_replica_n1"}}}

今度はうまくいきました。

結論としては、「Untrusted configsets では lib ディレクティブが使えない」とは、libディレクティブを含む Untrusted configsets ではコレクションを生成できないという意味でした。

ところで、configsets アップロードする方法としては、Solr の Configsets API を使う方法とは別に zookeeper に直接アップロードする方法もあります。

$ ./solr-8.4.0/server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:9983 -cmd upconfig -confdir solr-8.4.0/server/solr/configsets/sample_techproducts_configs/conf -confname configsets_test2
INFO  - 2020-02-23 22:52:50.804; org.apache.solr.common.cloud.ConnectionManager; Waiting for client to connect to ZooKeeper
INFO  - 2020-02-23 22:52:50.821; org.apache.solr.common.cloud.ConnectionManager; zkClient has connected
INFO  - 2020-02-23 22:52:50.821; org.apache.solr.common.cloud.ConnectionManager; Client is connected to ZooKeeper
$ curl --user solr:SolrRocks -s "http://localhost:8983/solr/admin/collections?action=CREATE&name=configsets_test2&numShards=1&replicationFactor=1&collection.configName=configsets_test2&omitHeader=true"
{
  "success":{
    "127.0.1.1:8983_solr":{
      "responseHeader":{
        "status":0,
        "QTime":1361},
      "core":"configsets_test2_shard1_replica_n1"}}}

なんとコレクション生成できてしまいました。

現時点では Untrusted Configsets の制限はまだ不十分なようで、今後の進展に注意する必要がありそうです。


コメント