Upgrade: a failed system VM template step is skipped on restart, as the schema steps are already marked Complete
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- java
- Domínio
- backend, infrastructure
Direção de pesquisa
Start by reading DatabaseUpgradeChecker.upgrade(), executeUpgradeCleanup(), VersionDaoImpl.getCurrentVersion(), and SystemVmTemplateRegistration.updateSystemVmTemplates(). Trace how upgrade state is read and written when template registration fails, then compare the two recovery approaches described in the issue. Done means a chosen approach retries the failed template step safely without rerunning non-idempotent SQL; the issue calls for agreeing on the approach and testing it on a real upgrade.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
problem
If the system VM template registration step of a database upgrade fails, the upgrade can't be completed by fixing the cause and restarting the management server. The restart skips the template step, and the server comes up on the new version with the old system VM template still configured. The only way back we found was to restore the database backup and run the upgrade again.
The cause is the order of operations in DatabaseUpgradeChecker.upgrade():
executeProcedureScripts();
final DbUpgrade[] upgrades = executeUpgrades(dbVersion, currentVersion);
executeViewScripts();
updateSystemVmTemplates(upgrades);
executeUpgrades()runs each step of the path.executeUpgrade()commits the schema and data changes and inserts theversionrow, andexecuteUpgradeCleanup()then sets that row toCompleteand commits.- Only after every step is
CompletedoesupdateSystemVmTemplates()run. It callsSystemVmTemplateRegistration.updateSystemVmTemplates(), which looks for the template under the name frommetadata.ini(for examplesystemvm-kvm-4.22.0-x86_64). If no template has that name, it registers one from the packaged template file. If that fails, it throws, and the management server stops. - On the next start,
VersionDaoImpl.getCurrentVersion()returns the newestCompleterow, which is now the code version.doUpgrades()logs "DB version and code version matches so no upgrade needed." and returns.updateSystemVmTemplates()is only reached fromupgrade(), so it doesn't run again.
The result is a management server on the new version with router.template.* and minreq.sysvmtemplate.version still at the old values, and nothing that marks the upgrade as incomplete. Nothing in the startup path checks for it, and nothing retries it.
In our case, the template step failed because the new template had been registered ahead of the upgrade under a name other than the one the upgrade expects (systemvm-kvm-4.22.0 instead of systemvm-kvm-4.22.0-x86_64). That was an operator error. But any failure in that step leaves the database in the same state, for example a missing or corrupt template file, or a secondary storage that can't be mounted.
versions
Seen on an upgrade from 4.20.3 to 4.22.1 on KVM with NFS secondary storage. The same ordering is on the 4.22 branch and on main. It has been there since template registration became part of the database upgrade in 4.16 (#4329).
The steps to reproduce the bug
- Run a 4.20 setup with at least one KVM cluster.
- Make the template registration step fail. One way is to register the 4.22 system VM template ahead of the upgrade under a different name, such as
systemvm-kvm-4.22.0, and move the packaged KVM template file out of/usr/share/cloudstack-management/templates/systemvm/. - Install the 4.22 packages and start the management server. The schema upgrade runs, then the template step fails with "Failed to register SystemVM Template. Upgrade failed" and the management server stops.
- Check the
versiontable. The rows for every step up to 4.22.x areComplete. - Fix the cause, for example by renaming the template to
systemvm-kvm-4.22.0-x86_64, and start the management server again. - It logs "DB version and code version matches so no upgrade needed." and starts. The template step doesn't run.
router.template.kvmandminreq.sysvmtemplate.versionstill hold the 4.20 values, and the template is not marked as a system template.
What to do about it?
Two ways to fix it come to mind. Both change upgrade or startup behaviour, so I'd rather agree on the approach here first, and then test it on a real upgrade.
- Retry on startup. When the database version matches the code version, check whether the template named in
metadata.iniis registered for each hypervisor and architecture in use, and run the registration step if one is missing. This is the smallest change, but it runs on every start. It has to tell a failed upgrade apart from a setup that is missing the template for another reason, for example a cluster of a new architecture added after the upgrade. It also has to decide whether a failure blocks startup. - Mark the last step
Completeonly after the template step succeeds. If the template step fails, leave the lastversionrow atCleanup. On the next start, when the newest row is the code version atCleanup, run only the template step and then mark itComplete. Its SQL must not run again, because the scripts aren't idempotent. This keeps the retry to failed upgrades only. ButgetCurrentVersion()would return the previous version while the schema is already at the new one, so every reader of that value needs checking, and so does downgrading to the old packages.
Until this is fixed, the only recovery we found is to restore the database backup, fix the cause, and run the upgrade again.
- Linguagem predominante
- Java
- Estrelas
- 3.1k
- Forks
- 1.4k
- Merge médio
- 7d 16h
- PRs com merge (30d)
- 15
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/cloudstack
-
resizeVolume of a running system VM's volume is accepted but the VM never sees the new sizeTalvez já em andamento @bhouse-nexthop assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/cloudstack#14645 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
VR reports a load balancer change as applied when haproxy.cfg cannot be replacedTalvez já em andamento @bhouse-nexthop assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
apache/cloudstack#14633 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
restartNetwork reports a ResourceUnavailableException as an unexpected error (530), unlike restartVPC (534)Talvez já em andamento @bhouse-nexthop assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
apache/cloudstack#14631 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
apache/cloudstack#14625 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Remote access VPN users are disconnected on every LB, ACL, port forward or firewall change (xl2tpd restarted on every iptables pass)Talvez já em andamento @willbennett-devops assumiu há 12 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/cloudstack#14545 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de apache/cloudstack
Issues semelhantes
-
[Bug]: Nullable implicit operator on string extensible enums still throws for a null stringTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug emitter:client:csharp
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
microsoft/typespec#12572 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
[BUG]: Java SDK MountRequest always sends update-optional fields, resetting stored mount settingsAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
Mantenedores costumam responder em até 1 dia
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationTalvez já em andamento @amalsaidov assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
needs-area-label
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias