-
Notifications
You must be signed in to change notification settings - Fork 5
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
[ADD] Dockerized Odoo OpenUpgrade methodology #1
base: master
Are you sure you want to change the base?
Conversation
We are already making migrations with Doodba, but make a more general approach, as you frequently don't perform the migration on the same system. What we make basically is:
|
Thanks for the elaboration @pedrobaeza. I need something dedicated though unfortunately, otherwise I will not have an upgrade strategy for my SaaS. My current testing here is to see if an upgrade can take place on core using just a standard OpenUpgrade install as you see here, with the final step of the upgrade taking place on the real Odoo instance on a proper scaffold. Something like this: OldOdoo => OpenUpgrade --update all --stop-after-init => NewOdoo --update all --stop-after-init => NewOdoo |
1565cab
to
b50c0c5
Compare
b50c0c5
to
3f838a5
Compare
@pedrobaeza - I updated the instructions in my main PR comment. Basically the goal of this is to provide one centralized upgrade-centric image, then subsequently nail the rest of the contextual upgrades via the scaffolds themselves. This is operating under the assumption, however, that OpenUpgrade is scoped only to core Odoo & that custom modules should contain their own migration scripts that would be executed via the standard update mechanisms. Is this assumption incorrect? cc @yajo |
3f838a5
to
0112ade
Compare
* Create a method to upgrade core Odoo using Docker. Support v8=>9 and v9=>10
0112ade
to
cc7ccdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, although I'm thinking that upgrading separately core addons from extra/private addons does not seem a very good idea... 😕
Apart from the extra time, there's the problem of Odoo being more strict on errors that OpenUpgrade. A normal odoo instance with some addons upgraded and some others not, could easily just not even boot, don't you think?
-e "PGPASSWORD=${PG_PASSWORD}" \ | ||
-e "DB_SOURCE=odoo_v8" \ | ||
-e "DB_TARGET=odoo_v9" \ | ||
laslabs/odoo-upgrade:9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's common that when migrating an addon from, say v8 to v9, the migration scripts from versions 7 and older are removed.
So, I guess you'd have to add 2 extra commands here that build the new project and upgrade it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following? You're meant to step up one version at a time, so I don't think this would be an issue? Assuming upgrading to v9, I would expect the v8=>v9 migration scripts in v9 branch (of OpenUpgrade for core stuff, and the addon dirs themselves for custom). Am I wrong there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean the migration scripts in the addon itself, if any.
README.md
Outdated
|
||
custom_upgrader: | ||
image: your_organization/your_odoo_scaffold_image:9.0 | ||
command: "autoupdate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only work when having installed module_auto_update
, and when that addon is already migrated to the new odoo version, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh crap good call. I'll switch this to a standard odoo --update=all --workers=0
then.
I also submitted Tecnativa/doodba#113 to add a note of such
Also, since you usually will want to CI/CD your updates, and since usage of this needs access to a docker socket, maybe we could consider the upgrade mechanism a part of doodba-qa? |
Does this method allows to prepare a scaffolding similar to doodba? That's the main reason why we use the regular doodba method, because a migration consists not only on OpenUpgrade, but the rest of the OCA modules (or even private ones) that contains migration scripts. I still don't see the reasoning behind this... even for SaaS. |
We're talking maybe 15 extra minutes on an Odoo instance that is not live. Comparing this to the cost of having to maintain upgrade images for all of my scaffolds, it's a clear win I think. It's also worth noting that there are zero out of the box solutions (other than EE) to upgrade an Odoo major version. I think this is a serious problem in the community, and it is causing me issues in discussions with potential customers. While the process may be simple to us, it's an absolute black box for anyone not deeply familiar with Odoo, OCA, and OpenUpgrade specifically.
I'm not sure I'm following here. What errors is OpenUpgrade getting rid of?
My testing so far is pointing towards this not being the case. The Odoo instance missing the custom addons will simply spit out some warnings stating that it is ignoring those addons when booting. The subsequent I think this works because of the dependency graph. While updating with the core modules, we can be naive of the custom ones entirely. A typical upgrade process works up this dependency chain, so by the time the custom modules are touched during a standard process, the core ones they depend on have been upgraded already. The only thing we're doing differently here is double-upgrading core (once with OpenUpgrade core, then another time on the new scaffold in order to update everything else). Taking this a step further, this is how the Odoo Enterprise upgrade works, is it not? I don't think you supply Odoo SA with all your custom addons in order to facilitate that upgrade. I could be wrong there though.
Agreed, but I think that serves a different purpose - both CI and CD would be for the scaffold testing and production deploy respectively. In a typical CI/CD cycle, we would want to end up replacing the previous instance(s) with ones running on a new image by using a fully automated process (other than our standard software QA cycle). The paradigm with Odoo major version upgrades is different - at a minimum you will end up with 2:1 ratio of instances upgraded vs production instances (a testing and an eventual prod). The v11 migrations (which aren't done) really skew this ratio because of failed upgrades, as do custom addons. When it boils down to it, an Odoo major version migration will basically always require manual verification. It would be extremely reckless in my opinion to blindly replace a production Odoo vX with a production vX+1. The goal of this project is to help facilitate the needs of this workflow in as universal of a way as possible. This is a stepping stone to a larger picture though. In one of the systems I need to be able to offer a backup upload mechanism + a form to configure options. My tool will spit out a working, testable instance on the fly. In this light, my upgrade mechanism must be completely different from the actual image in order for me to keep from having to build an image for each upgrade.
You only need link instances with the standard
This mechanism is meant to play intermediary between two Doodba (or any other Odoo) images. The custom addons exist on both sides of the equation, with the missing piece being OpenUpgrade itself + the filestore/database copies. The proposed process from a high level is:
Numbers 2 and 3 from the above list are within scope of this image. 2-5 is all being handled in the sample Edit: better words |
ea4b824
to
887efa3
Compare
…ng old instance in env
Thanks for the elaboration. Indeed it makes sense to have this brick into our wall. Let me explain a couple of my points:
What I meant is that version updates should be tested before deployed to production. Thus, I imagine a good minimal upgrade CI pipeline would be:
The instructions you supplied are in the form of docker (or compose) commands, and those need access to the docker socket. Since doodba-qa is designed to have such access, that's why I meant it would be a good place to put this in. If such a thing is there, one could define this pipeline in a variables:
COMPOSE_FILE: test.yaml
stages:
- restore
- migrate
- runbot
Restore latest production database:
stage: restore
script:
- docker-compose -f prod.yaml run --rm -e PGDATABASE=test backup sh -c 'restore --force && psql -d postgres -c "CREATE DATABASE $PGDATABASE" && pg_restore /mnt/src/prod.pgdump | psql' # This is a good candidate to a script called i.e. "restore"
Migrate DB to next version:
stage: migrate
variables:
UPGRADE_FROM_ODOO: 8.0
script:
- migrate # This script would contain the migration magic, possibly expanding a little bit the instructions linked above
Boot runbot:
stage: runbot
script:
- docker-compose up -d If it all worked, you can go to runbot, download zip of database, and upload it to the new, empty, production vX+1 server 😊 (or do a new script that deploys it, and is ran only manually). Besides, if we do this, we can leverage all the doodba power and make it flip the switch on odoo repo remotes before doing all of this, so you don't actually have to maintain your upgrade scaffolding, nor this one, and still skip the problem of upgrading twice. It would be quite more powerful for us Doodbers, although hard to use in for others I guess. |
Thanks for the explanation, @yajo. I think we share a similar vision here, just with a different strategy.
I think this is a good idea. This would allow for a demo-data upgrade test process too. Basically unit tests for upgrades.
Wouldn't Runbot also have a live image to functionally review too? Similar to our current Runbot QA process?
If you really feel that this is a problem, I can add a script to simply look through the module manifest, exclude the core addons, and add a comma separated list to the
This is my problem - my scope is larger than people using our specific tools. Our community is fractured, and continuing to expand this rift is not in our best interests. The situation from my end is that I am not currently recommending Odoo for my new (non-managed) customers due to this rift (SpreeCommerce is the recommended at the moment). There are too many specifics, and there are too many gotchas [with the major version upgrade process & packaging/installation of modules]. Version lock is an absolute real issue, and my customers are not bound to using my frameworks for their deploys. Adding another layer of specific infrastructure is what I am trying to ward against here. The strategy I am proposing here requires only Docker. I am even in the process of making a strategy for bare metal conversions using this same image. Basically it downloads the database dump from an external Odoo, then spits the files you need out in another dump on a volume. A web based tool could expand upon this for an upload/download migration cycle, with the final steps being a |
f28bf00
to
e9835d9
Compare
e9835d9
to
bc26a0b
Compare
I have some interesting news as I refine this further. When starting the second instance, if you omit This is because the
I subsequently started the target image as normal, which updated the rest of the modules and left me with:
I now fully believe this is a valid strategy for migrating instances, and am pretty excited about the results 🚀 Edit: Ah crap so I was looking further into the target image, and I forgot that I have a So yeah that's the solution, but as I'm looking even further I'm thinking it's still updating the addons twice. |
22731bc
to
0d5b9fa
Compare
Of course, that's a runbot! I meant that you can do that if your functional tests pass.
I know, I tried to fix that, but it seems just impossible right now, so we decided just to be pragmatic and start this Doodba micro-community. It's actually growing faster than expected...
Well, our way has become much easier and our evolution much faster since we took the path of making decisions and setting infrastructure minimal requirements, and since it's been such a good experience, I'm just recommending you to do the same, although maybe it's not your case, of course. If that doesn't fit you, then I'd recommend you the way of ansible-container, which gets ansible roles and uses them to build docker images. You can still use the roles in bare metal or wherever, or just use Docker as usual.
😮 Nice! |
The only doubt I have with this is if end-migration scripts for already migrated modules are executed in that case... |
Is that an OpenUpgrade's or Odoo's feature? |
end-migration? Both. |
Then I guess OpenUpgrade ones will trigger after 1st migration, and single scripts will trigger after 2nd migration |
That's my thought as well. Do you by any chance know of some module combination I could test to see? |
Well, base module has an end-migration in v9, v10 and v11, so you can test any of them, interrupt the process, and see if at the end disable_invalid_filters call is made. |
Hmmmm ok so maybe I actually don't understand what an |
end migrations are run at the very end, when all modules have been already update. Example: https://github.com/OCA/OpenUpgrade/blob/11.0/odoo/addons/base/migrations/11.0.1.3/end-migration.py |
Ohhhh cool so this is in OpenUpgrade - I completely get it now. I was in the odoo/odoo base module and there weren't even any migrations. I was rather confused. Thanks for the elaboration Pedro, I'll test and get back to you all! |
The engine is in Odoo itself, but it's not used there. You can find doc on https://github.com/odoo/odoo/blob/22e458775a1757e9952bfb498b0014906825358a/odoo/modules/migration.py#L51-L74 |
It looks like end migrations are run every time the server is booted, although base is actually treated differently. Here's the relevant code vs. here is the actual migration process. The migration process itself seems to be capsuled within its own transaction, with this module loading happening in a transaction of its own as well. Looks safe enough to me, and if not I assert that it is a bug in Odoo. I've had plenty of servers die in the middle of a migration process, and they all came back fine once I resolved the underlying issue (usually missing dependencies before I added |
OK then. It seems correct. |
0d5b9fa
to
676e45a
Compare
Docker Odoo Upgrade
This image upgrades Odoo major versions using OpenUpgrade. This is an
experimental upgrade methodology, and care should be taken if using for
production environments.
This repository is tagged by the Odoo version that is being targeted, and
you can only upgrade one version at a time. Each tag is represented by a
Dockerfile, prefixed with the tag name. For example, to upgrade version
8 to version 10, you need to use the:
Basic Instructions
High level usage of this image is as follows:
/var/lib/odoo_old
filestore
directory, but the one that contains thefilestore
andsessions
directories (among others)./var/lib/odoo
filestore
directory, but the one that contains thefilestore
andsessions
directories (among others).db_old
db
major version upgrades.
PGUSER
,PGPASSWORD
)db credentials if not defined. (
PGUSER_OLD
,PGPASSWORD_OLD
)DB_SOURCE
,DB_TARGET
)Given the above, and assuming the below:
postgresql
odoo_user
with the passwordodoo_password
that has superuseraccess to the database.
odoo_v8
/var/lib/odoo_v8
You would run the following commands:
Running the above, you will be left with an Odoo v9 and an Odoo v10 database &
filesystem. They will be named
odoo_v9
andodoo_v10
respectively.You typically want to run one migration at a time, and validate that it works before
proceeding to the next one. Living on the edge can be fun though.
Docker-Compose Instructions
The above section is mostly instructional usage, in that it uses plain Docker and
does not consider custom addons that you may have in your installation. Instead, you
would want to use a
docker-compose.yml
file similar to the below:After running the above, you will be left with a running Odoo v9 instance
that was upgraded from your Odoo v8 instance.
Using a Live Instance
This image provides the ability to obtain an Odoo backup on the fly, instead
of having to mount the old volume and database. To enable this functionality,
you should set the following environment variables on the upgrader instance:
ODOO_URI_OLD
: The base URI of the old Odoo instance, includinghttp(s)://
ADMIN_PASSWORD_OLD
: The database administration password for the old Odooinstance.
The Odoo instance that you provide must have the capability of delivering a
database backup through its web interface. This is usually not possible in
production due to time limits, but that is easy enough to work around and out
of scope here.
Assuming the following:
postgresql
running~/odoo_v10_test
on your hosthttps://odoo.example.com
odoo_v9
odoo_v10
odoo
Then a docker run command to upgrade a v9 to v10 would look something like this:
You would subsequently launch your v10 environment as normal, making sure
to configure the
data_dir
anddb_host
parameters appropriately.Upon first launch, your custom modules will be upgraded. This is because the
upgrade image is only scoped to Odoo core modules, but makes sure to flag the
remainder of the modules for upgrade as well.