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

Establish on_delete for ForeignKey re Django update #2645 #2648

Conversation

phillxnet
Copy link
Member

Adds now required on_delete argument to all ForeignKey and OneToOneField definitions: in both model definitions and all prior migration files. The resulting new migration files for storageadmin (default) and smart_manager were created via:

  • poetry run django-admin makemigrations storageadmin
  • poetry run django-admin makemigrations smart_manager

Fixes #2645

Testing

See referenced issue comments for test application of the resulting migration files. Otherwise this pull request is simply a pre-requisite for our next Django update, see issue #2625; and represents no functional change given we have explicitly added what was previously an implicit default behaviour.

Adds now required on_delete argument to all ForeignKey and
OneToOneField definitions: in both model definitions and
all prior migration files. The resulting migration files
for storageadmin (default) and smart_manager were created
via:

- poetry run django-admin makemigrations storageadmin
- poetry run django-admin makemigrations smart_manager
@phillxnet
Copy link
Member Author

An rpm was build with these changes pre-merged:

rleap15-5:/opt/rockstor # zypper info rockstor | grep Version
Version        : 5.0.2-2648

And the resulting migrations look to have been applied:

Default database (storageadmin)

rleap15-5:~ # cd /opt/rockstor
rleap15-5:/opt/rockstor # export DJANGO_SETTINGS_MODULE=settings
rleap15-5:/opt/rockstor # poetry run django-admin showmigrations

admin
 [ ] 0001_initial
 [ ] 0002_logentry_remove_auto_add
auth
 [X] 0001_initial
 [X] 0002_alter_permission_name_max_length
 [X] 0003_alter_user_email_max_length
 [X] 0004_alter_user_username_opts
 [X] 0005_alter_user_last_login_null
 [X] 0006_require_contenttypes_0002
 [X] 0007_alter_validators_add_error_messages
 [X] 0008_alter_user_username_max_length
contenttypes
 [X] 0001_initial
 [X] 0002_remove_content_type_name
oauth2_provider
 [X] 0001_initial
 [X] 0002_08_updates
 [X] 0003_auto_20160316_1503
 [X] 0004_auto_20160525_1623
 [X] 0005_auto_20170514_1141
 [X] 0006_auto_20171214_2232
sessions
 [ ] 0001_initial
sites
 [ ] 0001_initial
 [ ] 0002_alter_domain_unique
smart_manager
 [ ] 0001_initial
 [ ] 0002_auto_20170216_1212
 [ ] 0003_auto_20230810_1143
storageadmin
 [X] 0001_initial
 [X] 0002_auto_20161125_0051
 [X] 0003_auto_20170114_1332
 [X] 0004_auto_20170523_1140
 [X] 0005_auto_20180913_0923
 [X] 0006_dcontainerargs
 [X] 0007_auto_20181210_0740
 [X] 0008_auto_20190115_1637
 [X] 0009_auto_20200210_1948
 [X] 0010_sambashare_time_machine
 [X] 0011_auto_20200314_1207
 [X] 0012_auto_20200429_1428
 [X] 0013_auto_20200815_2004
 [X] 0014_rockon_taskid
 [X] 0015_auto_20220918_1524
 [X] 0016_auto_20221020_1605
 [X] 0017_auto_20230810_1141

And smart_manager

rleap15-5:/opt/rockstor # poetry run django-admin showmigrations --database=smart_manager smart_manager

smart_manager
 [X] 0001_initial
 [X] 0002_auto_20170216_1212
 [X] 0003_auto_20230810_1143

@phillxnet
Copy link
Member Author

A test_pool and test_share were created and the share was then exported via Samba to create a chain of on_delete object instances.

Deleting the pool did not result in any rockstor.log errors and the Web-UI behaved as expected.

@phillxnet
Copy link
Member Author

test migration from 5.0.2-0 via cli upgrade.

5.0.2-0 was installed and setup from a prior wiped /opt/rockstor: which, given there is not .initrock initrock (rockstor-pre) will drop prior rockstor databases.

zypper in rockstor-5.0.2-0
systemctl start postgresql
systemctl enable --now rockstor-bootstrap

cd /opt/rockstor
export DJANGO_SETTINGS_MODULE=settings
poetry run django-admin showmigrations | tail -n 3
 [X] 0014_rockon_taskid
 [X] 0015_auto_20220918_1524
 [X] 0016_auto_20221020_1605
poetry run django-admin showmigrations --database=smart_manager smart_manager | tail -n 3
smart_manager
 [X] 0001_initial
 [X] 0002_auto_20170216_1212

A cli upgrade was performed to 5.0.2-2648 (lan hosted test repo )

rleap15-5:/opt/rockstor # zypper info rockstor | grep "Version\|Status"
Version        : 5.0.2-2648
Status         : out-of-date (version 5.0.2-0 installed)

# With a zypper install, if there is a newer version - it actually upgrades:
zypper in rockstor

Executing %posttrans scripts ..................................................................................................[done]
There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs.

zypper ps -s

rleap15-5:/opt/rockstor # zypper ps -s
The following running processes use deleted files:

PID   | PPID  | UID | User | Command   | Service
------+-------+-----+------+-----------+---------
19419 | 19403 | 0   | root | python3.6 | rockstor
19420 | 19403 | 0   | root | python3.6 | rockstor
19428 | 19418 | 0   | root | python3.6 | rockstor
19429 | 19418 | 0   | root | python3.6 | rockstor

You may wish to restart these processes.


rleap15-5:/opt/rockstor # zypper info rockstor | grep "Version\|Status"
Version        : 5.0.2-2648
Status         : up-to-date

rleap15-5:/opt/rockstor #  poetry run django-admin showmigrations | tail -n 3
 [X] 0015_auto_20220918_1524
 [X] 0016_auto_20221020_1605
 [ ] 0017_auto_20230810_1141

rleap15-5:/opt/rockstor # poetry run django-admin showmigrations --database=smart_manager smart_manager | tail -n 3
 [X] 0001_initial
 [X] 0002_auto_20170216_1212
 [ ] 0003_auto_20230810_1143

From this last test it appears we are failing to apply our migrations: however we have yet to re-run our initrock (rockstor-pre) where our migrations are applied.

systemctl stop rockstor*
systemctl start rockstor-bootstrap

zypper ps -s
No processes using deleted files found.
...

poetry run django-admin showmigrations | tail -n 3
 [X] 0015_auto_20220918_1524
 [X] 0016_auto_20221020_1605
 [X] 0017_auto_20230810_1141

poetry run django-admin showmigrations --database=smart_manager smart_manager | tail -n 3
 [X] 0001_initial
 [X] 0002_auto_20170216_1212
 [X] 0003_auto_20230810_1143

@phillxnet
Copy link
Member Author

phillxnet commented Aug 14, 2023

Given an in-development fix associated with issue:

Web-UI update fails to recreate venv #2652

We now have a successful Web-UI update from 5.0.1-0 to an rpm build from the product of this pr: resulting in a 5.0.2-2648 rpm.

@phillxnet phillxnet merged commit f6d51fa into rockstor:testing Aug 14, 2023
@phillxnet phillxnet deleted the 2645-Establish-on_delete-for-ForeignKey-re-Django-update branch August 14, 2023 16:29
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

1 participant