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

Ckan 2.10系に対応 #88

Closed
ryo-ma opened this issue Nov 27, 2023 · 15 comments
Closed

Ckan 2.10系に対応 #88

ryo-ma opened this issue Nov 27, 2023 · 15 comments
Assignees
Labels

Comments

@ryo-ma
Copy link
Contributor

ryo-ma commented Nov 27, 2023

https://github.com/ckan/ckan/releases

動作確認後、2.10系に対応作業を実施

@To-Ki-O
Copy link
Collaborator

To-Ki-O commented Feb 27, 2024

CKAN2.10系の検証

現状で判明している内容について以下に記載いたします。

ckanext-feedback前に必要な修正

  • SQLAlchemyver.1.4.41が利用されている

    • pyproject.tomlsqlalchemyの指定しているバージョンを修正する必要がある
  • /srv/app/src/ckan/ckan/public/base/i18n/ja.jsに権限を付与する

    • 初期段階ではPLUGINから上記ファイルへのアクセス権限がないため、権限を付与する必要がある

ckanext-feedbackインストール後

  • templateファイル内のhelper関数が変更になっている(以下のログを参照)
Screenshot 2024-02-27 at 15 02 50
  • その他(templateファイル)
    • {{ h.url_for(controller='admin', action='index') }}{{ h.url_for('admin.index') }}と簡略化されている
    • {{ h.url_for('/user/_logout') }}{{ h.url_for('user.logout') }}となっている 等

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Feb 27, 2024

@To-Ki-O 試した手順も残しておいてもらえますか?

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Feb 27, 2024

https://github.com/ckan/ckan-docker
こちらで立ち上げているがckan/ckan-base-datapusher:0.0.20 の起動がうまくいかず。

特に目立ったエラーは見られず再起動を繰り返す

2024-02-28 01:07:38 [uWSGI] getting INI configuration from /srv/app/datapusher-uwsgi.ini
2024-02-28 01:07:38 *** Starting uWSGI 2.0.19.1 (64bit) on [Tue Feb 27 16:07:38 2024] ***
2024-02-28 01:07:38 compiled with version: 10.2.1 20201203 on 09 January 2021 08:06:39
2024-02-28 01:07:38 os: Linux-5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022
2024-02-28 01:07:38 nodename: e55d9896ea1f
2024-02-28 01:07:38 machine: x86_64
2024-02-28 01:07:38 clock source: unix
2024-02-28 01:07:38 pcre jit disabled
2024-02-28 01:07:38 detected number of CPU cores: 4
2024-02-28 01:07:38 current working directory: /srv/app
2024-02-28 01:07:38 writing pidfile to /tmp/datapusher-uwsgi.pid
2024-02-28 01:07:38 detected binary path: /usr/sbin/uwsgi
2024-02-28 01:07:38 setuid() to 92
2024-02-28 01:07:38 your memory page size is 4096 bytes
2024-02-28 01:07:38  *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers *** 
2024-02-28 01:07:38 detected max file descriptor number: 1048576
2024-02-28 01:07:38 lock engine: pthread robust mutexes
2024-02-28 01:07:38 unable to set PTHREAD_PRIO_INHERIT
2024-02-28 01:08:38 [uWSGI] getting INI configuration from /srv/app/datapusher-uwsgi.ini
2024-02-28 01:08:38 *** Starting uWSGI 2.0.19.1 (64bit) on [Tue Feb 27 16:08:38 2024] ***
2024-02-28 01:08:38 compiled with version: 10.2.1 20201203 on 09 January 2021 08:06:39
2024-02-28 01:08:38 os: Linux-5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022
2024-02-28 01:08:38 nodename: e55d9896ea1f
2024-02-28 01:08:38 machine: x86_64
2024-02-28 01:08:38 clock source: unix
2024-02-28 01:08:38 pcre jit disabled
2024-02-28 01:08:38 detected number of CPU cores: 4
2024-02-28 01:08:38 current working directory: /srv/app
2024-02-28 01:08:38 writing pidfile to /tmp/datapusher-uwsgi.pid
2024-02-28 01:08:38 detected binary path: /usr/sbin/uwsgi
2024-02-28 01:08:38 setuid() to 92
2024-02-28 01:08:38 your memory page size is 4096 bytes
2024-02-28 01:08:38  *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers *** 
2024-02-28 01:08:38 detected max file descriptor number: 1048576
2024-02-28 01:08:38 lock engine: pthread robust mutexes
2024-02-28 01:08:38 unable to set PTHREAD_PRIO_INHERIT

@To-Ki-O
Copy link
Collaborator

To-Ki-O commented Feb 28, 2024

以下に手順を記載いたします。

  1. ckan-docker/src内にckanext-feedbackcloneする

  2. ckanext-feedback/pyproject.tomlの33行目, 34行目のPythonとSQLAlchemyのバージョンを変更する

  3. https://github.com/ckan/ckan-docker からCKAN 2.10を起動

DataPusherは再起動を繰り返します。(Issueとして上がっているようですが、調査中です)
ckan/ckan-docker#114

  1. CKANコンテナ内に入り、権限を変更する chmod 777 /srv/app/src/ckan/ckan/public/base/i18n/ja.js

  2. pip install /srv/app/src_extensions/ckanext-feedback

  3. vi srv/app/ckan.iniのPluginsにfeedbackを追記する

以上が私が行った手順になります。

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Feb 28, 2024

@To-Ki-O ありがとうございます。
現在、submoduleの対象がckan本体のリポジトリになっているので、ckan-dockerに変更する作業もしたいですね。

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Mar 1, 2024

ckanの起動もコンテナは起動していますがlocalhostで接続できず。

2024-03-01 10:48:44 2024-03-01 01:48:44,281 INFO  [ckan.cli] Using configuration file /srv/app/ckan.ini
2024-03-01 10:48:44 2024-03-01 01:48:44,283 INFO  [ckan.config.environment] Loading static files from public
2024-03-01 10:48:45 2024-03-01 01:48:45,432 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
2024-03-01 10:48:46 2024-03-01 01:48:46,878 WARNI [ckanext.reclineview.plugin] The Recline-based views are deprecated andwill be removed in future versions
2024-03-01 10:48:46 2024-03-01 01:48:46,999 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
2024-03-01 10:48:47 2024-03-01 01:48:47,515 WARNI [ckan.config.middleware.flask_app] Extensions are excluded from CSRF protection! We allow extensions to run without CSRF protection but it will be forced future releases. Read the documentation for more information on how to add CSRF protection to your extension.
2024-03-01 10:48:50 2024-03-01 01:48:50,653 INFO  [ckan.cli] Using configuration file /srv/app/ckan.ini
2024-03-01 10:48:50 2024-03-01 01:48:50,655 INFO  [ckan.config.environment] Loading static files from public
2024-03-01 10:48:51 2024-03-01 01:48:51,816 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
2024-03-01 10:48:53 2024-03-01 01:48:53,279 WARNI [ckanext.reclineview.plugin] The Recline-based views are deprecated andwill be removed in future versions
2024-03-01 10:48:53 2024-03-01 01:48:53,402 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
2024-03-01 10:48:53 2024-03-01 01:48:53,905 WARNI [ckan.config.middleware.flask_app] Extensions are excluded from CSRF protection! We allow extensions to run without CSRF protection but it will be forced future releases. Read the documentation for more information on how to add CSRF protection to your extension.
2024-03-01 10:48:56 2024-03-01 01:48:56,729 INFO  [ckan.cli] Using configuration file /srv/app/ckan.ini
2024-03-01 10:48:56 2024-03-01 01:48:56,731 INFO  [ckan.config.environment] Loading static files from public
2024-03-01 10:48:58 2024-03-01 01:48:58,041 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
2024-03-01 10:48:59 2024-03-01 01:48:59,572 WARNI [ckanext.reclineview.plugin] The Recline-based views are deprecated andwill be removed in future versions
2024-03-01 10:48:59 2024-03-01 01:48:59,713 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
2024-03-01 10:48:54 
2024-03-01 10:48:54 WARNING:  no privileges were granted for "public"
2024-03-01 10:48:54 
2024-03-01 10:48:54 WARNING:  no privileges were granted for "public"
2024-03-01 10:48:54 
2024-03-01 10:48:54 WARNING:  no privileges were granted for "public"
2024-03-01 10:48:54 
2024-03-01 10:48:54 WARNING:  no privileges were granted for "public"
2024-03-01 10:48:54 
2024-03-01 10:48:54 [prerun] Initializing datastore db - end
2024-03-01 10:48:54 b''
2024-03-01 10:48:54 [prerun] Succesfully connected to solr and CKAN schema loaded
2024-03-01 10:48:54 [prerun] Sysadmin user exists, skipping creation
2024-03-01 10:48:54 /srv/app/start_ckan.sh: Running init file /docker-entrypoint.d/01_setup_datapusher.sh
2024-03-01 10:48:54 Set up ckan.datapusher.api_token in the CKAN config file
2024-03-01 10:49:03 /srv/app/start_ckan.sh: Ignoring /docker-entrypoint.d/README.md (not an sh or py file)
2024-03-01 10:49:03 Setting a temporary value for ckan.datapusher.api_token
2024-03-01 10:49:00 2024-03-01 01:49:00,244 WARNI [ckan.config.middleware.flask_app] Extensions are excluded from CSRF protection! We allow extensions to run without CSRF protection but it will be forced future releases. Read the documentation for more information on how to add CSRF protection to your extension.
2024-03-01 10:49:03 *** Starting uWSGI 2.0.21 (64bit) on [Fri Mar  1 01:49:03 2024] ***
2024-03-01 10:49:03 compiled with version: 12.2.1 20220924 on 09 November 2022 12:47:28
2024-03-01 10:49:03 os: Linux-5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022
2024-03-01 10:49:03 nodename: bbcbcb92287b
2024-03-01 10:49:03 machine: x86_64
2024-03-01 10:49:03 clock source: unix
2024-03-01 10:49:03 pcre jit disabled
2024-03-01 10:49:03 detected number of CPU cores: 4
2024-03-01 10:49:03 current working directory: /srv/app
2024-03-01 10:49:03 detected binary path: /usr/sbin/uwsgi
2024-03-01 10:49:03 uWSGI running as root, you can use --uid/--gid/--chroot options
2024-03-01 10:49:03 setgid() to 92
2024-03-01 10:49:03 setuid() to 92
2024-03-01 10:49:03 your memory page size is 4096 bytes
2024-03-01 10:49:03  *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers *** 
2024-03-01 10:49:03 detected max file descriptor number: 1048576
2024-03-01 10:49:03 lock engine: pthread robust mutexes
2024-03-01 10:49:03 unable to set PTHREAD_PRIO_INHERIT

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Mar 1, 2024

