-
Notifications
You must be signed in to change notification settings - Fork 71
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 genconfig does not fail when schema validation failed #425
Changes from 2 commits
fea790c
38fde7e
60cac66
92ead90
25e2f3f
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 |
---|---|---|
|
@@ -146,7 +146,7 @@ def validate_deployment_template(self): | |
validation_success = True | ||
try: | ||
template_schema = json.loads(urlopen(Constants.deployment_template_schema_url).read().decode()) | ||
self._validate_json_schema(template_schema, self.json, "Deployment template") | ||
validation_success = self._validate_json_schema(template_schema, self.json, "Deployment template") | ||
except Exception as ex: # Ignore other non shcema validation errors | ||
self.output.info("Unexpected error during deployment template schema validation, skip schema validation. Error:%s" % ex) | ||
|
||
|
@@ -190,6 +190,9 @@ def _validate_json_schema(self, schema_object, json_object, schema_type): | |
self.output.warning("%s schema validation failed. Please see previous logs for more details" % schema_type) | ||
else: | ||
self.output.info("%s schema validation passed." % schema_type) | ||
|
||
if error_detected: | ||
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. line 189 has if error_detected? 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. besides it already has error_detected, do we still need validation_success? 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. Removed the error_detected and reuse validation_success. We need to declare validation_success outside of try to handle situations with exception. 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. removed error_detected? we have two blocks of error_detected (189 and 194)? 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. Here's the commit that removes error_detected, I removed both of them and use validation_success instead: 60cac66 |
||
validation_success = False | ||
except jsonschema.exceptions.SchemaError as schemaErr: | ||
self.output.info("Errors found in %s schema, skip schema validation. Error:%s" % (schema_type, schemaErr.message)) | ||
except Exception as ex: # Ignore other non schema validation errors | ||
|
@@ -201,7 +204,7 @@ def _validate_deployment_manifest_schema(self): | |
validation_success = True | ||
try: | ||
deployment_schema = json.loads(urlopen(Constants.deployment_manifest_schema_url).read()) | ||
self._validate_json_schema(deployment_schema, self.json, "Deployment manifest") | ||
validation_success = self._validate_json_schema(deployment_schema, self.json, "Deployment manifest") | ||
except Exception as ex: # Ignore other non schema validation errors | ||
self.output.info("Unexpected error during deployment manifest schema validation, skip schema validation. Error:%s" % ex) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 2.1.2 | ||
current_version = 2.1.3 | ||
commit = True | ||
tag = True | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"modulesContent": { | ||
"$edgeAgent": { | ||
"properties.desired": { | ||
"schemaVersion": "1.0", | ||
"runtime": { | ||
"type": "docker", | ||
"settings": { | ||
"minDockerVersion": "v1.25", | ||
"loggingOptions": "", | ||
"registryCredentials": { | ||
"test": { | ||
"username": "$USERNAME", | ||
"password": "$PASSWORD", | ||
"address": "docker.io" | ||
} | ||
} | ||
} | ||
}, | ||
"systemModules": { | ||
"edgeAgent": { | ||
"type": "docker", | ||
"settings": { | ||
"image": "mcr.microsoft.com/azureiotedge-agent:1.0" | ||
} | ||
}, | ||
"edgeHub": { | ||
"type": "docker", | ||
"status": "running", | ||
"restartPolicy": "always", | ||
"settings": { | ||
"image": "mcr.microsoft.com/azureiotedge-hub:1.0", | ||
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}" | ||
} | ||
} | ||
}, | ||
"modules": { | ||
"tempSensor": { | ||
"version": "1.0", | ||
"type": "docker", | ||
"status": "running", | ||
"restartPolicy": "always", | ||
"settings": { | ||
"image": "mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0", | ||
"createOptions": "{\"Env\":[\"abcdefghij0=00\",\"abcdefghij1=01\",\"abcdefghij2=02\",\"abcdefghij3=03\",\"abcdefghij4=04\",\"abcdefghij5=05\",\"abcdefghij6=06\",\"abcdefghij7=07\",\"abcdefghij8=08\",\"abcdefghij9=09\",\"abcdefghij10=10\",\"abcdefghij11=11\",\"abcdefghij12=12\",\"abcdefghij13=13\",\"abcdefghij14=14\",\"abcdefghij15=15\",\"abcdefghij16=16\",\"abcdefghij17=17\",\"abcdefghij18=18\",\"abcdefghij19=19\",\"abcdefghij20=20\",\"abcdefghij22=21\",\"abcdefghij22=22\",\"abcdefghij23=23\",\"abcdefghij24=24\",\"abcdefghij25=25\",\"abcdefghij26=26\",\"abcdefghij27=27\",\"abcdefghi", | ||
"createOptions01": "j28=28\",\"abcdefghij29=29\",\"abcdefghij30=30\",\"abcdefghij31=31\",\"abcdefghij32=32\",\"abcdefghij33=33\",\"abcdefghij34=34\",\"abcdefghij35=35\",\"abcdefghij36=36\",\"abcdefghij37=37\",\"abcdefghij38=38\",\"abcdefghij39=39\",\"abcdefghij40=40\",\"abcdefghij41=41\",\"abcdefghij42=42\",\"abcdefghij43=43\",\"abcdefghij44=44\",\"abcdefghij45=45\",\"abcdefghij46=46\",\"abcdefghij47=47\",\"abcdefghij48=48\",\"abcdefghij49=49\",\"abcdefghij50=50\",\"abcdefghij51=51\",\"abcdefghij52=52\",\"abcdefghij53=53\",\"abcdefghij54=54\",\"abcdefghij55=55\",\"abcdefghij56abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh=56\",", | ||
"createOptions02": "\"abcdefghij56abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh=57\",\"abcdefghij58=58\",\"abcdefghij59=59\"]}" | ||
} | ||
}, | ||
"csharpmodule": { | ||
"version": "1.0", | ||
"type": "docker", | ||
"status": "running", | ||
"restartPolicy": "always", | ||
"settings": { | ||
"image": "${MODULES.csharpmodule.amd64}", | ||
"createOptions": "{\"Env\":[\"abcdefghij0=00\",\"abcdefghij1=01\",\"abcdefghij2=02\",\"abcdefghij3=03\",\"abcdefghij4=04\",\"abcdefghij5=05\",\"abcdefghij6=06\",\"abcdefghij7=07\",\"abcdefghij8=08\",\"abcdefghij9=09\",\"abcdefghij10=10\",\"abcdefghij11=11\",\"abcdefghij12=12\",\"abcdefghij13=13\",\"abcdefghij14=14\",\"abcdefghij15=15\",\"abcdefghij16=16\",\"abcdefghij17=17\",\"abcdefghij18=18\",\"abcdefghij19=19\",\"abcdefghij20=20\",\"abcdefghij22=21\",\"abcdefghij22=22\",\"abcdefghij23=23\",\"abcdefghij24=24\",\"abcdefghij25=25\",\"abcdefghij26=26\",\"abcdefghij27=27\",\"abcdefghi", | ||
"createOptions01": "j28=28\",\"abcdefghij29=29\",\"abcdefghij30=30\",\"abcdefghij31=31\",\"abcdefghij32=32\",\"abcdefghij33=33\",\"abcdefghij34=34\",\"abcdefghij35=35\",\"abcdefghij36=36\",\"abcdefghij37=37\",\"abcdefghij38=38\",\"abcdefghij39=39\",\"abcdefghij40=40\",\"abcdefghij41=41\",\"abcdefghij42=42\",\"abcdefghij43=43\",\"abcdefghij44=44\",\"abcdefghij45=45\",\"abcdefghij46=46\",\"abcdefghij47=47\",\"abcdefghij48=48\",\"abcdefghij49=49\",\"abcdefghij50=50\",\"abcdefghij51=51\",\"abcdefghij52=52\",\"abcdefghij53=53\",\"abcdefghij54=54\",\"abcdefghij55=55\",\"abcdefghij56=56\",", | ||
"createOptions03": "\"abcdefghij57=57\",\"abcdefghij58=58\",\"abcdefghij59=59\"]}" | ||
} | ||
}, | ||
"csharpfunction": { | ||
"version": "1.0", | ||
"type": "docker", | ||
"status": "running", | ||
"restartPolicy": "always", | ||
"settings": { | ||
"image": "${MODULES.csharpfunction.amd64.debug}", | ||
"createOptions": "[1,2,3]" | ||
} | ||
}, | ||
"csharpfunction2": { | ||
"version": "1.0", | ||
"type": "docker", | ||
"status": "running", | ||
"restartPolicy": "always", | ||
"settings": { | ||
"image": "${MODULES.csharpfunction2.amd64.debug}", | ||
"createOptions": "{\"Env\":[\"abcdefghij0=00\",\"abcdefghij1=01\",\"abcdefghij2=02\",\"abcdefghij3=03\",\"abcdefghij4=04\",\"abcdefghij5=05\",\"abcdefghij6=06\",\"abcdefghij7=07\",\"abcdefghij8=08\",\"abcdefghij9=09\",\"abcdefghij10=10\",\"abcdefghij11=11\",\"abcdefghij12=12\",\"abcdefghij13=13\",\"abcdefghij14=14\",\"abcdefghij15=15\",\"abcdefghij16=16\",\"abcdefghij17=17\",\"abcdefghij18=18\",\"abcdefghij19=19\",\"abcdefghij20=20\",\"abcdefghij22=21\",\"abcdefghij22=22\",\"abcdefghij23=23\",\"abcdefghij24=24\",\"abcdefghij25=25\",\"abcdefghij26=26\",\"abcdefghij27=27\",\"abcdefghi", | ||
"createOptions01": "j28=28\",\"abcdefghij29=29\",\"abcdefghij30=30\",\"abcdefghij31=31\",\"abcdefghij32=32\",\"abcdefghij33=33\",\"abcdefghij34=34\",\"abcdefghij35=35\",\"abcdefghij36=36\",\"abcdefghij37=37\",\"abcdefghij38=38\",\"abcdefghij39=39\",\"abcdefghij40=40\",\"abcdefghij41=41\",\"abcdefghij42=42\",\"abcdefghij43=43\",\"abcdefghij44=44\",\"abcdefghij45=45\",\"abcdefghij46=46\",\"abcdefghij47=47\",\"abcdefghij48=48\",\"abcdefghij49=49\",\"abcdefghij50=50\",\"abcdefghij51=51\",\"abcdefghij52=52\",\"abcdefghij53=53\",\"abcdefghij54=54\",\"abcdefghij55=55\",\"abcdefghij56=56\",", | ||
"createOptions03": "\"abcdefghij57=57\",\"abcdefghij58=58\",\"abcdefghij59=59\"]}", | ||
"createOptions04": {"test": "value"} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"$edgeHub": { | ||
"properties.desired": { | ||
"schemaVersion": "1.0", | ||
"routes": { | ||
"sensorTocsharpmodule": "FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/csharpmodule/inputs/input1\")", | ||
"csharpmoduleToIoTHub": "FROM /messages/modules/csharpmodule/outputs/* INTO $upstream", | ||
"csharpfunctionToIoTHub": "FROM /messages/modules/csharpfunction/outputs/* INTO $upstream" | ||
}, | ||
"storeAndForwardConfiguration": { | ||
"timeToLiveSecs": 7200 | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"modulesContent": { | ||
"$edgeAgent": { | ||
"properties.desired": { | ||
"schemaVersion": "1.0", | ||
"runtime": { | ||
"type": "docker", | ||
"settings": { | ||
"minDockerVersion": "v1.25", | ||
"loggingOptions": "", | ||
"registryCredentials": { | ||
"test": { | ||
"username": 1, | ||
"password": "pwd" | ||
}, | ||
"test2": { | ||
"username": "$USERNAME", | ||
"password": "$PASSWORD", | ||
"address": "" | ||
} | ||
} | ||
} | ||
}, | ||
"systemModules": { | ||
"edgeAgent": { | ||
"type": "docker", | ||
"settings": { | ||
"image": "mcr.microsoft.com/azureiotedge-agent:1.0" | ||
} | ||
}, | ||
"edgeHub": { | ||
"type": "docker", | ||
"status": "running", | ||
"restartPolicy": "always", | ||
"settings": { | ||
"image": "mcr.microsoft.com/azureiotedge-hub:1.0", | ||
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}" | ||
} | ||
} | ||
}, | ||
"modules": { | ||
"tempSensor": { | ||
"version": "1.0", | ||
"type": "docker", | ||
"status": "running", | ||
"restartPolicy": "always", | ||
"settings": { | ||
"image": "mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0", | ||
"createOptions": "{}" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"$edgeHub": { | ||
"properties.desired": { | ||
"schemaVersion": "1.0", | ||
"routes": { | ||
"sensorTocsharpmodule": "FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/csharpmodule/inputs/input1\")", | ||
"csharpmoduleToIoTHub": "FROM /messages/modules/csharpmodule/outputs/* INTO $upstream", | ||
"csharpfunctionToIoTHub": "FROM /messages/modules/csharpfunction/outputs/* INTO $upstream" | ||
}, | ||
"storeAndForwardConfiguration": { | ||
"timeToLiveSecs": 7200 | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
exception happens and the validation is still success?
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.
Only schema failures should be treated as validation failure. Other exceptions such as network error should not fail the validation. iotedgedev will only print related error and skip validation.