You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "soreana (via GitHub)" <gi...@apache.org> on 2023/01/27 15:05:29 UTC

[GitHub] [cloudstack] soreana opened a new issue, #7139: Root disk size reverts to its template size after reinstall

soreana opened a new issue, #7139:
URL: https://github.com/apache/cloudstack/issues/7139

   <!--
   Verify first that your issue/request is not already reported on GitHub.
   Also test if the latest release and main branch are affected too.
   Always add information AFTER of these HTML comments, but no need to delete the comments.
   -->
   
   This issue is almost the same as the #3957
   
   
   ##### ISSUE TYPE
   <!-- Pick one below and delete the rest -->
    * Bug Report
   
   
   ##### COMPONENT NAME
   <!--
   Categorize the issue, e.g. API, VR, VPN, UI, etc.
   -->
   ~~~
   Instance reinstallation
   ~~~
   
   ##### CLOUDSTACK VERSION
   <!--
   New line separated list of affected versions, commit ID for issues on main branch.
   -->
   
   ~~~
   main,
   4.17, 
   but not in 4.14
   ~~~
   
   
   
   ##### SUMMARY
   <!-- Explain the problem/feature briefly -->
   
   Reinstall action acts surprisingly. When users reinstall a vm, they expect the VM configurations stay the same (like: service offering, volume sizes, IP) and a brand new operating system installs on the VM. But it is not always true. For example:
   
   
   ###### First Scenario:
   
   1. Deploy an instance. `Don't override the root disk`
   2. Resize the root volume 
   3. Reinstall the VM
   
   | Expected Result | Actual Result |
   |-----------------|---------------|
   | Root volume size stays the same | Root volume size resets to original value |
   
   ###### First Scenario:
   
   1. Deploy an instance.  `Override the root disk`
   2. Resize the root volume 
   3. Reinstall the VM
   
   | Expected Result | Actual Result |
   |-----------------|---------------|
   | Root volume size stays the same | Root volume size stays the same |
   
   
   
   ##### Findings
   
   In our debugging we noticed that when user overrides the root disk size an entry in user_vm_details is created. When user don't override root disk size, the entry is not created in database. In that case, CloudStack uses the template's disk size rather than the old root volume size in reinstallation process.
   
   ```
   mysql> select * from user_vm_details where name = 'rootdisksize' ;
   +----+-------+--------------+-------+---------+
   | id | vm_id | name         | value | display |
   +----+-------+--------------+-------+---------+
   | 21 |     5 | rootdisksize | 15    |       1 |
   +----+-------+--------------+-------+---------+
   1 row in set (0.00 sec)
   ```
   
   
   https://github.com/apache/cloudstack/blob/eac357cb77f2ef210ce9c247059e74b9ad75265b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java#L7746-L7752
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] weizhouapache commented on issue #7139: Root disk size reverts to its template size after reinstall

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on issue #7139:
URL: https://github.com/apache/cloudstack/issues/7139#issuecomment-1426662489

   > @weizhouapache
   > 
   > Although the #7145 PR fixed the issue for new VMs, we have to update CloudStack's database manually and add an entry in `user_vm_details` for old VMs. I thought it would be nice to share the scrips here just in case someone has the same issue. :-)
   > 
   > 1. Get the affected VMs with the following sql query. Save it to a file called `missing.txt`
   > 2. Then use the python code to generate appropriate insert SQLs. `python3 parser.py missing`
   > 3. The python programm will generate the `missing.sql` file.
   > 4. Update the database using the `missing.sql`
   > 
   > ```sql
   > MariaDB [cloud]> SELECT distinct(view.id) as vm_id, view.uuid as vm_uuid, view.volume_id, vol.uuid as volume_uuid, \
   >     vol.volume_type , details.value as rootdisksize, CAST(vol.size/1024/1024/1024 AS SIGNED INTEGER) as expected \ 
   >     FROM cloud.user_vm_view AS view LEFT JOIN cloud.user_vm_details AS details ON view.id=details.vm_id AND \
   >     details.name='rootdisksize' LEFT JOIN cloud.volumes AS vol ON vol.id=view.volume_id WHERE view.state != 'Destroyed' \
   >     AND (CAST(vol.size/1024/1024/1024 AS SIGNED INTEGER) != details.value OR details.value IS NULL) \
   >     and vol.volume_type = 'ROOT' and details.value is NULL ORDER BY vm_id ;
   > +-------+--------------------------------------+-----------+--------------------------------------+-------------+--------------+----------+
   > | vm_id | vm_uuid                              | volume_id | volume_uuid                          | volume_type | rootdisksize | expected |
   > +-------+--------------------------------------+-----------+--------------------------------------+-------------+--------------+----------+
   > |   1   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff0 |       1   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff0 | ROOT        | NULL         |       12 |
   > |   2   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff1 |       2   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff1 | ROOT        | NULL         |       15 |
   > |   3   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff2 |       3   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff2 | ROOT        | NULL         |       25 |
   > +-------+--------------------------------------+-----------+--------------------------------------+-------------+--------------+----------+
   > 3 rows in set (0.005 sec)
   > ```
   > 
   > ```python
   > import sys
   > 
   > input_file_name = '{}.txt'.format( sys.argv[1] )
   > output_file_name = '{}.sql'.format( sys.argv[1] )
   > 
   > with open( input_file_name , "r") as f_in:
   >     with open( output_file_name , "w") as f_out:
   >         for li in f_in.readlines():
   >             if '-+-' not in li and "vm_id" not in li and "SELECT" not in li and 'rows' not in li:
   >                 print(li, end = '')
   >                 tmp = li.split('|')
   >                 print(tmp)
   >                 out_line = 'insert into user_vm_details (vm_id, name, value, display) values ( {}, \'rootdisksize\', {}, 1);\n'.format( tmp[1], tmp[-2] )
   >                 print(out_line, end = '')
   > 
   >                 if 'NULL' in tmp[-3]:
   >                     f_out.write(out_line)
   > ```
   
   thanks @soreana for sharing
   would it be good do it via mysql procedure?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland closed issue #7139: Root disk size reverts to its template size after reinstall

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland closed issue #7139: Root disk size reverts to its template size after reinstall
URL: https://github.com/apache/cloudstack/issues/7139


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on issue #7139: Root disk size reverts to its template size after reinstall

