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

CLOUDSTACK 9601: Upgrade: change logic for update path for files #1768

Merged
merged 1 commit into from Feb 28, 2017

Conversation

marcaurele
Copy link
Member

For going from version A to version D, it uses to run the SQL files in
that order: A -> B -> C -> D -> A-cleanup -> B-cleanup -> C-cleanup ->
D-cleanup. If you had upgraded each version separatively you would have
run A -> A-cleanup -> B -> B-cleanup -> C -> C-cleanup -> D ->
D-cleanup.
This change the logic to follow the same path if you are jumping over
versions.

Signed-off-by: Marc-Aurèle Brothier m@brothier.org

@marcaurele
Copy link
Member Author

The second commit can be removed if the cleanup is not wanted.

@rohityadavcloud
Copy link
Member

This may break db upgrade, as the cleanup paths are run at the end. Can you prove if changing the sequence will be idempotent? Thanks.

@marcaurele marcaurele force-pushed the fix/CLOUDSTACK-9601 branch 4 times, most recently from b51bc32 to 0cb584c Compare February 21, 2017 13:20
@marcaurele
Copy link
Member Author

@rhtyd Changing the sequence is only idempotent if you have been upgrading to each new versions step by step. If you jumped other versions, then the path is different for each original version. This fix wants to avoid such a difference.

@serg38
Copy link

serg38 commented Feb 21, 2017

@marcaurele I tend to agree with @rhtydthat it could break some of the upgrades. If I get it right with your proposed changes, upgrade scripts become obsolete since all the changes can be done in upgrade scripts.

@marcaurele
Copy link
Member Author

@serg38 Not sure to understand what you mean with:

If I get it right with your proposed changes, upgrade scripts become obsolete since all the changes can be done in upgrade scripts.

You meant: If I get it right with your proposed changes, upgrade cleanup scripts become obsolete since all the changes can be done in upgrade scripts. ?

@marcaurele
Copy link
Member Author

I'll try to make my point clearer with a better use case. Let say you were running version ACS 4.4.2 and wish to upgrade to 4.7.1. After installing the 4.7.1, when ACS starts for the first time you will execute SQL scripts in that order (case A):

schema-442to450.sql       -----> schema-442to450-cleanup.sql
      |                  |             |
      v                  |             v
schema-450to451.sql      |       schema-450to451-cleanup.sql
      |                  |             |
      v                  |             v
schema-451to452.sql      |       schema-451to452-cleanup.sql
      |                  |             |
      v                  |             v
schema-452to460.sql      |       schema-452to460-cleanup.sql
      |                  |             |
      v                  |             v
schema-460to461.sql      |       schema-460to461-cleanup.sql
      |                  |             |
      v                  |             v
schema-461to470.sql      |       schema-461to470-cleanup.sql
      |                  |             |
      v                  |             v
schema-470to471.sql >----        schema-470to471-cleanup.sql

But if you would have updated to each versions, one after the other, you would have run those scripts in that order (case B):

schema-442to450.sql -----> schema-442to450-cleanup.sql
                                 |
       --------------------------
      |
      v
schema-450to451.sql -----> schema-450to451-cleanup.sql
                                 |
       --------------------------
      |
      v
schema-451to452.sql -----> schema-451to452-cleanup.sql
                                 |
       --------------------------
      |
      v
schema-452to460.sql -----> schema-452to460-cleanup.sql
                                 |
       --------------------------
      |
      v
schema-460to461.sql -----> schema-460to461-cleanup.sql
                                 |
       --------------------------
      |
      v
schema-461to470.sql -----> schema-461to470-cleanup.sql
                                 |
       --------------------------
      |
      v
schema-470to471.sql -----> schema-470to471-cleanup.sql

Since case B is that most developer would expect when fixing bugs and doing changes, but case A is the most common case of production upgrade, I wanted to correct the algorithm so that everyone will follow the same route (case B).

Most -cleanup.sql scripts are either empty or only updating the configuration table, so it's safe. There is only one possible problematic script: https://github.com/apache/cloudstack/blob/master/setup/db/db/schema-481to490-cleanup.sql today. This one does change views, which IMO was a mistake to put in the cleanup script file, it should have gone into schema-481to490.sql (@rhtyd ?). Leaving the mechanism as it is today would leave people with a possible bug while upgrading from any version prior to 4.9.0 if any future SQL script was to change the views modified inside schema-481to490-cleanup.sql because of scenario case A. Did I lost people there?

Any comment @remibergsma @DaanHoogland @syed @nvazquez ?

For going from version A to version D, it uses to run the SQL files in
that order: A -> B -> C -> D -> A-cleanup -> B-cleanup -> C-cleanup ->
D-cleanup. If you had upgraded each version separatively you would have
run A -> A-cleanup -> B -> B-cleanup -> C -> C-cleanup -> D ->
D-cleanup.
This change the logic to follow the same path if you are jumping over
versions.

Signed-off-by: Marc-Aurèle Brothier <m@brothier.org>
@DaanHoogland
Copy link
Contributor

@marcaurele your point is clear and valid. I see that the change worries people as it will actually change existing upgrade paths.
@serg38 @marcaurele 's version of your comment doesn't hold if changes in java are encoded as well!
/me about to look at the code

@DaanHoogland
Copy link
Contributor

LGTM but
I hope you appreciate the concerns @marcaurele , on the other hand let's fix what breaks and make sure the 4.9 to 4.10 works with this. We can always advice to upgrade to 4.9 before going up.

@DaanHoogland
Copy link
Contributor

btw @marcaurele @rhtyd idempotent will only be possible if we encode it. It is not encoded in older upgrades. Unless we clean those upgrades up we will have some issues.

@DaanHoogland
Copy link
Contributor

@karuturi I think this should go in. Even being a bit of a risk, it will potentially reduce the support hours on upgrades.

@marcaurele
Copy link
Member Author

As a reminder for -cleanup SQL scripts:

We rarely need cleanup scripts, only when some field/value is required during the data migration and has to be dropped later on.

https://cwiki.apache.org/confluence/display/CLOUDSTACK/DB+Upgrade+in+CloudStack

@syed
Copy link
Contributor

syed commented Feb 22, 2017

I agree with @DaanHoogland , as @marcaurele mentioned, the only file we need to worry about is schema-481to490-cleanup.sql the rest of them are either empty or change the configuration where the order of execution doesn't really matter. Looking at it briefly it looks like it modifies ovs_tunnel_network table which is used to manage OVS tunnels when using non-vlan isolation. I've never seen anyone use this in production. Would be useful if we can find someone who has used this before. Or if no one is using, it is LGTM from me as well.

@marcaurele
Copy link
Member Author

@syed I would prefer to move what's inside schema-481to490-cleanup.sql to the end of the file schema-481to490.sql as it would have been the way of processing during an update from 481 to 490.
If I get the go about the move, I'll do it too in this PR.

@DaanHoogland
Copy link
Contributor

@syed the -cleanup scripts are for removing data that had been migrated, not for temporary tables. also a use case for those may be if things are done partly in the migrate script and partly in the migrate class, though I can't think of a real instance of that use case.
as for the ovs-tunnel code, we don't have to loose that, do we? SO even with people using it we can apply this.

@DaanHoogland
Copy link
Contributor

@blueorangutan package

@DaanHoogland
Copy link
Contributor

@blueorangutan help

@borisstoyanov
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@borisstoyanov a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-532

@marcaurele
Copy link
Member Author

I looked at the code inside Upgrade481to490.java and I cannot understand why the table alterations have been made inside the Java class instead of the SQL file. Because now we cannot move the code from the -cleanup without changing that class too, other the column role_id won't be present when creating the account_view.
To make the change transparent, I'll have to change those too. I'll push another commit for that.

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@marcaurele
Copy link
Member Author

Forget my last comment, the files can remains as they are.

@remibergsma
Copy link
Contributor

@marcaurele Nice improvement, thanks! Tested it and works as you described. LGTM.

@karuturi
Copy link
Member

@DaanHoogland Can you post test results?

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@rohityadavcloud
Copy link
Member

@marcaurele can we have a unit test to confirm that this does not break upgrade for older systems, also by changing the order for all older versions, the way someone would upgrade from say 4.3 to 4.10, will be different from someone who upgraded from 4.3->4.9->4.10 -- this may have side effects.

@marcaurele
Copy link
Member Author

@rhtyd I don't see how I could write such a test case. My point is exactly what you're saying, the upgrade would be different today for anyone who comes from an older version, which I don't think you're currently testing. I want to avoid such situation, therefore I'm pushing this PR to stop having different upgrade paths.
Can you be more explicit in what you think can become a problem compared to the current situation we're in today?

@karuturi
Copy link
Member

karuturi commented Feb 28, 2017

Actually, BVT is not going to verify this as this is db upgrade related and travis would have tested it.
I will merge this once @rhtyd and @marcaurele come to an agreement

@@ -424,27 +421,9 @@ protected void upgrade(CloudStackVersion dbVersion, CloudStackVersion currentVer
}

upgrade.performDataMigration(conn);
boolean upgradeVersion = true;

if (upgrade.getUpgradedVersion().equals("2.1.8")) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about the implications, but since 2.x is a very old version -- we need to put in our release notes that we won't support upgrades from very old 2.x releases. We can in that case even remove all 2.x upgrade paths.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought that anything older than 4.x should be removed. The simulator and DB schema create a structure based on 4.0.0 or 4.1.0 if I recall correctly.
I initially added another commit (removed now) which was only leaving upgrade paths from version 4.0.0. That can be done later, and I think it would be a good cleanup.

@rohityadavcloud
Copy link
Member

@marcaurele I appreciate the cleanup, it should have been like this from the beginning but since we've the workflow to execute all the upgrades first and then the cleanup. In https://github.com/apache/cloudstack/blob/master/setup/db/db/schema-481to490-cleanup.sql the views are executed at the end because certain columns are added by the java based upgrade path and views can only access them after the script/java-based-upgrade is complete. I think with this change future db upgrade paths need to written carefully.

I've no objections with the overall goal to cleanup the sequence logic, though I have a concern that this might cause upgrade regressions in some environments as writing upgrade validation tests may not be possible. /cc @DaanHoogland @karuturi

@DaanHoogland
Copy link
Contributor

@rhtyd I don't see how your concern is more true for the new code by @marcaurele then it is true for old code. cleanup is still going to be executed after the scripts, is it? only directly after instead of waiting for unrelated upgrade scripts to complete as well. We never have and never can have full coverage of upgrades as every cloud is a different snowflake. So we'll need to fix problems after intitial release most of the time. That is no worse or better with this code it is just a little more predictable.

@DaanHoogland
Copy link
Contributor

1768.network.results.txt
1768.vpc_routers.results.txt

just for form @karuturi . I see failures in network but can not relate these to the upgrades

@karuturi
Copy link
Member

Thanks everyone. merging this now.

@asfgit asfgit merged commit ea8814f into apache:master Feb 28, 2017
asfgit pushed a commit that referenced this pull request Feb 28, 2017
CLOUDSTACK 9601: Upgrade: change logic for update path for filesFor going from version A to version D, it uses to run the SQL files in
that order: A -> B -> C -> D -> A-cleanup -> B-cleanup -> C-cleanup ->
D-cleanup. If you had upgraded each version separatively you would have
run A -> A-cleanup -> B -> B-cleanup -> C -> C-cleanup -> D ->
D-cleanup.
This change the logic to follow the same path if you are jumping over
versions.

Signed-off-by: Marc-Aurle Brothier <m@brothier.org>

* pr/1768:
  Upgrade: change logic for update path for files

Signed-off-by: Rajani Karuturi <rajani.karuturi@accelerite.com>
lucas-a-martins pushed a commit to scclouds/cloudstack that referenced this pull request Jan 29, 2024
Correção na apresentação da descrição de tarifas do Quota

Closes apache#1768

See merge request scclouds/scclouds!736
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

10 participants