Skip to content
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

fix: validate deploying module rather than entire schema #1217

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

worstell
Copy link
Contributor

@worstell worstell commented Apr 9, 2024

when deploying a module, we will only validate the deploying module's schema (but do so within the context of the greater schema).

this change prevents issues where a schema error outside of the deploying module prevents the deploy from succeeding—causing issues like #1211. now in combination with the buildengine logic, a change in the upstream module that breaks a downstream module will not prevent the upstream module from deploying (if the module still has a valid standalone schema). the deploy will succeed and then the subsequent deploy triggered for the downstream module will fail if the schema change from its dependency breaks it.

fixes #1211

@worstell worstell requested a review from deniseli April 9, 2024 22:11
@alecthomas alecthomas mentioned this pull request Apr 9, 2024
@worstell worstell force-pushed the worstell/20240409-fix-module-validation branch from 7708773 to 2ece28b Compare April 9, 2024 22:12
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Great great catch, nice work.

// Validate clones, normalises and semantically valies a schema.
func Validate(schema *Schema) (*Schema, error) {
// ValidateWholeSchema clones, normalises and semantically validates a schema.
func ValidateWholeSchema(schema *Schema) (*Schema, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ubernit: the "Whole" here seems redundant, but also isn't consistent with ValidateModule() - schema.Validate() is more idiomatic because it doesn't "stutter", but schema.ValidateSchema() could be preferable now because we now have a few different Validate*() functions


// ValidateModuleInSchema clones and normalises a schema and semantically validates a single module within it.
// If no module is provided, all modules in the schema are validated.
func ValidateModuleInSchema(schema *Schema, m *Module) (*Schema, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not 100% consistent with this myself, but I do try to use Optional in places where it conveys semantic meaning like it does 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.

good to know, ty!

@alecthomas
Copy link
Collaborator

I wonder if we should "un"deploy any broken modules so that the cluster isn't in an inconsistent state. This will be unnecessary in the future because we'll allow multiple versions to be active at once, and broken state will also be prevented on a "real" full deploy anyway, so probably not necessary

@@ -60,7 +66,7 @@ func Validate(schema *Schema) (*Schema, error) {

scopes := NewScopes()

// Validate dependencies
// ValidateWholeSchema dependencies
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the change to this comment and the one on line 84 be undone? It looks like "Validate" was used as a regular English language verb in these two places, rather than being a reference to the Validate function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oop yes accidentally picked up from refactoring in my IDE! thanks for catching :)

with this change, when deploying a module, we will only validate the deploying module's schema (but do so within the context of the greater schema).
this change prevents issues where a schema error outside of the deploying module prevents the deploy from succeeding—causing issues like #1211.
now in combination with the buildengine logic, a change in the upstream module that breaks a downstream module will not prevent the change from deploying (if the deploying module still has a valid standalone schema). the deploy will succeed and then the subsequent deploy triggered for the downstream module will fail if the schema change from its dependency is breaking.

fixes #1211
@worstell worstell force-pushed the worstell/20240409-fix-module-validation branch from 2ece28b to 14f7140 Compare April 9, 2024 22:38
@worstell worstell merged commit 1896cca into main Apr 9, 2024
12 checks passed
@worstell worstell deleted the worstell/20240409-fix-module-validation branch April 9, 2024 22:45
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.

buildengine can reach a deadend where build errors can't be easily fixed by user
4 participants