Skip to content

Conversation

@marc-1010
Copy link
Contributor

@marc-1010 marc-1010 commented Jun 24, 2024

Issue #, if available:

Description of changes:

  • Remove file_generation_enabled from canarySettings. If the canarySettings field is provided with an empty object, canaries will be generated with contract_test_file_names: [input1.json] default. If canarySettings are removed from .rpdk-config, no canary generation will occur.
  • Improved logging will simplify debugging canary autogeneration.
  • Add a warning log when canarySettings are provided but empty
  • Add Logging at info level for skipping, starting, and finishing canary autogeneration
  • Add Logging at the debug level for loading contract test inputs and writing canary file outputs.
"canarySettings": {
        "contract_test_file_names": ["inputs1.json"]
    }
#positive case at Debug Log Level

% cfn generate -v -v -v
Logging set up successfully
...
Starting Canary Auto-Generation...
Writing: /[ROOT]/testcfncli/canary-bundle/bootstrap.yaml
Loading contract test input file: /[ROOT]/testcfncli/contract-tests-artifacts/inputs_1.json
Writing Canary Stack Template File: /[ROOT]/testcfncli/canary-bundle/canary/canary1_001.yaml
Writing Canary Stack Template File: /[ROOT]/testcfncli/canary-bundle/canary/canary1_002.yaml
Loading contract test input file: /[ROOT]/testcfncli/contract-tests-artifacts/inputs_2.json
Writing Canary Stack Template File: /[ROOT]/testcfncli/canary-bundle/canary/canary2_001.yaml
Writing Canary Stack Template File: /[ROOT]/testcfncli/canary-bundle/canary/canary2_002.yaml
Loading contract test input file: /[ROOT]/testcfncli/contract-tests-artifacts/inputs_3.json
Writing Canary Stack Template File: /[ROOT]/testcfncli/canary-bundle/canary/canary3_001.yaml
Writing Canary Stack Template File: /[ROOT]/testcfncli/canary-bundle/canary/canary3_002.yaml
Finished Canary Auto-Generation
Generated files for TestOrg::TestService::TestResource
Finished generate

# canarySettings not in .rpdk-config

% cfn generate -vv
Logging set up successfully
...
Skipping Canary Auto-Generation
Generated files for TestOrg::TestService::TestResource
Finished generate

#canarySettings:{} with DEBUG Log Level

Logging set up successfully
Writing docs README: [ROOT]/testcfncli/docs/README.md
Starting Canary Auto-Generation...
canarySettings are provided but empty. Generation is enabled with default settings.
Writing: [ROOT]/testcfncli/canary-bundle/bootstrap.yaml
Loading contract test input file: [ROOT]/testcfncli/contract-tests-artifacts/inputs_1.json
Writing Canary Stack Template File: [ROOT]/testcfncli/canary-bundle/canary/canary1_001.yaml
Writing Canary Stack Template File: [ROOT]/testcfncli/canary-bundle/canary/canary1_002.yaml
Finished Canary Auto-Generation
Generated files for TestOrg::TestService::TestResource
Finished generate


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@marc-1010 marc-1010 marked this pull request as ready for review June 24, 2024 21:34
@marc-1010 marc-1010 requested review from ammokhov and rajdnp June 24, 2024 21:34
self._plugin = load_plugin(raw_settings["language"])
self.settings = raw_settings.get("settings", {})
self.canary_settings = raw_settings.get("canarySettings", {})
if raw_settings.get("canarySettings", False) is False:
Copy link
Contributor Author

@marc-1010 marc-1010 Jun 27, 2024

Choose a reason for hiding this comment

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

A has_canary_settings was added here to avoid having canary_settings being either an object or boolean.

)
bootstrap_file = stack_template_root / CANARY_DEPENDENCY_FILE_NAME
if dependencies_file.exists():
LOG.debug("Writing: %s", bootstrap_file)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

logs for writing files are set at debug level. this is consistent with other write operations in this file.

return
LOG.info("Starting Canary Auto-Generation...")
if self.file_generation_enabled and self.canary_settings == {}:
LOG.warning(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this log is set at warning level to make the user aware of empty settings resulting in default generation.

@marc-1010 marc-1010 requested a review from AidenAtSea June 27, 2024 20:03
@marc-1010 marc-1010 changed the title Add logging for canary auto generation Add logging for canary auto generation and refactor canarySettings Jun 27, 2024
@marc-1010 marc-1010 requested a review from joshuadeanhall July 2, 2024 17:02
@rajdnp rajdnp merged commit 8ea4916 into aws-cloudformation:master Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants