Skip to content

Allow public templates with no url to be migrated#5404

Merged
yadvr merged 1 commit into
apache:4.15from
shapeblue:include-public-template-migration
Sep 3, 2021
Merged

Allow public templates with no url to be migrated#5404
yadvr merged 1 commit into
apache:4.15from
shapeblue:include-public-template-migration

Conversation

@Pearl1594
Copy link
Copy Markdown
Contributor

Description

This PR allows migration of public templates that are created from snapshots / volumes. Data migration across secondary stores initially excluded all public templates on the pretext that public templates are automatically synced when a new image store is added; however, this assumption isn't true for templates marked as "public" when created from snapshots / volumes. Such templates can be identified if their url is null

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Initial Behavior:

  1. Created a snapshot and then created a template from that snapshot and marked the template as public
  2. Added another image store
  3. Validated that the template doesn't get synced
  4. Attempted migration of resources from one store to another - all public templates including the one created from the snapshot is left behind

New Behavior:

MariaDB [cloud]>  select * from vm_template  // template created from snapshot
*************************** 15. row ***************************
                  id: 202
         unique_name: 202-2-1367573b-68d3-3bfe-977a-bdc2bf9936d1
                name: PublicTempFromSnap
                uuid: 08c14c2e-4440-4c3f-9feb-546ca1ae022f
              public: 1
            featured: 0
                type: USER
                 hvm: 0
                bits: 64
                 url: NULL
              format: QCOW2
             created: 2021-09-02 11:42:55
             removed: NULL
          account_id: 2
            checksum: NULL
        display_text: PublicTempFromSnap
     enable_password: 0
       enable_sshkey: 0
         guest_os_id: 99
            bootable: 1
         prepopulate: 0
         cross_zones: 0
         extractable: 1
     hypervisor_type: KVM
  source_template_id: 4
        template_tag: NULL
            sort_key: 0
                size: 8589934592
               state: Active
        update_count: 0
             updated: NULL
dynamically_scalable: 0
  parent_template_id: NULL
     direct_download: 0
        deploy_as_is: 0
15 rows in set (0.00 sec)

MariaDB [cloud]> select * from template_store_ref  where template_id = 202\G <-- secondary store template reference before migration (store_id = 1)
*************************** 1. row ***************************
                  id: 8
            store_id: 1
         template_id: 202
             created: 2021-09-02 11:42:55
        last_updated: NULL
              job_id: NULL
        download_pct: 100
                size: 8589934592
          store_role: Image
       physical_size: 1622409216
      download_state: DOWNLOADED
           error_str: NULL
          local_path: NULL
        install_path: template/tmpl/2/202/5ed48fa5-69b9-4297-94a6-0a75cebdaf25.qcow2
                 url: NULL
               state: Ready
           destroyed: 0
             is_copy: 0
        update_count: 2
             ref_cnt: 0
             updated: 2021-09-02 11:43:15
download_url_created: NULL
        download_url: NULL
1 row in set (0.00 sec)

MariaDB [cloud]> select * from template_store_ref  where template_id = 202\G < -- template store ref after migration (store_id = 2)
*************************** 1. row ***************************
                  id: 17
            store_id: 2
         template_id: 202
             created: 2021-09-02 11:42:55
        last_updated: NULL
              job_id: NULL
        download_pct: 100
                size: 8589934592
          store_role: Image
       physical_size: 1622409216
      download_state: DOWNLOADED
           error_str: NULL
          local_path: NULL
        install_path: template/tmpl/2/202/5ed48fa5-69b9-4297-94a6-0a75cebdaf25.qcow2
                 url: NULL
               state: Ready
           destroyed: 0
             is_copy: 0
        update_count: 2
             ref_cnt: 0
             updated: 2021-09-02 12:25:14
download_url_created: NULL
        download_url: NULL
1 row in set (0.00 sec)

Also attempted deletion of store 1 prior initiating migration - with the public template (created from snapshot) present - fails as expected:
image

@Pearl1594
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 1110

@weizhouapache
Copy link
Copy Markdown
Member

@Pearl1594
if the templates created from snapshot or volume are not public, is it allowed to be copied to other secondary stores ?

@Pearl1594
Copy link
Copy Markdown
Contributor Author

yes @weizhouapache - all private templates are selected for migration

@Pearl1594
Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

VMTemplateVO templateVO = templateDao.findById(template.getTemplateId());
if (template.getState() == ObjectInDataStoreStateMachine.State.Ready && templateVO != null && !templateVO.isPublicTemplate() &&
if (template.getState() == ObjectInDataStoreStateMachine.State.Ready && templateVO != null &&
(!templateVO.isPublicTemplate() || (templateVO.isPublicTemplate() && templateVO.getUrl() == null)) &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

extract to a method ?

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-1944)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 34488 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5404-t1944-kvm-centos7.zip
Smoke tests completed. 87 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

Copy link
Copy Markdown
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

code lgtm
left 1 small comment

@yadvr yadvr added this to the 4.15.2.0 milestone Sep 3, 2021
@sureshanaparti
Copy link
Copy Markdown
Contributor

code LGTM, @Pearl1594 pls resolve outstanding comments.

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Sep 3, 2021

I see only one minor nit comment - while 2lgtms and smoketests are here. Merging based on this.

@yadvr yadvr merged commit b2fd1f6 into apache:4.15 Sep 3, 2021
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.

5 participants