Skip to content

python-common: fix ServiceSpec validation#35493

Merged
sebastian-philipp merged 3 commits intoceph:masterfrom
mgfritch:orch-service-spec-validate
Jun 17, 2020
Merged

python-common: fix ServiceSpec validation#35493
sebastian-philipp merged 3 commits intoceph:masterfrom
mgfritch:orch-service-spec-validate

Conversation

@mgfritch
Copy link
Contributor

@mgfritch mgfritch commented Jun 9, 2020

Fixes various issues around validation of a ServiceSpec during orch apply.

Signed-off-by: Michael Fritch mfritch@suse.com

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

mgfritch added 3 commits June 8, 2020 18:09
the ServiceSpec needs to be validated during `orch apply`, but not
during `orch daemon add`

Signed-off-by: Michael Fritch <mfritch@suse.com>
Signed-off-by: Michael Fritch <mfritch@suse.com>
the service_id needs to be validated during `orch apply`, but not during
`orch daemon add`

Signed-off-by: Michael Fritch <mfritch@suse.com>
@mgfritch mgfritch requested a review from a team as a code owner June 9, 2020 00:18
Comment on lines +474 to +476
if self.service_type in ['mds', 'rgw', 'nfs', 'iscsi'] and not self.service_id:
raise ServiceSpecValidationError('Cannot add Service: id required')

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a chance that there are existing specs in the store that violate this validation?

Copy link
Contributor

Choose a reason for hiding this comment

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

nice, this is what I meant to do as well.

Is there a chance that there are existing specs in the store that violate this validation?

They probably is. Is the validate method being run on already existing specs though? If not, this would only raise for new or exported(and re-imported) specs.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice, this is what I meant to do as well.

Is there a chance that there are existing specs in the store that violate this validation?

They probably is. Is the validate method being run on already existing specs though?

right: __init__ doesn't call validate():

def __init__(self,
service_type: str,
service_id: Optional[str] = None,
placement: Optional[PlacementSpec] = None,
count: Optional[int] = None,
unmanaged: bool = False,
):
self.placement = PlacementSpec() if placement is None else placement # type: PlacementSpec
assert service_type in ServiceSpec.KNOWN_SERVICE_TYPES, service_type
self.service_type = service_type
self.service_id = service_id
self.unmanaged = unmanaged

and https://github.com/ceph/ceph/blob/master/src/pybind/mgr/cephadm/inventory.py doesn't call .validate() either.

should we add it? If yes, how do we handle specs that fail the validation?

If not, this would only raise for new or exported(and re-imported) specs.

Copy link
Contributor

Choose a reason for hiding this comment

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

should we add it? If yes, how do we handle specs that fail the validation?

we probably only should do that if we have a clear path for communicating these kind of issues. some way of indicating that an already applied spec is not valid anymore..

otoh, we probably shouldn't invalidate existing specs to begin with.. maybe adding an internal tracking id for already existing specs isn't the worst move.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

which is not as bad as in load() . I think #35456 plus some HEALTH_WARN integration would be enough here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a chance that there are existing specs in the store that violate this validation?

If so, they would have likely broke the orch ls etc commands...

which is not as bad as in load() . I think #35456 plus some HEALTH_WARN integration would be enough here.

This actually makes a lot of sense in the general case where the cluster state could change and we might want to (re)validate before another placement...

Copy link
Contributor

Choose a reason for hiding this comment

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

so I think we're good, as long as we provide a way for users to remove that service after they did an upgrade.

@sebastian-philipp
Copy link
Contributor

sebastian-philipp commented Jun 10, 2020

QA run failed due to #35474 (comment) . not 100% sure if this PR is not related.

@sebastian-philipp
Copy link
Contributor

@sebastian-philipp sebastian-philipp added wip-swagner-testing My Teuthology tests and removed wip-swagner-testing My Teuthology tests labels Jun 10, 2020
@sebastian-philipp
Copy link
Contributor

@sebastian-philipp
Copy link
Contributor

@callithea is this ceph dashboard backend API tests failue related to this PR?

@sebastian-philipp
Copy link
Contributor

jenkins test dashboard backend

@sebastian-philipp sebastian-philipp merged commit 57734cf into ceph:master Jun 17, 2020
@mgfritch mgfritch deleted the orch-service-spec-validate branch June 18, 2020 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants