in mysqloperator/controller/innodbcluster/cluster_api.py [0:0]
def validate(self, logger: Logger) -> None:
# TODO see if we can move some of these to a schema in the CRD
if len(self.name) > MAX_CLUSTER_NAME_LEN:
raise ApiSpecError(
f"Cluster name {self.name} is too long. Must be < {MAX_CLUSTER_NAME_LEN}")
if not self.instances:
raise ApiSpecError(
f"spec.instances must be set and > 0. Got {self.instances!r}")
if (not self.baseServerId or
self.baseServerId < config.MIN_BASE_SERVER_ID or
self.baseServerId > config.MAX_BASE_SERVER_ID):
raise ApiSpecError(
f"spec.baseServerId is {self.baseServerId} but must be between "
f"{config.MIN_BASE_SERVER_ID} and {config.MAX_BASE_SERVER_ID}")
# TODO validate against downgrades, invalid version jumps
# validate podSpec through the Kubernetes API
if self.podSpec:
pass
if self.tlsSecretName and not self.tlsCASecretName:
logger.info("spec.tlsSecretName is set but will be ignored because self.tlsCASecretName is not set")
# TODO ensure that if version is set, then image and routerImage are not
# TODO should we support upgrading router only?
# validate version
if self.version:
# note: format of the version string is defined in the CRD
[valid_version, version_error] = utils.version_in_range(self.version)
if not valid_version:
raise ApiSpecError(version_error)
self.logs.validate()