-
Notifications
You must be signed in to change notification settings - Fork 37
Implement new automatic snapshot feature #2403
base: b6.3
Are you sure you want to change the base?
Conversation
93fa574
to
3b789d1
Compare
#[cfg_attr(feature = "graphql", derive(juniper::GraphQLObject))] | ||
#[derive(serde::Deserialize, serde::Serialize, Eq, Clone, Debug)] | ||
/// Automatic snapshot policy | ||
pub struct SnapshotPolicy { |
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.
FYI, currently weeks end on Sunday. I think it would be the best to make it part of the policy, even if not visible for users.
14e32b4
to
5d15364
Compare
svcs.insert(p, ah); | ||
} | ||
|
||
tokio::time::delay_for(tokio::time::Duration::from_secs(6)).await; |
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.
Any significance to 6 seconds?
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.
No :)
start: NaiveDateTime, | ||
datetimes: &[NaiveDateTime], | ||
) -> LinkedList<LinkedList<NaiveDateTime>> { | ||
let mut v: Vec<i64> = datetimes |
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.
Any benefit to using a linked list? If we could use a Set we wouldn't need to worry about de-duping.
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.
It's just that the size is not known in advance. And more importantly, the order is important.
why do we have policy and interval in help output? is it overlapping functionality or it is different? |
It's a previous effort which will be replaced by this new feature. You can ignore it for now. |
e3a0efd
to
2cff950
Compare
2cff950
to
17df2d3
Compare
@ip1981 please rebase, this has conflicts on latest master. |
iml-api/src/graphql/mod.rs
Outdated
), | ||
))] | ||
/// Creates a new automatic snapshot policy. | ||
async fn create_snapshot_policy( |
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.
Let's move this (and any other snapshot related queries / mutations) into a new snapshot module so it's consistent with other areas.
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.
Is it possible? Looks like we put everything into the implementation of pub(crate) struct QueryRoot
.
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.
Yup, we are doing this in a few other areas already.
ref:
pub(crate) struct StratagemQuery; |
iml-api/src/graphql/mod.rs
Outdated
sqlx::query!( | ||
r#" | ||
DELETE FROM snapshot_policy | ||
WHERE (filesystem IS NOT DISTINCT FROM $1) |
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.
Why not !=
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.
Because $1
can be NULL.
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.
Given we can only have one policy per fs, why do we need the id at all?
Why not just make filesystem
the only required param as it's already a unique key?
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.
This was written first when I thought id
would be used in general and fs
only for convenience. I will update.
iml-api/src/graphql/mod.rs
Outdated
r#" | ||
DELETE FROM snapshot_policy | ||
WHERE (filesystem IS NOT DISTINCT FROM $1) | ||
OR (id IS NOT DISTINCT FROM $2) |
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.
Why not !=
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.
Likewise, $2
can be NULL. I don't actually use id
. So here it's just a PoC.
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.
Yeah, I think we should eliminate the id and just make the fs field required.
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.
... and it will be =
;-)
eac5624
to
3d4c89c
Compare
Done at the DB level and in GUI.
Done. First create a new snapshot if possible, then cleanup. There are a couple of things to improve, but in general it's ready.
|
3d4c89c
to
c59d2bd
Compare
a128baa
to
ec17b4f
Compare
ec17b4f
to
b4c5354
Compare
Signed-off-by: Igor Pashev <[email protected]>
b4c5354
to
4298bef
Compare
Signed-off-by: Igor Pashev <[email protected]>
Signed-off-by: Igor Pashev <[email protected]>
c6fd0fe
to
036af3e
Compare
Signed-off-by: Igor Pashev <[email protected]>
4a1bbdc
to
34c0016
Compare
76c9662
to
002be2a
Compare
Signed-off-by: Igor Pashev <[email protected]>
002be2a
to
d3d62fd
Compare
Signed-off-by: Igor Pashev [email protected]
This change is