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

Update Django to latest 4.2 LTS #2750 #2751

Conversation

phillxnet
Copy link
Member

@phillxnet phillxnet commented Nov 16, 2023

Update Django from 3.2.23 to 4.2.7 via poetry update and pyproject.toml.

Includes:

  • Move from django.utils.timezone utc to datetime.timezone.utc: RemovedInDjango50Warning
  • Remove to-be-deprecated USE_L10N setting, prior setting now enforced: RemovedInDjango50Warning
  • Add comment re Django 5.0 change in default USE_TZ value: Future default already adopted.
  • Remove non-existent/unused STATICFILES_DIRS entry.
  • Adopt new-in-Django-4.2 STORAGES setting to replace STATICFILES_STORAGE setting.

Fixes #2750

Update Django from 3.2.23 to 4.2.7 via `poetry update`
and pyproject.toml.
## Includes:
- Move from django.utils.timezone utc to datetime.timezone.utc:
 RemovedInDjango50Warning
- Remove to-be-deprecated USE_L10N setting, prior setting now enforced:
 RemovedInDjango50Warning
- Add comment re Django 5.0 change in default USE_TZ value:
 Future default already adopted.
- Remove non-existent/unused STATICFILES_DIRS entry.
- Adopt new-in-Django-4.2 STORAGES setting to replace
 STATICFILES_STORAGE setting.
@phillxnet phillxnet marked this pull request as ready for review November 17, 2023 18:10
@phillxnet
Copy link
Member Author

We have a slight issue here still regarding our static file arrangements/changes, looking into this now.
I.e. with a clean RPM build and install, against this PR, and clearing the cache of the testing browser; we have many 404's re missing JS libs.

@phillxnet phillxnet marked this pull request as draft November 20, 2023 13:27
@phillxnet
Copy link
Member Author

In our build.sh we have the following:

rockstor-core/build.sh

Lines 47 to 56 in e7edab7

if [ ! -d "jslibs" ]; then
# See: STATICFILES_DIRS in settings.py
echo "Creating jslibs/js/lib & populating from rockstor-jslibs.tar.gz"
echo
mkdir -p jslibs/js/lib
# GitHub versioned archives have rockstor-jslibs-{jslibs_version} top directory,
# i.e. rockstor-jslibs-#.#.#, we strip this single top directory.
tar zxvf rockstor-jslibs.tar.gz --directory jslibs/js/lib --strip-components=1
echo
fi

which is where we import our rockstor-jslibs, this is then available via the indicated settings.py entry (removed in error/haste in this PR to satisfy a warning that does not have this dynamic import/ build-time context.

@phillxnet
Copy link
Member Author

Preparing a follow-up commit to prove this over-step before representing what we have here.

- Comment STATICFILES_DIRS setting re build.sh & rockstor-jslibs.
@phillxnet
Copy link
Member Author

We have a new sensitivity re collect static:

Post-processing 'js/lib/socket.io.min.js' failed!

Traceback (most recent call last):
  File "/opt/rockstor/.venv/bin/django-admin", line 8, in <module>
    sys.exit(execute_from_command_line())
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 154, in collect
    raise processed
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 372, in _post_process
    content = pattern.sub(converter, content)
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 249, in converter
    hashed_url = self._url(
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 182, in _url
    hashed_name = hashed_name_func(*args)
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 422, in _stored_name
    cache_name = self.clean_name(self.hashed_name(name))
  File "/opt/rockstor/.venv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 143, in hashed_name
    raise ValueError(
ValueError: The file 'js/lib/socket.io.min.js.map' could not be found with <pipeline.storage.PipelineManifestStorage object at 0x7f42e58c1220>.

Initially observed in rpmbuild environment and now reproduced in a regular shell.

@phillxnet
Copy link
Member Author

phillxnet commented Nov 20, 2023

In rockstor-jslibs PR: rockstor/rockstor-jslibs#37

We updated our socket.io.js and did not include the previously optional .map
Investigating if the existence of the equivalent map file:

https://unpkg.com/socket.io-client@4.7.2/dist/socket.io.min.js.map

would resolve this new sensitivity.

In reproducer development setup, after the above noted build.sh (collectstatic) failure, we have a re-run working as intended once we wget the matching socket.io.min.js.map file:

cd /opt/rockstor/jslibs/js/lib
wget  https://unpkg.com/socket.io-client@4.7.2/dist/socket.io.min.js.map
lbuildvm:/opt/rockstor/jslibs/js/lib # ls -lah socket.io.min*
-rw-rw-r-- 1 root root  49K Oct 15 12:23 socket.io.min.js
-rw-r--r-- 1 root root 183K Oct 26  1985 socket.io.min.js.map
...
sh build.sh
...
Skipping 'js/lib/socket.io.min.js' (not modified)
Skipping 'js/lib/underscore.js' (not modified)
Copying '/opt/rockstor/jslibs/js/lib/socket.io.min.js.map'
Skipping 'js/lib/DataTables-addons/file-size.js' (not modified)
Skipping 'js/lib/cron/jquery-cron-window.js' (not modified)
...
Skipping 'js/lib/select2/4.0.3/css/select2.min.css' (not modified)
Skipping 'js/lib/select2/4.0.3/js/select2.min.js' (not modified)
Post-processed 'storageadmin/js/storageadmin.js' as 'storageadmin/js/storageadmin.js'
Skipped post-processing 'storageadmin/js/templates/dashboard/widgets/cpuusage.jst'
Skipped post-processing 'storageadmin/js/templates/dashboard/widgets/disk_util_select.jst'
...
Skipped post-processing 'js/lib/README.md'
Post-processed 'js/lib/socket.io.min.js.map' as 'js/lib/socket.io.min.js.f7ab01fc7228.map'
Post-processed 'admin/js/vendor/select2/i18n/af.js' as 'admin/js/vendor/select2/i18n/af.4f6fcd73488c.js'
...
Post-processed 'js/lib/simple-slider.min.js' as 'js/lib/simple-slider.min.25777b3ef023.js'
Post-processed 'js/lib/socket.io.min.js' as 'js/lib/socket.io.min.62ad1c4cd565.js'
Post-processed 'js/lib/underscore.js' as 'js/lib/underscore.f893e294cde6.js'
Post-processed 'storageadmin/js/storageadmin.js' as 'storageadmin/js/storageadmin.a3e43dd39771.js'

1 static file copied to '/opt/rockstor/static', 514 unmodified, 270 post-processed.

ROCKSTOR BUILD SCRIPT COMPLETED
...

@phillxnet
Copy link
Member Author

The last comments findings re collectstatic failure on missing .map file looks to be related to the following new sensitivity in Django: https://code.djangoproject.com/ticket/33353

@phillxnet
Copy link
Member Author

After merging the referenced off-shoot PR Add socket.io.min.js.map file #39 to the matching testing branch in rockstor-jslibs, we now have a successful rpmbuild, and consequent install/services start with this PR.

@phillxnet
Copy link
Member Author

Resulting fresh install from the resulting rpm of this PR looks to be behaving as expected. I'll move to squashing and representing.

@phillxnet phillxnet closed this Nov 20, 2023
@phillxnet phillxnet deleted the 2750-Update-Django-to-latest-4.2-LTS branch November 20, 2023 19:04
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.

1 participant