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

rework the commitments data model and API #383

Merged
merged 7 commits into from
Dec 7, 2023
Merged

Conversation

majewsky
Copy link
Contributor

@majewsky majewsky commented Nov 30, 2023

Based on feedback from the Demand Management folks, and my own thoughts based on that feedback. Roughly ordered by complexity:

  • rename requested_at field to created_at (in the future, there will be several workflows to create commitment objects that are not really requests)
  • add fields to identify the creating user (cheap to do now; if we need it later, we can save ourselves a tedious and expensive lookup in the audit log)
  • commitments shall never be deleteable by regular users, only by cloud admins
  • report min_confirm_date in commitment config
  • add a dry-run API endpoint, to test if a commitment of X size in a given AZ could be confirmed immediately
  • change semantics of confirm_after while renaming it to confirm_by
    • confirm_by can be chosen by the user
    • commitments without confirm_by can only be created if they can be confirmed immediately (hence why we need the aforementioned dry run ability for a clean UI workflow)
    • commitments with confirm_by will have expires_at = confirm_by + duration instead of expires_at = confirmed_at + duration (i.e. if we take longer to provide the requested capacity, the customer shall not be bound to pay for it longer than they anticipated when requesting)
    • commitments with confirm_by need to have confirm_by >= min_confirm_date (hence why this config attribute needs to be surfaced in the API)

This includes changes to the vendored go-api-declarations copy that does not exist in this form in that module's upstream repo. All the changes to go-api-declarations to this feature branch will be bundled into a single commit in go-api-declarations in the end to avoid a bunch of useless intermediate releases on that upstream repo. Done.

@majewsky majewsky requested a review from VoigtS November 30, 2023 12:57
@coveralls
Copy link

coveralls commented Nov 30, 2023

Coverage Status

coverage: 80.202% (+0.003%) from 80.199%
when pulling 8623cc9 on commitment-rework
into 3e73004 on master.

@majewsky majewsky force-pushed the commitment-rework branch 6 times, most recently from c3de719 to 70fbd42 Compare December 6, 2023 12:39
@majewsky majewsky marked this pull request as ready for review December 6, 2023 12:39
- "confirm_after" becomes "confirm_by" in a move that anticipates an
  upcoming semantic change in the commitment state machine. This change
  will come later, but since I'm doing a DB migration anyway, I'm
  including it here.
- "requested_at" becomes "created_at" because the "request" wording only
  applies to completely fresh commitments. Later, we will add workflow
  for transferring, splitting and converting commitments. All of these
  will have a creation timestamp without that creation referring to a
  request.
- I'm adding some fields to identify who created a commitment, since
  this information may be valuable, but surfacing it from the CADF audit
  log is usually quite tedious.

This includes a change to the vendored go-api-declarations copy that
does not exist in this form in that module's upstream repo. All the
changes to go-api-declarations to this feature branch will be bundled
into a single commit in go-api-declarations in the end to avoid a bunch
of useless intermediate releases on that upstream repo.
The test for this is quite incomplete because a full test requires
reworking the POST .../new endpoint, which I will do in the next commit.
This one is large enough as it is.
- If `confirm_by` is absent, the commitment must be immediately
  confirmed upon creation. Insufficient committable capacity is an
  error.

- If `confirm_by` is present, the commitment will be confirmed after
  that timestamp as soon as committable capacity is available.

- To avoid surprises for the users, `expires_at` counts from the moment
  when the commitment could first be confirmed, instead of from the
  moment of confirmation. This is only a difference for commitments with
  delayed confirmation:

  ```
  expires_at = confirmed_at + duration   # before
  expires_at = confirm_by + duration     # after
  ```
internal/api/commitment.go Show resolved Hide resolved
internal/api/commitment.go Show resolved Hide resolved
@majewsky majewsky merged commit a1eab43 into master Dec 7, 2023
7 checks passed
@majewsky majewsky deleted the commitment-rework branch December 7, 2023 09:29
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