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

[deploy][scd/crdb] Add columns uss_requested_ovn and past_ovns to scd_operations table; Bump schema_version to v3.2.0 #1095

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

mickmis
Copy link
Contributor

@mickmis mickmis commented Sep 2, 2024

First step of #1078: this adds to the cockroach DB scd_operations table the ovn and past_ovns columns.
This change only concerns the DB and does not introduce any behavior change.
Note the README.md updates: removal of *_bootstrapper.sh (latest version is specified there) and addition of schema_manager.yaml.

CRDB schema

A NULL value in the ovn column signifies that the operational intent uses the existing DSS-generated OVN, which is derived from the timestamp of the last update. If it has a non-NULL value, it may not be an empty string, and it signifies that the OVN in force was proposed by the USS.

The past_ovns column is intended to contain all past OVNs of the operational intent, both DSS-generated and USS-proposed. This mechanism will be implemented in the next PR.

Testing

Do note that I've only tested this change by deploying locally the DSS and by validating that the CI passes. I've not tested deployment to the cloud: @barroco should this be tested manually before merging this PR or it this not necessary?

Comment on lines 227 to 232
if operation.OVN != "" {
ovn = pgtype.Text{
String: operation.OVN.String(),
Valid: true,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Side question: if we are going to set the ovn field only when it was specified by a client, should we possibly name it client_specified_ovn?

Alternatively, could we set it in any case and compute the time-based OVN once at insertion time instead of when it is retrieved from the database? Or is it important to be able to distinguish between client-provided and server-generated OVN, and to do this via a null ovn field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, could we set it in any case and compute the time-based OVN once at insertion time instead of when it is retrieved from the database? Or is it important to be able to distinguish between client-provided and server-generated OVN, and to do this via a null ovn field?

I did consider that initially, and at the time of making this PR the assumption was that if the provided suffix is not valid, the DSS just ignores it and do as usual.
However that assumption changed so maybe that's to be reconsidered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've looked into it, but unfortunately there isn't a simple way (i.e. w/o data migration) of computing the OVN at insertion time instead of when it is retrieved. The risk is that with the DSS update the previous OVNs cease to be valid which is of course not acceptable.
I will update the column however to make it more explicit that this is not the OVN in all cases however.

Comment on lines 6 to 10
CHECK (
array_position(past_ovns, NULL) IS NULL AND
array_position(past_ovns, '') IS NULL AND
array_position(past_ovns, ovn) IS NULL
); -- past_ovns must not contain NULL elements, empty strings or current ovn
Copy link
Contributor

Choose a reason for hiding this comment

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

Side thought: how big do we expect these arrays to grow?

I don't believe that enforcing the constraint will ever become a problem, but this still makes me wonder how many modifications of an OIR (which is what will cause this array to grow) we should expect in the worst case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know. But given that we don't use it to query anything, I don't expect its size to have any significant impact.

@mickmis mickmis marked this pull request as draft September 3, 2024 15:19
@mickmis mickmis marked this pull request as ready for review September 3, 2024 16:16
@mickmis mickmis marked this pull request as draft September 3, 2024 16:21
@mickmis mickmis marked this pull request as ready for review September 6, 2024 10:44
@mickmis mickmis marked this pull request as draft September 6, 2024 10:44
@mickmis mickmis force-pushed the 1078/crdb branch 2 times, most recently from c1a38c0 to c8c57f5 Compare September 6, 2024 10:51
@mickmis mickmis changed the title [scd/crdb] Add columns ovn and past_ovns to scd_operations table; Bump schema_version to v3.2.0 [scd/crdb] Add columns uss_requested_ovn and past_ovns to scd_operations table; Bump schema_version to v3.2.0 Sep 6, 2024
@mickmis mickmis marked this pull request as ready for review September 6, 2024 10:54
Copy link
Contributor

@barroco barroco left a comment

Choose a reason for hiding this comment

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

Small remark about the expected commit message / PR title.

Do note that I've only tested this change by deploying locally the DSS and by validating that the CI passes. I've not tested deployment to the cloud: @barroco should this be tested manually before merging this PR or it this not necessary?

Full scale deployment to the cloud will be tested before releasing the next stable version manually.
There is an action to deploy a DSS instance to AWS if you wish to run it on specific commits. (Only covers helm and aws for the moment)

build/deploy/examples/minimum/main.jsonnet Show resolved Hide resolved
@mickmis mickmis changed the title [scd/crdb] Add columns uss_requested_ovn and past_ovns to scd_operations table; Bump schema_version to v3.2.0 [deploy][scd/crdb] Add columns uss_requested_ovn and past_ovns to scd_operations table; Bump schema_version to v3.2.0 Sep 9, 2024
@mickmis mickmis removed the request for review from BenjaminPelletier September 9, 2024 12:58
@mickmis mickmis merged commit 7497c12 into interuss:master Sep 9, 2024
6 checks passed
@mickmis mickmis deleted the 1078/crdb branch September 9, 2024 12:59
Comment on lines +1 to +10
ALTER TABLE scd_operations
ADD COLUMN IF NOT EXISTS uss_requested_ovn STRING
CHECK (uss_requested_ovn != ''), -- uss_requested_ovn must be NULL if unspecified, not an empty string
ADD COLUMN IF NOT EXISTS past_ovns STRING[] NOT NULL
DEFAULT ARRAY []::STRING[]
CHECK (
array_position(past_ovns, NULL) IS NULL AND
array_position(past_ovns, '') IS NULL AND
array_position(past_ovns, uss_requested_ovn) IS NULL
); -- past_ovns must not contain NULL elements, empty strings or current uss_requested_ovn
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BenjaminPelletier @barroco FTR: the only modification this data migration is doing is to add columns. Given that the queries are only ever referencing explicitly columns (as opposed to a wildcard selection), I think it is safe to conclude that previous versions of the DSS runtime are compatible with this newer version of the schema.

(follow-up to the discussion last tuesday about upgrades during the InterUSS weekly)

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.

3 participants