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

Ms2/config versioning #433

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Ms2/config versioning #433

wants to merge 12 commits into from

Conversation

canptura
Copy link
Contributor

@canptura canptura commented Dec 9, 2024

Summary

This re-enables the versioning for configs/techdata sets in a similar fashion to the process versioning. This state is usable and presentable eventhough some problems still persist. For example linked parameters are currently not referenced correctly when versioned and also deletion of a config may cause version data to stay unreferenced in storage.

Details

  • versionedParentConfigs added to the techdata-store
  • addParentConfigVersion() added to store a new version of the current state
  • setParentConfigVersionAsLatest added overwrite latest config

This comment has been minimized.

versionDescription: string;
}) => {
const versionId = v4();
await addParentConfigVersion(parentConfig, environment.spaceId, versionId);
Copy link
Contributor

Choose a reason for hiding this comment

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

You should check for a user error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What kind of error do you mean?

Comment on lines 165 to 178
version
? (storedData.versionedParentConfigs[parentConfig.id][version] = {
...parentConfig,
targetConfig: targetConfigToStorage(parentConfig.id, targetConfig, newId),
machineConfigs: machineConfigsToStorage(parentConfig.id, machineConfigs, newId),
metadata: parametersToStorage(parentConfig.id, 'parent-config', metadata, newId),
})
: (storedData.parentConfigs[parentConfig.id] = {
...parentConfig,
targetConfig: targetConfigToStorage(parentConfig.id, targetConfig, newId),
machineConfigs: machineConfigsToStorage(parentConfig.id, machineConfigs, newId),
metadata: parametersToStorage(parentConfig.id, 'parent-config', metadata, newId),
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Both of these are storing the same value, you could store it in a variable and the conditionally store it.
Also, since in the lines above you set storedData.versionedParentConfigs[parentConfig.id] = {}, the second case wouldn't happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, but what do you mean when you say the second case wouldn't happen? The conditional branch only depends on the version string which is not changed

src/management-system-v2/lib/data/legacy/machine-config.ts Outdated Show resolved Hide resolved
@@ -571,6 +638,23 @@ export async function addParentConfig(
}
}

// TODO
export async function setParentConfigVersionAsLatest(machineConfigInput: ParentConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Im a bit confused as to what this function does, could you explain it?

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 copies the data of a specific config-version into the editable "main-config" displayed as latest version. This is to provide the same functionality as the process-versions

@@ -33,6 +34,8 @@ type StoredConfigsAndParameters = {
machineConfigs: Record<string, StoredMachineConfig>;
targetConfigs: Record<string, StoredTargetConfig>;
parameters: Record<string, StoredParameter>;
// versionedParentConfigs: Record<string, StoredParentConfig>;
versionedParentConfigs: Record<string, Record<string, StoredParentConfig>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the versionId should be a part of the config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is. The type StoredParentConfig contains the field version to keep track of the version number.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

github-actions bot commented Jan 9, 2025

CLOUDRUN ACTIONS

✅ Successfully created Preview Deployment.

https://pr-433---ms-server-staging-c4f6qdpj7q-ew.a.run.app

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