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

Support enabling IPM instance-wide #485

Merged
merged 22 commits into from
Oct 10, 2024
Merged

Support enabling IPM instance-wide #485

merged 22 commits into from
Oct 10, 2024

Conversation

isc-tleavitt
Copy link
Contributor

@isc-tleavitt isc-tleavitt commented May 22, 2024

This is done via new options in the existing zpm "enable" command that add package mappings.

We looked into using %ALL but ultimately that doesn't work, because namespace-specific mappings aren't allowed to override %ALL mappings (!?).

Fixes #470

Even %SYS, but not using the %ALL namespace because that ends up overriding namespace-specific mappings (gah).
@isc-tleavitt isc-tleavitt changed the base branch from master to v1 May 22, 2024 20:09
Copy link
Collaborator

@isc-kiyer isc-kiyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isc-tleavitt a few comments but looks good!

src/cls/IPM/Main.cls Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Show resolved Hide resolved
src/cls/IPM/Main.cls Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
@gjsjohnmurray
Copy link
Contributor

namespace-specific mappings aren't allowed to override %ALL mappings (!?).

This always struck me as an unfortunate design choice. Too late to get it changed now, but maybe a second pseudo-namespace %DEFAULT could be added whose mappings defer to namespace specific ones.

src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
@isc-tleavitt
Copy link
Contributor Author

namespace-specific mappings aren't allowed to override %ALL mappings (!?).

This always struck me as an unfortunate design choice. Too late to get it changed now, but maybe a second pseudo-namespace %DEFAULT could be added whose mappings defer to namespace specific ones.

@gjsjohnmurray thanks for chiming in! I like the idea and will float it, but we won't be able to make it a prerequisite for this work.

@isc-shuliu isc-shuliu marked this pull request as ready for review September 20, 2024 14:56
@isc-shuliu
Copy link
Collaborator

Not sure why the CIs are failing.

Tried to run the tests locally on 9b19985 it still fails although CIs passed in May ...

@isc-shuliu
Copy link
Collaborator

It appears the CI failure stems from this block

If '$Get(pParams("Verify","InCurrentNamespace"),0) {

@isc-tleavitt isc-tleavitt requested review from isc-shuliu and removed request for gjsjohnmurray September 23, 2024 12:50
@isc-tleavitt
Copy link
Contributor Author

Next steps here for @isc-shuliu who's carrying this work forward:

  • Revert the changes to the MapOnly installer XData block and associated method, as they're causing the CI issues and are generally problematic
  • Reevaluate against criteria in Review and improve installation modes #470

@isc-shuliu
Copy link
Collaborator

isc-shuliu commented Sep 25, 2024

CIs are failing specifically in I4H because migration was not successful (see log line 1362). This failure was introduced by changes in bf6e699 which attempts to perform data migration in all namespaces

Guess I shouldn't perform it in all namespaces according to this comment

// Intentionally runs for current namespace only
but I'm not sure why.

@isc-tleavitt Any insights?

@isc-shuliu
Copy link
Collaborator

This PR should now meet the requirement in #470 (comment) . Specifically,

It should be easy to say, after installing IPM, "I want this version of IPM to be used in all namespaces"

This can be done by mapping the current IPM globally

It should be easy to upgrade IPM instance-wide from any namespace to which the instance-wide installation is mapped (note: IPM installed version metadata needs to be tracked in the right DB!) - this might mean tracking the namespace through which IPM is managed, and only allowing upgrades through that namespace.

This is achieved by checking whether IPM in current NS is mapped if a user attempts to install/reinstall/uninstall IPM. If IPM is mapped from elsewhere, will abort and prompt the user to go the source namespace.

It should be easy, with or without an instance-wide installation of IPM, to install and run different IPM versions in different namespace.

This is achieved by adding the unmap command which allows a user to unmap IPM in give namespaces.

There should be a way to see which namespaces have IPM available, at which versions, and where it's mapped from in each namespace.

The zpm "version" command will show IPM versions from all namespaces, and if applicable, where it's mapped from.

Interactive use of the zpm command should direct the user properly if IPM is not available in the current context.

If IPM is not installed, will iterate through all namespaces and run zpm "version" in the first namespace found that has IPM installed.

After enabling of IPM in a namespace with 0.7.x (or earlier) installed, need to run the data migration process.

%IPM.Utils.Migration:MigrateZPMToIPM() will be called in each namespace

@isc-tleavitt
Copy link
Contributor Author

CIs are failing specifically in I4H because migration was not successful (see log line 1362). This failure was introduced by changes in bf6e699 which attempts to perform data migration in all namespaces

Guess I shouldn't perform it in all namespaces according to this comment

// Intentionally runs for current namespace only

but I'm not sure why.
@isc-tleavitt Any insights?

The issue here is:

Migrating ZPM data to IPM... in namespace HSCUSTOM
Migrating repo registry... 
IPM data migration was not fully successful. You may be able to reinstall the impacted packages to correct the issues.
ERROR #5809: Object to Load not found, class '%IPM.Storage.Module', ID '1'

Migrating ZPM data to IPM... in namespace HSLIB
IPM data migration was not fully successful. You may be able to reinstall the impacted packages to correct the issues.
ERROR #5002: ObjectScript error: <PROTECT>SetMapSelectability+17^%SYSTEM.SQL.Util.1 ^rINDEXEXT("MS","%IPM_Storage","ModuleItem","IDKEY"),/usr/irissys/mgr/hslib/

