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

[FLI-937] Ensure determinism in exporting and declarative formats #2915

Open
1 task done
markphelps opened this issue Mar 28, 2024 · 0 comments
Open
1 task done

[FLI-937] Ensure determinism in exporting and declarative formats #2915

markphelps opened this issue Mar 28, 2024 · 0 comments
Labels
enhancement Created by Linear-GitHub Sync

Comments

@markphelps
Copy link
Collaborator

markphelps commented Mar 28, 2024

Problem

From Discord: https://discord.com/channels/960634591000014878/960697263150227510/1222701847257550919

Does flipt have a consistent/deterministic ordering of flags/keys/segments, etc when exporting?

The intention is yes, they should have. Though resulting order is dependent on the backend used.
The export currently walks the read portions of the API, using the standard pagination list operations to get the material.
The exporter does rely on the default sort order of each resource. This differs depending on the resource and the backend type chosen.

As an example: Flag and Segment in the relational backends returns sorted by created at timestamp.
Where rules and rollouts are sorted by an explicit rank. This is the order defined in the UI or implicitly the order in the list in the export format.

There is a subtle issue with the declarative formats that makes these orders different for exporting from e.g. Git, local, Object or OCI compared with the relational. This is because we don't have resource-level created at timestamps. We don't write arbitrary created at times in the export format. So instead, here we sort by the key instead.

But either way, that should only be a problem if you're comparing export format from a relational backend instance with one from a declarative backed one. Two exports from the same logical Flipt instance should produce consistent results.

@GeorgeMac for my usecase, I could go either two ways right now:
if writable local backend becomes a thing, that may be the answer (e.g. sorting flags and segments by key is 👍), or
git repo -> import, modify with local sqlite, export, commit -> build, etc

So when exporting from sqlite, they're based on timestamp though and not key right now?

Yeah thats correct, this stems from the export format and list APIs predating the declarative backends.
It was developed to export from the relational backends.

cc @GeorgeMac

Ideal Solution

Its not a huge change to adjust, we just need to consider the implications of changing the export order for folks already depending on it. We know there are users who are running export and putting the result in Git, then importing it into other Flipts later. Changing the order would likely cause a big diff for those users. Maybe if that is something they're ok with though, we can certainly find out.

Export code listing flags is here

resp, err := e.store.ListFlags(
ctx,
&flipt.ListFlagRequest{
NamespaceKey: namespaces[i],
PageToken: nextPage,
Limit: batchSize,
},
)

If we wanted to e.g. make it consistently sort by key we would need to add support for that ordering constraint to the storage list APIs too.

Search

  • I searched for other open and closed issues before opening this

Additional Context

No response

FLI-937

@markphelps markphelps added the enhancement Created by Linear-GitHub Sync label Mar 28, 2024
@markphelps markphelps changed the title Ensure determinism in exporting and declarative formats [FLI-937] Ensure determinism in exporting and declarative formats Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Created by Linear-GitHub Sync
Projects
Status: No status
Development

No branches or pull requests

1 participant