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 downgrade support #343

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Fix downgrade support #343

wants to merge 9 commits into from

Conversation

lo-simon
Copy link
Contributor

@lo-simon lo-simon commented Sep 7, 2023

Fix IS-04 (v1.3) downgrade resource to register to v1.2 Registry.

There are some parameters which have been extended in nmos-parameter-registers for the latest nmos version.

The problem was identified when a downgraded v1.3 video flow with transfer_characteristic set to UNSPECIFIED failed to register to the v1.2 Registry. It is because v1.2 video flow schema used in the Registry does not allow transfer_characteristic to be UNSPECIFIED. This PR sets the default values for the downgraded resources when an invalid value is used or removes it if the parameter is optional.

See https://specs.amwa.tv/nmos-parameter-registers/branches/main/flow-attributes/#transfer-characteristic

@garethsb
Copy link
Contributor

garethsb commented Sep 7, 2023

Since this is a significant change to code which is used by both Node and Registry, I recommend unit tests with very good coverage are added.

Copy link
Contributor

@garethsb garethsb left a comment

Choose a reason for hiding this comment

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

A few comments

}
})")
},
{ make_schema_id(is04_versions::v1_1, nmos::types::sender, U("tags")), make_schema(R"({
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see any difference between v1.0 and v1.1 schemas for tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sender's tags v1.0 is optional and v1.1 is not.

"description": "URN identifying the type of service",
"format": "uri"
},
"authorization": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to remove authorization when downgrading before v1.3? The v1.2 schema doesn't consider it invalid as far as I know. Same applies to many other cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only apply the JSON validation on the device's 'controls' parameter when downgrading to v1.1 or v1.2. If JSON validation fails, the 'controlswill be set to an empty array. btw if that ever happens, our idea of theis_permitted_downgrade` is no longer corrected. I am just extending the original downgrade resources_versions, rather than adding sub-parameters.

{ U("href") },
{ U("hostname") },
{ U("caps") },
{ U("services"), value::array() }
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like right strategy to me. I don't think we should remove authorization when considering v1.3 node resource and exposing it via Node API v1.0 or registering via Registration API v1.0. If someone has good reason that we should do that, I don't think we should ever remove all services and replace with empty array... 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as long as the JSON validation is successful, the authorization parameter will not be removed.

}

// list of property validators to identify the associated property has been changed since the previous version
static const web::json::experimental::json_validator& property_changed_validator()
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: property_changed_validator sounds like something that is used to perform validation every time a property is changed (e.g. as a result of nmos::modify_resource). Not sure what is the best name, though!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe just named it as property_validator, using the word changed because I wanted to specify that the validator is only used for those properties which have schema changed between versions.

return U("/downgrade") + make_api_version(version) + U("-") + type.name + U("-") + property;
}

// property schemas are extracted from the resource schemas
Copy link
Contributor

Choose a reason for hiding this comment

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

Since all of these property schemas are already included in the full schemas embedded in nmos-cpp, could this code be refactored to use a json value path to extract the property value schema from those? Not sure...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we agree with this PR, this can be followed up.

@lo-simon
Copy link
Contributor Author

lo-simon commented Sep 8, 2023

Since this is a significant change to code which is used by both Node and Registry, I recommend unit tests with very good coverage are added.

Yes totally agree

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.

2 participants