Skip to content

Fix message upgrade and config downgrades#864

Merged
noursaidi merged 8 commits intofaucetsdn:masterfrom
noursaidi:upgrade
Apr 30, 2024
Merged

Fix message upgrade and config downgrades#864
noursaidi merged 8 commits intofaucetsdn:masterfrom
noursaidi:upgrade

Conversation

@noursaidi
Copy link
Collaborator

No description provided.

@noursaidi noursaidi marked this pull request as ready for review April 24, 2024 14:23
@noursaidi noursaidi requested a review from grafnu April 24, 2024 14:23
Copy link
Collaborator

@grafnu grafnu left a comment

Choose a reason for hiding this comment

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

Just one minor real comment and then a few nits and pontifications

VERSION_1_5_0("1.5.0", 105000),
VERSION_1_4_2("1.4.2", 104020),
VERSION_1_4_0("1.4.0", 104000);
VERSION_1_4_1("1.4.1", 104010),
Copy link
Collaborator

Choose a reason for hiding this comment

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

These don't seem right, I would expect 1_4_1 to be 010401 (not 104010) and 1.3.14 to be 010314 (not 103014)... ? Something doesn't line up right!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right - I just followed the existing numbering. They all need changing

final Integer targetVersion = targetVersionEnum.value();

// downgrade to 1.4.1
if (currentVersion() > VERSION_1_4_1.value() && currentVersion() > targetVersion){
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we wanted to be really smarmy here we could make a table of sorts that had { versionA, versionB, downgradeFunc, upgradeFun } in it and then all this if statement stuff would be automagic!

Not something I'd suggest for now, but just something to keep in mind for the rainy day in the future when you're bored.

message.put(VERSION_KEY, String.format(TARGET_FORMAT, major, minor, patch));
} else {
// Files are now updated to Current version of UDMI
if(message.has(VERSION_KEY)){
Copy link
Collaborator

Choose a reason for hiding this comment

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

lint won't like this? Should have space after "if"

Also, comment is unclear or superfluous -- it's not particularly clarifying the why of anything?

Copy link
Collaborator Author

@noursaidi noursaidi Apr 25, 2024

Choose a reason for hiding this comment

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

Comment updated - Even if the message was not modified, it is now conformant to the current version of UDMI, so update the version property if it exists

Maybe worth a quick thought on if this is correct?

The main reason it was added was because the udmi_site_model devices have a future metadata version of 1.5.1. Consequently, trying to "downgrade" the config to 1.5.1 caused errors because the version it didn't exist. My solution was to correct the version at source. It also made sense because at the end of the upgrade process, even if unmodified, the message schema is "current". Whereas presently, we can have version "1" of files coming through.

I guess by stomping over the version, we lose the original information? Is it a problem? I could leave it as is and solve my unrecognized version differently.

private void upgradeTo_1_5_0_metadata() {

}
private void upgradeTo_1_4_1_metadata() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

spaces 'n' stuff

@grafnu
Copy link
Collaborator

grafnu commented Apr 25, 2024 via email

@noursaidi noursaidi merged commit 9a7f833 into faucetsdn:master Apr 30, 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.

2 participants