New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the pack schema #2988
Change the pack schema #2988
Conversation
be5bc37
to
40f41bd
Compare
Current coverage is 76.67% (diff: 89.80%)@@ master #2988 diff @@
==========================================
Files 426 427 +1
Lines 21812 21959 +147
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 16684 16836 +152
+ Misses 5128 5123 -5
Partials 0 0
|
Discussed this schema change with @bigmstone, I think we came up with a decent structure for storing system requirements:
In this PR, we'll just introduce the field, and in the future versions st2 will act upon the params inside |
dependencies : | ||
- core=0.2.0 | ||
system : | ||
stackstorm : 1.6dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we’ll need a range and not a simple number for this. So when we actually start validating these fields, we should make sure that we don't lock ourselves on specifying an exact version.
I also think that st2_version should be a top level field and system should just be used for OS level package deps. @Kami what are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we’ll need a range and not a simple number for this. So when we actually start validating these fields, we should make sure that we don't lock ourselves on specifying an exact version.
The number was supposed to be a minimum version, but you're right, we could find ourselves deprecating or removing stuff, so I'm adding full range support.
Yeah, could use @Kami's opinion on this. My thinking is So I'm fine with either, but I think |
@@ -177,11 +177,6 @@ def _register_pack_db(self, pack_name, pack_dir): | |||
pack_file_list = get_file_list(directory=pack_dir, exclude_patterns=EXCLUDE_FILE_PATTERNS) | |||
content['files'] = pack_file_list | |||
|
|||
# Note: If some version values are not explicitly surrounded by quotes they are recognized | |||
# as numbers so we cast them to string | |||
if 'version' in content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason why this was removed?
Comment mentioned why it was needed :D Or it's not needed anymore now that we use semver everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be needed anymore. Can get it back just in case :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you can actually just leave it as is - I will make this change in the versioning change and move it to a better place anyway (API model) :)
'items': {'type': 'string'}, | ||
'default': [] | ||
}, | ||
'system': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I think this name is much better than engines. We could perhaps also call it system_version
or st2_version
to be more explicit and obvious what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also simplify it and make it a string, I think there is little need to have an object since we have only one platform - StackStorm.
In Node.JS land it's a bit different since there are multiple executions environments using different engines / JITs. Having said that, I also very rarely seen people specify anything else than nodejs there :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also simplify it and make it a string, I think there is little need to have an object since we have only one platform - StackStorm.
Yeah, if we stuck to the initial "engines" purpose, that would be "st2_version", but later (#2988 (comment) and #2988 (comment)) there was an idea to utilize it for storing system-level requirements like packages and versions of runners, etc.
|
||
model = cls.model(name=name, description=description, ref=ref, keywords=keywords, | ||
version=version, author=author, email=email, files=files) | ||
parameters = pack.__dict__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally not a fan of this __dict__
approach, too much magic and could cause us to store weird stuff.
I would prefer to explicitly assign it as we did before. As far as forward compatibility goes - I thought we will just accept them without throwing, but not actually store them in the database (which I think it's the right thing to do).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, now that I think about it - new version of mongoengine throws if you pass in a field which is not explicitly declared so this would actually cause it to throw :)
In any case, as mentioned above, I would prefer to explicitly assign parameters we use and store and ignore others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we will just accept them without throwing, but not actually store them in the database (which I think it's the right thing to do).
Reasonable. Will do.
@@ -144,5 +144,5 @@ def test_register_setup_virtualenvs(self): | |||
# All packs | |||
cmd = BASE_CMD_ARGS + ['--register-setup-virtualenvs', '--register-no-fail-on-failure'] | |||
exit_code, stdout, stderr = run_command(cmd=cmd) | |||
self.assertTrue('Setup virtualenv for 8 pack(s)' in stderr) | |||
self.assertTrue('Setup virtualenv for 10 pack(s)' in stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is a bit error prone, for got to update this in my PR so we don't need to update it every time new pack fixtures are added (I did do this in one place, but forgot some others :)).
Will push a commit to this branch which changes that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha. I thought it's written like this on purpose, to manually check the pack number or something. 😛
Yeah, I agree :) As mentioned in my comment above, I would also prefer |
I added some comments - some things which still need to be decided and changes, but overall nice work 👍 I also just checked out this branch and will make the version changes we discussed yesterday directly in this branch so there won't be any merge conflicts :) |
specifiers (e.g. 1.0). In case we encounter a non-semver valid version, we cast it so semver valid one by appending .0 at the end of the original version string.
This way the schema is still forward compatible, but we don't try to store or pass in the fields we don't officially support. This way user can't pass garbage or bad data and cause us to store it.
… fixture is added.
…enly normalized everywhere and so it's also done before .validate() is called.
…ow valid semver format.
…ex semver version specifiers.
@emedvedev @bigmstone
Even if that part is not implemented, just a thought: I think it will be a bit dangerous to specify/install OS-level dependencies, because it could be much harder than we initially think. Different packages can provide same libraries(package1|package2), different flavors of distros can have different package naming, dependency could be installed/configured from sources and not from the package, add here OS package versioning requirements and so on underwater rocks.
|
… pack and compare it against the current StackStorm version. If the version required is not satisfied, throw and fail pack registration.
Various pack schema changes
@emedvedev I merged my PR into this one so only thing we need to decide is version normalization (cc @m4dcoder, @lakshmi-kannan). Besides that, we should be good to go. Oh, and of course we also need some docs + upgrade notes on it (I can tackle upgrade notes once it's merged). |
I definitely think StackStorm should not be be touching or handling OS-level dependencies. This info is more just like a metadata for packaging (and perhaps package maintainers can use it to auto-generate files based on this metadata). |
Yeah, what that guy said. :) |
@emedvedev @Kami ^^ Huh, I thought you smoked something, but looks like I've smoked something wrong 😄 Just let's make sure the naming is not confusing, so smokers like me won't think that os-level packages will be really installed. Kind of recommends keyword. |
@Kami I've removed the .0 stuff as I think it should be a separate discussion in another PR, and the version validation should probably be done during the installation for a few reasons, so also removed the check (but not utils). So normalization can be returned later, I just didn't want to hold off this PR until everyone has time for discussions. |
As discussed with @Kami, we need to do something about packs meant for newer StackStorm versions than whatever the user might have. Ideally, StackStorm should be able to figure it out and ask the user to update if they want to install a newer pack:
This PR does not implement this feature, but it lays the groundwork by preventing StackStorm from throwing on unknown
pack.yaml
fields. We also add properties that are very likely to appear in the next version:dependencies
andsystem
. Even if there's no implementation for these fields right now, they are pretty self-explanatory (and there's a description in the schema, too) and helpful to the user, so it's better if 2.1 still allows to install a pack meant for whenever those features are implemented. Then users can handle versions and deps themselves or consider updating.dependencies
will be implemented either in the content management release (see https://github.com/stackstorm/discussions/issues/204), or earlier, but in a basic form: for instance, conflicting dependencies won't be resolved.system
is a way to specify system requirements. We could use it to require a minimal StackStorm version, but also for packages. Even if StackStorm can't check and install system requirements right now, at least with this field users would know where to look for them. I'll try to take a stab at it it as soon as I can, but only after everything critical is done for the current release.