Posted by "soreana (via GitHub)" <gi...@apache.org>.
soreana commented on issue #7139:
URL: https://github.com/apache/cloudstack/issues/7139#issuecomment-1426058567

   @weizhouapache 
   
   Although the https://github.com/apache/cloudstack/pull/7145 PR fixed the issue for new VMs, we have to update CloudStack's database manually and add an entry in `user_vm_details` for old VMs. I thought it would be nice to share the scrips here just in case someone has the same issue. :-)
   
   1. Get the affected VMs with the following sql query. Save it to a file called `missing.txt`
   2. Then use the python code to generate appropriate insert SQLs. `python3 parser.py missing`
   3. The python programm will generate the `missing.sql` file.
   4. Update the database using the `missing.sql`
   
   ```sql
   MariaDB [cloud]> SELECT distinct(view.id) as vm_id, view.uuid as vm_uuid, view.volume_id, vol.uuid as volume_uuid, \
       vol.volume_type , details.value as rootdisksize, CAST(vol.size/1024/1024/1024 AS SIGNED INTEGER) as expected \ 
       FROM cloud.user_vm_view AS view LEFT JOIN cloud.user_vm_details AS details ON view.id=details.vm_id AND \
       details.name='rootdisksize' LEFT JOIN cloud.volumes AS vol ON vol.id=view.volume_id WHERE view.state != 'Destroyed' \
       AND (CAST(vol.size/1024/1024/1024 AS SIGNED INTEGER) != details.value OR details.value IS NULL) \
       and vol.volume_type = 'ROOT' and details.value is NULL ORDER BY vm_id ;
   +-------+--------------------------------------+-----------+--------------------------------------+-------------+--------------+----------+
   | vm_id | vm_uuid                              | volume_id | volume_uuid                          | volume_type | rootdisksize | expected |
   +-------+--------------------------------------+-----------+--------------------------------------+-------------+--------------+----------+
   |   1   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff0 |       1   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff0 | ROOT        | NULL         |       12 |
   |   2   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff1 |       2   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff1 | ROOT        | NULL         |       15 |
   |   3   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff2 |       3   | aaaaaaaa-bbbb-cccc-dddd-fffffffffff2 | ROOT        | NULL         |       25 |
   +-------+--------------------------------------+-----------+--------------------------------------+-------------+--------------+----------+
   3 rows in set (0.005 sec)
   ```
   
   
   ```python
   import sys
   
   input_file_name = '{}.txt'.format( sys.argv[1] )
   output_file_name = '{}.sql'.format( sys.argv[1] )
   
   with open( input_file_name , "r") as f_in:
       with open( output_file_name , "w") as f_out:
           for li in f_in.readlines():
               if '-+-' not in li and "vm_id" not in li and "SELECT" not in li and 'rows' not in li:
                   print(li, end = '')
                   tmp = li.split('|')
                   print(tmp)
                   out_line = 'insert into user_vm_details (vm_id, name, value, display) values ( {}, \'rootdisksize\', {}, 1);\n'.format( tmp[1], tmp[-2] )
                   print(out_line, end = '')
   
                   if 'NULL' in tmp[-3]:
                       f_out.write(out_line)
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on issue #7139: Root disk size reverts to its template size after reinstall

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on issue #7139:
URL: https://github.com/apache/cloudstack/issues/7139#issuecomment-1411880811

   fixed by #7145


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on issue #7139: Root disk size reverts to its template size after reinstall

Posted by "soreana (via GitHub)" <gi...@apache.org>.
soreana commented on issue #7139:
URL: https://github.com/apache/cloudstack/issues/7139#issuecomment-1433279771

   @weizhouapache We had a lot of edge cases, we prefer to get the list first and manually update those. :-)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org