Migrating ZPM data to IPM... in namespace HSSYS
Migrating repo registry... 
IPM data migration was not fully successful. You may be able to reinstall the impacted packages to correct the issues.
ERROR #5809: Object to Load not found, class '%IPM.Storage.Module', ID '1'

Migrating ZPM data to IPM... in namespace HSSYSLOCALTEMP
Migrating repo registry... 
IPM data migration was not fully successful. You may be able to reinstall the impacted packages to correct the issues.
ERROR #5809: Object to Load not found, class '%IPM.Storage.Module', ID '1'

Two classes of issues here:

  • HSLIB: here we can't migrate because the HSLIB database is read-only. In this case, we want to just skip. (Should be able to detect this.)
  • Others: likely related to presence of IPM in HSLIB itself but kind of hard to pinpoint with available data.

Ultimately, I think the issue is going to be that we should only try to migrate a namespace's data after it's mapped.

Data migration post-installation should migrate everywhere that is already mapped (mostly will be useful for future automatic data migrations); mapping should migrate the newly-mapped namespace. The automatic mapping post-installation on an environment with older ZPM will end up migrating each namespace as it's mapped. That covers all scenarios.

Copy link
Contributor Author

@isc-tleavitt isc-tleavitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #485 (comment) - soooo close.

src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Utils/Migration.cls Show resolved Hide resolved
@isc-shuliu
Copy link
Collaborator

@isc-tleavitt I updated the migration logic to run only in namespaces where %IPM is mapped from the current namespace. This resolved the problem for HSLIB but still doesn't successfully migrate HSCUSTOM, HSSYS, and HSSYSLOCALTEMP.

In I4H, HSCUSTOM, HSSYS, and HSSYSLOCALTEMP did not have %IPM mapping initially. Upgrading from %ZPM to %IPM automatically adds %IPM mapping for them. However, data migration still fails in these 3 namespaces.

@isc-shuliu
Copy link
Collaborator

@isc-tleavitt I think I figured out why:

In ##class(%IPM.Utils.Migration).MigrateOneRepo(), we should check for

Set newObj = ##class(%IPM.Repo.Definition).%OpenId(newId,,.sc)

instead of

Set newObj = ##class(%IPM.Storage.Module).%OpenId(newId,,.sc)

This is likely an error due to copy-paste from MigrateOnePackageToIPM()

@isc-tleavitt
Copy link
Contributor Author

@isc-shuliu goooood catch! Thank you!

@isc-tleavitt
Copy link
Contributor Author

I can't approve this (since it was originally my PR), but I think it's in a good state; would appreciate an eye on this from @isc-kiyer next week.

Copy link
Collaborator

@isc-kiyer isc-kiyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isc-shuliu a few comments. Can maybe skip the one about changing the structure of the subscripted array to JSON since that would be more invasive (just the current structure is quite hard to follow).

@@ -35,6 +35,7 @@ XData PM [ XMLNamespace = INSTALLER ]
<Arg Value="${MODDIR}"/>
</Invoke>
<Invoke Class="IPM.Installer" Method="ZPMCompile" CheckStatus="true" />
<Invoke Class="IPM.Installer" Method="MapIfLegacy" CheckStatus="true" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General question: how do you decide what should go into this installer block vs in the module.xml? Should each invoke here be there too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that <Invoke>s in module.xml should be a (not necessarily proper) subset of Installer.cls since a legacy user can always download a release artifact from GitHub or community PM registry.

Not sure if there are <Invoke>s that we only want present in Installer.cls but not module.xml.

@isc-tleavitt Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, things only need to go into module.xml and the installer will run them. The issue here is in setting up mappings in advance of load when someone is already running legacy %ZPM and upgrades by loading/running an installer; that's why this particular thing needs to be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait - I'm wrong, we shouldn't need this because the above (line 34) call to ZPMLoad will end up running all the <Invoke>s.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confusing this with:
<Invoke Class="IPM.Installer" Method="Map" Phase="Reload" When="Before" />

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isc-shuliu @isc-tleavitt so should the installer invokes be removed in favor of the Invoke's in module.xml? The installer then essentially installs the module using itself which would run invokes from the module.xml?

src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
src/cls/IPM/Main.cls Outdated Show resolved Hide resolved
Quit $$$OK
}

If tModuleName = $$$IPMModuleName {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check should be moved to LoadNewModule instead to catch the case from the load command as well instead of just the install command. Before loading the file using $System.OBJ.Load(), can read the module name using xslts to confirm whether it can be loaded in the current namespace.

// but need to decide what level of customization to provide
Quit ""
// TODO: Needs to support enabling IPM from here, also need to decide what level of customization to provide
Set tQuitOnError = $Get(pArgs(2))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this quit/halt on error stuff a general feature of ZLANG or something specific here? Could you add some more doc about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specific to the zpm command - should be covered in doc for %IPM.Main:Shell.

@isc-tleavitt isc-tleavitt merged commit 72fb28e into v1 Oct 10, 2024
15 checks passed
@isc-tleavitt isc-tleavitt deleted the v1-enable-globally branch October 10, 2024 16:54
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.

4 participants