docker-compose.dev.ymlの方だと動作しました。

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Mar 5, 2024

  • datapusherの必要性の調査
  • datapusherの動作対応
  • どのtemplateが修正必要か調査
  • ckan内部で利用していた関数が利用できるかの確認

@To-Ki-O
Copy link
Collaborator

To-Ki-O commented Mar 5, 2024

2024.03.05 09:35

解決策

  • .envファイルのCKAN_SITE_URLhttp://localhost:5000というHTTPに変更する

DataPusherが起動していない状態

  • 画面遷移のたびに以下のエラーが発生する
    • Organization, dataset, resourceを作成するボタンにHTTPSのURLが割り振られているため発生している
Screenshot 2024-03-05 at 9 24 12
  • リソースの登録自体は可能
Screenshot 2024-03-05 at 9 30 32

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Mar 5, 2024

DataPusherとの関係が分からなかったのです、上記は関係あるのですか?

@To-Ki-O
Copy link
Collaborator

To-Ki-O commented Mar 5, 2024

  • DataPusherなしでデータの挿入が可能か試した形になります。

  • DataPusherの役割としては以下のようです。

    • CKANのDataStoreにデータを挿入するPlugin
    • Preview画面にリソース可視化するPluginで必須になるようです。

CKANフィードバックにおいては、DataPusherは必須ではなさそうです。
もう少し調査をいたします。

@To-Ki-O
Copy link
Collaborator

To-Ki-O commented Mar 7, 2024

DataPusherについて

  • 本拡張機能においてはDataPusherは必須ではないと判断しました。
    • CKAN 9.7系において、DataPusherPluginsから削除し、DataPusherのコンテナを落として動作確認を行いました。
      • 特に問題なく、CKANフィードバック機能が動作いたしました

修正が必要なファイルについて

  • 調査は完了しておりませんが、修正が必要になりそうです。

    • command/feedback.py
      • (psycopg2.errors.UndefinedTable) relation "resource" does not existというエラーが発生している
      • [解決済] ckan.model.metaengineが定義されており、こちらを利用することでテーブルの作成が完了した
        • command/feedback.pyの中身を見直す必要あり
  • その他の修正が必要と考えられる点について

    • CSRF対応
      • 以下のWarningが出ている
        WARNI [ckan.config.middleware.flask_app] Extensions are excluded from CSRF protection! 
        We allow extensions to run without CSRF protection but it will be forced future releases. 
        Read the documentation for more information on how to add CSRF protection to your extension.
        
      • CKANのドキュメントに対応方法が記載

@To-Ki-O
Copy link
Collaborator

To-Ki-O commented Mar 7, 2024

Templateについて

CKAN 2.9系とCKAN 2.10系のdiffを取って比較した

大きく修正が必要

  • header.html
  • package/snippets/resource_item.html
  • package/resource_read.html
  • snippets/package_item.html

若干の修正が必要

  • package/snippets/additional_info.html
    • h.link_to()が削除され、aタグが利用される形に修正されていた
  • command/feedback.py ※こちらはtemplatesではありませんが、こちらに記載いたします
    • ckan/model/meta.pyからengineを取得する形で動作可能であり、中身の見直しと修正が必要と考えられるため

動作確認は必要だが、修正の必要はなさそう

  • page.htmlに若干の変更
    • management/comment.html
    • utilization/details.html
    • utilization/edit.html
    • utilization/search.html
  • package/base.htmlに若干の変更
    • resource/comment.html
    • utilization/new.html

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Apr 3, 2024

リソースコメント画面のApproveボタンとReplyボタンが左寄せになっています。Utilizationのコメントは右寄せだったので2.10系対応によるバグですかね?

スクリーンショット 2024-04-03 22 42 37

@ryo-ma
Copy link
Contributor Author

ryo-ma commented Apr 3, 2024

Utilizationのeditも同様で元々は以下で
スクリーンショット 2024-04-03 22 50 29

v2.10系で以下のようになっています。
スクリーンショット 2024-04-03 22 52 23

@ryo-ma ryo-ma closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

2 participants