Merge pull request #37432 from sebastian-philipp/cephadm-upgrade-state-none

mgr/cephadm: upgrade_state can be literally "null"
This commit is contained in:
Joshua Schmid 2020-09-30 09:55:57 +02:00 committed by GitHub
commit 9f752b177e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import pytest
from ceph.deployment.service_spec import ServiceSpec
from cephadm import CephadmOrchestrator
from cephadm.upgrade import CephadmUpgrade
from .fixtures import _run_cephadm, wait, cephadm_module, with_host, with_service
@ -85,3 +86,10 @@ def test_upgrade_run(use_repo_digest, cephadm_module: CephadmOrchestrator):
assert image == 'to_image@repo_digest'
else:
assert image == 'to_image'
def test_upgrade_state_null(cephadm_module: CephadmOrchestrator):
# This test validates https://tracker.ceph.com/issues/47580
cephadm_module.set_store('upgrade_state', 'null')
CephadmUpgrade(cephadm_module)
assert CephadmUpgrade(cephadm_module).upgrade_state is None

View File

@ -49,8 +49,11 @@ class UpgradeState:
}
@classmethod
def from_json(cls, data) -> 'UpgradeState':
return cls(**data)
def from_json(cls, data) -> Optional['UpgradeState']:
if data:
return cls(**data)
else:
return None
class CephadmUpgrade: