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

Remove the CAN_INSTALL file when occ maintenance:install is complete #27492

Conversation

alexharpin
Copy link
Contributor

When occ maintenance:install is run from the CLI, the CAN_INSTALL in the config directory is left in place when installed is set to true, whereas this file is removed when the web installer is used. Removing this file in the CLI command maintains consistency between the two. This allows automation tools an easier way to determine if this process has been completed.

Signed-off-by: Alex Harpin development@landsofshadow.co.uk

@alexharpin
Copy link
Contributor Author

I came across this when creating a Kubernetes deployment for Nextcloud, with a batch job to perform the initial setup. I'd expected the CAN_INSTALL to be removed when the setup had completed, in the same manner as the web installer, so was using the presence of this file in an init container to delay the deployment of the frontend Apache container. Worked around this issue by delete the file in the batch job instead for now.

@alexharpin
Copy link
Contributor Author

Resolves #24301

@alexharpin
Copy link
Contributor Author

Looks like a few of the CI tests failed due to git clone issues :(

@juliushaertl
Copy link
Member

Good catch, would be good to also check the return value of unlink and log an error in case the file was not removed.

@alexharpin
Copy link
Contributor Author

@juliushaertl Would you class this enough of an error to return it in the error array from the install method in the Setup class, which would then be handled in the install command, returning with an exit code of 1 instead of 0 (core/Command/Maintenance/Install.php:109), or just log the fact it couldn't be removed?

@alexharpin
Copy link
Contributor Author

Little bit of a rework as the SetupController was calling the install method of the Setup class, so was duplicating the check to unlink the CAN_INSTALL file. Resolved that and added logging to the CLI command to output a warning that the file needs to be removed manually (matching the web installer).

@szaimen
Copy link
Contributor

szaimen commented Aug 31, 2021

@cyclops8456 any update here?

@szaimen
Copy link
Contributor

szaimen commented Apr 7, 2022

@cyclops8456 any update here?

@szaimen
Copy link
Contributor

szaimen commented Apr 25, 2022

Would this be a solution to #18620 ?

This was referenced Aug 12, 2022
This was referenced Aug 24, 2022
This was referenced Sep 6, 2022
@skjnldsv skjnldsv mentioned this pull request Sep 15, 2022
This was referenced Sep 20, 2022
@blizzz blizzz modified the milestones: Nextcloud 25, Nextcloud 26 Sep 22, 2022
When occ maintenance:install is run from the CLI, the CAN_INSTALL in the config directory is left in place when installed is set to true, whereas this file is removed when the web installer is used.  Removing this file in the CLI command maintains consistency between the two.  This allows automation tools an easier way to determine if this process has been completed.

Signed-off-by: Alex Harpin <development@landsofshadow.co.uk>
Move the check for the CAN_INSTALL file in the config directory to a method in the Setup class and remove the call to unlink from the SetupController as this in now handled in the Setup class.

Signed-off-by: Alex Harpin <development@landsofshadow.co.uk>
Log a warning for the CLI install command if the CAN_INSTALL file still exists at the end of the installation.  This matches the warning logged by the web installer.

Signed-off-by: Alex Harpin <development@landsofshadow.co.uk>
Rename canInstallExists to shouldRemoveCanInstallFile to cover removal of this file for non-git channels and logging any failure to remove it.

Add new method to detect if this file exists during web based installation.

Signed-off-by: Alex Harpin <development@landsofshadow.co.uk>
@alexharpin
Copy link
Contributor Author

@szaimen Regarding #18620, this wouldn't have resolved that particular case, but the fix for that could still be impacted by the non-removal of the CAN_INSTALL file, at least for CLI installation (so more for automated installs).

@alexharpin alexharpin force-pushed the feature/24301-remove-can-install-on-occ-maintenance-install branch from 5c3a37d to 644df59 Compare January 11, 2023 10:38
@alexharpin
Copy link
Contributor Author

@szaimen @juliushaertl Returning to this MR after getting snowed under with other work and completely forgetting about it. I've rebased my branch against current master and have tested it locally for both web and CLI based installs and the CAN_INSTALL file is removed as expected in both cases now. This should mean that automated installs don't need to do this manually now, and I can remove it from my Kubernetes deployment config.

@szaimen szaimen added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 11, 2023
@szaimen szaimen requested review from a team, ArtificialOwl, icewind1991, blizzz and juliushaertl and removed request for a team January 11, 2023 23:00
@szaimen
Copy link
Contributor

szaimen commented Jan 18, 2023

failing CI likely unrelated

@szaimen szaimen merged commit 06a572f into nextcloud:master Jan 18, 2023
@welcome
Copy link

welcome bot commented Jan 18, 2023

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants