Skip to content

[ZDT] set switchToModelVersionAt to 8.10.0 for all types#158267

Merged
pgayvallet merged 5 commits intoelastic:mainfrom
pgayvallet:kbn-xxx-switch-to-model-version
May 24, 2023
Merged

[ZDT] set switchToModelVersionAt to 8.10.0 for all types#158267
pgayvallet merged 5 commits intoelastic:mainfrom
pgayvallet:kbn-xxx-switch-to-model-version

Conversation

@pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented May 23, 2023

Summary

Sets switchToModelVersionAt to 8.10.0 for all registered SO types, forcing them to switch to the model version API once main is on version 8.10.0 (~end of june)

@pgayvallet pgayvallet added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes v8.9.0 labels May 23, 2023
Copy link
Contributor Author

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

Self review

throw new Error('cannot call `registerType` after service startup.');
}
this.typeRegistry.registerType(type);
this.typeRegistry.registerType(applyTypeDefaults(type));
Copy link
Contributor Author

@pgayvallet pgayvallet May 23, 2023

Choose a reason for hiding this comment

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

Doing that directly in the type registry class was too low level, just breaking too many tests. Also I think it makes sense to have this done from the service instead.

Comment on lines +17 to +29
let switchToModelVersionAt = type.switchToModelVersionAt;
if (
!switchToModelVersionAt ||
!Semver.valid(switchToModelVersionAt) ||
Semver.gt(switchToModelVersionAt, globalSwitchToModelVersionAt)
) {
switchToModelVersionAt = globalSwitchToModelVersionAt;
}

return {
...type,
switchToModelVersionAt,
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The actual logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're adding switchToModelVersionAt on all types, so the associated hashes are changing, had to update the snapshot

@pgayvallet pgayvallet marked this pull request as ready for review May 23, 2023 15:08
@pgayvallet pgayvallet requested a review from a team as a code owner May 23, 2023 15:08
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

Comment on lines +20 to +21
!Semver.valid(switchToModelVersionAt) ||
Semver.gt(switchToModelVersionAt, globalSwitchToModelVersionAt)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would normally think of these lines as reasons to throw an error, something like:

Invalid version detected: "foobar". Please use SemVer compliant versions. for (1)

Max switch version is 8.10.0, you provided 8.11.0. for (2).

In which case we have more of a classic default behaviour. But I get that we may not want to draw attention/discussion quite yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After thinking about it, I think you're right. It's probably better to throw if the provided version is invalid (bad format) or higher than 8.10.0 (or 8.11.0 if we want to already allow owners to specify a one-version grace period)

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Overall looks good, left a comment but I'll defer to @rudolf for final approval!

Comment on lines +32 to +39
it(`sets switchToModelVersionAt to the global version if type version is greater than the global version`, () => {
const type = createType({
switchToModelVersionAt: '9.2.0',
});

const result = applyTypeDefaults(type);
expect(result.switchToModelVersionAt).toEqual(globalSwitchToModelVersionAt);
});
Copy link
Member

Choose a reason for hiding this comment

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

should this be allowed as we mentioned we needed a workaround to give teams some extra time?

Copy link
Contributor

@TinaHeiligers TinaHeiligers May 23, 2023

Choose a reason for hiding this comment

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

We could use a delaySwitchToModelVersionAt and override the default or not apply the forced switch to those. That way, we need to agree on which types we're more lenient with based on the type-owner's justification but that can be done as a follow up.
Given the timing, we do need to force our hand a bit 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.

Let's start by not :) and figure out if we need it then

Copy link
Member

Choose a reason for hiding this comment

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

IMO, there is no need for an additional property. The way I understood our conversation was:

If not provided, let's set 8.10.0 as the default switchover deadline.
Teams can override that default by either anticipating or postponing the switch. If postponing, we'd discuss it in the PR review.

Basically function registerType({ switchToModelVersionAt = '8.10.0', ...otherOptions }) {...}.

Given the short timeframe we are providing, I'm almost certain that some teams will need to postpone it.

But I don't think this is a blocker, so let's keep it as it is, and we can soften the validation in a follow-up PR if needed.

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

We'll need to exclude types that are allowed to delay the switch over if that's what we agreed on but that can be done as a follow up.

@TinaHeiligers TinaHeiligers self-requested a review May 23, 2023 16:15
Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

LGTM to CI green

@pgayvallet pgayvallet requested a review from rudolf May 23, 2023 17:41
@pgayvallet pgayvallet enabled auto-merge (squash) May 24, 2023 06:02
@kibana-ci
Copy link

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #5 / machine learning - data frame analytics classification saved search creation with filter and lucene query edits the analytics job and displays it correctly in the job list

Metrics [docs]

Unknown metric groups

API count

id before after diff
@kbn/core-saved-objects-base-server-internal 85 86 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 399 403 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 479 483 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@pgayvallet pgayvallet merged commit acdadf2 into elastic:main May 24, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label May 24, 2023
delanni pushed a commit to delanni/kibana that referenced this pull request May 25, 2023
…#158267)

## Summary

Sets `switchToModelVersionAt` to `8.10.0` for all registered SO types,
forcing them to switch to the model version API once `main` is on
version `8.10.0` (~end of june)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v8.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants