Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Consider replacing SnapshotStatus enum with booleans #302

Closed
saad-ali opened this issue Nov 6, 2018 · 5 comments · Fixed by #307
Closed

Consider replacing SnapshotStatus enum with booleans #302

saad-ali opened this issue Nov 6, 2018 · 5 comments · Fixed by #307
Assignees
Milestone

Comments

@saad-ali
Copy link
Member

saad-ali commented Nov 6, 2018

An enum when used for "state" encourages clients to write switch statements or or statements capturing every currently known state of enum and fail if the state is unrecognized. This leads to clients breaking when a new value is added to the enum (which should be a non-breaking additive change).

In Kubernetes we've moved to a model where we flaten the enum in to booleans, e.g. is_ready, which makes it harder for a client to be written in a forward incompatible way.

So request is to consider replacing SnapshotStatus enum with booleans.

@saad-ali
Copy link
Member Author

saad-ali commented Nov 7, 2018

@julian-hj made a good point: Kubernetes has to deal with many many consumers, this code is consumed by a handful of COs, so this is not as much of an issue.

Also @jdef mentioned that for terminal states, you would want the client to fail so optimizing for non-terminal states doesn't necessarily add much value.

Agreed with both points, will close this issue.

@saad-ali saad-ali closed this as completed Nov 7, 2018
@saad-ali
Copy link
Member Author

saad-ali commented Nov 7, 2018

Also @jdef mentioned that for terminal states, you would want the client to fail so optimizing for non-terminal states doesn't necessarily add much value.

Discussed this some more with thockin. He pointed out that a good APIs should not make backwards compatibility breaking changes but may make additive changes. And when you have additive changes a list of booleans is much less likely to cause breakages then an enum (e.g. introducing a new state that new clients should handle, but doesn't invalidate any existing state or any existing clients handling of that state).

I'll leave this open for now. If we can't get consensus on it by the time we want to cut 1.0.rc we can abandon it. In the meantime assigning to @xing-yang @jingxu97 to explore.

@saad-ali
Copy link
Member Author

saad-ali commented Nov 7, 2018

Spoke with @jingxu97 @xing-yang and they pointed out that the multiple states are not necessary based on their implementation for Kubernetes. Error does not need to be a state.

Their proposal for simplifcation:

  • When CreateSnapshotRequest is called, it blocks until the snapshot is cut, and returns a CreateSnapshotRequest with a new boolean isReadyToUse set to false indicating the snapshot has been taken and any workload can be resumed.
  • CO then reissues CreateSnapshotRequest repeatedly until boolean isReadyToUse flips to true indicating the volume has been "processed" or "uploaded" and is ready to use to create new Snapshots.
  • If there is an error during cutting the initial call will fail with gRPC error.
  • If there is an error during "processing" (aka "uploading") the followup CreateSnapshotRequest will fail.
  • There is no need to differentiate between a failure during cut vs upload because CO will not treat those differently.

@jdef
Copy link
Member

jdef commented Nov 7, 2018 via email

@julian-hj
Copy link
Contributor

Sounds good to me. It would bring the snapshot RPCs more in alignment with the other RPCs.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants