Problems upgrading to Plone 6.2

When pushing Plone 6.2 to a testing server we faced the following problems:

All pages were broken due to the migration tool trying to check if the current profile was up-to-date, the stack trace:

  File "plone/rest/service.py", line 21, in __call__
    return self.render()
  File "plone/distribution/services/sites/get.py", line 52, in render
    content = self.reply()
  File "plone/distribution/services/sites/get.py", line 143, in reply
    "default_values": self._populate_server_defaults(dist),
  File "distribution/services/sites/get.py", line 98, in _populate_server_defaults
    all_sites = self.get_sites()
  File "plone/distribution/services/sites/get.py", line 87, in get_sites
    "needs_upgrade": _is_outdated(plone_site),
  File "plone/distribution/services/sites/get.py", line 28, in _is_outdated
    is_outdated = mig.needUpgrading() if mig else False
  File "Products/CMFPlone/MigrationTool.py", line 213, in needUpgrading
    return self.getInstanceVersion() != self.getFileSystemVersion()
  File "Products/CMFPlone/MigrationTool.py", line 171, in getInstanceVersion
    version = setup.getVersionForProfile(profile)
  File "Products/GenericSetup/tool.py", line 911, in getVersionForProfile
    return self.getProfileInfo(profile_id).get('version', UNKNOWN)
  File "Products/GenericSetup/tool.py", line 942, in getProfileInfo
    return _profile_registry.getProfileInfo(profile_id)
  File "Products/GenericSetup/registry.py", line 693, in getProfileInfo
    raise KeyError(profile_id)

The missing bit was to set a _baseline_context_id on portal_setup.

The value was copied by checking what a freshly new installed Plone website had there.

from plone import api
import transaction

psetup = api.portal.get_tool('portal_setup')
migtool = api.portal.get_tool('portal_migration')

psetup._baseline_context_id = 'profile-Products.CMFPlone:plone'
migtool.get_profile()
transaction.commit()

Fixing the above showed yet another problem: plone.distribution is storing an annotation on the plone site root that was missing in our website and that broke again the migration tool.

Again, like on the previous case, checking what's the value of a fresh instance and copying it over solved the day.

from plone import api
from zope.annotation.interfaces import IAnnotations
from plone.distribution.api.site import _add_report_to_site
import transaction

anot = IAnnotations(api.portal.get())
anot['__plone_distribution_report__']

_add_report_to_site(api.portal.get(), 'der Freitag', {})

anot['__plone_distribution_report__']
transaction.commit()

This site was created +15 years ago, and since then upgraded in-place.

A few questions about the above:

  • are the patched solutions sound?
  • should this be handled in plone.app.upgrade or plone.distribution should be more forgiving?
  • I’m a bit puzzled on why is it happening now and not since plone.distribution got added in Plone 6.0/6.1 ?
  • for the first problem, I see on Products.GenericSetup there is setBaselineContext which runs applyContextById, not having run that is that going to be a problem down the road? :thinking:
  • likewise for the second problem, leaving the questions as an empty dictionary is problematic? the last parameter on _add_report_to_site
2 Likes