-
Notifications
You must be signed in to change notification settings - Fork 316
[DevSetting] Replace cinc_version/cinc_installer_url with CliAttributeOverrides which is similar to ExtraChefAttributes #7447
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,33 @@ | |
| ATTR_CLUSTER_READINESS_CHECK_IGNORE_FAILURE = "cluster.cluster_readiness_check_ignore_failure" | ||
| MIN_SLURM_RECONFIGURE_TIMEOUT = 300 | ||
|
|
||
| CLI_ATTRIBUTE_OVERRIDES_PATH = "DevSettings/CliAttributeOverrides" | ||
| # Keys the CLI currently unfurls from the blob. Kept for an optional future | ||
| # strict check; today validation is well-formedness only (like ExtraChefAttributes). | ||
| KNOWN_CLI_ATTRIBUTE_OVERRIDES = {"cinc_version", "cinc_installer_url"} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can remove this constant because we are only interested in enforcing the json formatting of the In Cookbook Chef Attribute we introduced the validation of specific attributes only because we decided to vend those attributes publicly to mitigate an impact, but in general we should not do it and keep it free form.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will do |
||
|
|
||
|
|
||
| class CliAttributeOverridesValidator(Validator): | ||
| """Validate DevSettings/CliAttributeOverrides is a well-formed JSON object.""" | ||
|
|
||
| def _validate(self, cli_attribute_overrides: str = None): | ||
| if not cli_attribute_overrides: | ||
| return | ||
| try: | ||
| attrs = json.loads(cli_attribute_overrides) | ||
| except ValueError: | ||
| self._add_failure( | ||
| f"Invalid value in {CLI_ATTRIBUTE_OVERRIDES_PATH}: must be a valid JSON string.", | ||
| FailureLevel.ERROR, | ||
| ) | ||
| return | ||
| if not isinstance(attrs, dict): | ||
| self._add_failure( | ||
| f"Invalid value in {CLI_ATTRIBUTE_OVERRIDES_PATH}: must be a JSON object.", | ||
| FailureLevel.ERROR, | ||
| ) | ||
| # TODO: optionally validate keys against KNOWN_CLI_ATTRIBUTE_OVERRIDES here. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE FOR REVIEWER: Keeping this as a future improvement since we do not validate all JSON content for ExtraChefAttributes as of today and the cinc attributes that I am replacing also do no have any validators. Any un-related attribute apart from the cinc* one's in the JSON will be a no-op. |
||
|
|
||
|
|
||
| class ExtraChefAttributesValidator(Validator): | ||
| """Validate DevSettings/Cookbook/ExtraChefAttributes.""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance | ||
| # with the License. A copy of the License is located at | ||
| # | ||
| # http://aws.amazon.com/apache2.0/ | ||
| # | ||
| # or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
| # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import pytest | ||
| from assertpy import assert_that | ||
|
|
||
| from pcluster.config.imagebuilder_config import ImagebuilderDevSettings | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "cli_attribute_overrides, expected_cinc_version, expected_cinc_installer_url", | ||
| [ | ||
| pytest.param(None, "", "", id="unset blob -> empty overrides"), | ||
| pytest.param("", "", "", id="empty blob -> empty overrides"), | ||
| pytest.param( | ||
| '{"cinc_version": "18.8.54", "cinc_installer_url": "https://omnitruck.cinc.sh/install.sh"}', | ||
| "18.8.54", | ||
| "https://omnitruck.cinc.sh/install.sh", | ||
| id="both keys unfurled", | ||
| ), | ||
| pytest.param('{"cinc_version": "18.8.54"}', "18.8.54", "", id="only cinc_version present"), | ||
| pytest.param( | ||
| '{"cinc_installer_url": "https://omnitruck.cinc.sh/install.sh"}', | ||
| "", | ||
| "https://omnitruck.cinc.sh/install.sh", | ||
| id="only cinc_installer_url present", | ||
| ), | ||
| pytest.param('{"unrelated": "value"}', "", "", id="unknown keys ignored"), | ||
| ], | ||
| ) | ||
| def test_dev_settings_cli_attribute_overrides_unfurl( | ||
| cli_attribute_overrides, expected_cinc_version, expected_cinc_installer_url | ||
| ): | ||
| dev_settings = ImagebuilderDevSettings(cli_attribute_overrides=cli_attribute_overrides) | ||
| assert_that(dev_settings.cinc_version).is_equal_to(expected_cinc_version) | ||
| assert_that(dev_settings.cinc_installer_url).is_equal_to(expected_cinc_installer_url) |
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.
Removing this parameter from DevSettings schema is ok because we do not guarantee backward compatibility for DevSettings by definition. However, I suggest to document the removal in the changelog. the fact that we do not guarantee backward compatibility means it is ok to make this change, but does not mean we should not surface it.
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.
IF we never surface the addition of DevSettings in chnagelog; why should we surface their removal?