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

Add Simulation API types #110

Merged
merged 1 commit into from
Aug 20, 2024
Merged

Add Simulation API types #110

merged 1 commit into from
Aug 20, 2024

Conversation

negz
Copy link
Member

@negz negz commented Aug 9, 2024

Description of your changes

These types are in service of an upcoming private preview Upbound feature.

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

These types have been tested with unit and E2E tests on an Upbound internal PR.

apis/spaces/v1alpha1/simulation_conditions.go Outdated Show resolved Hide resolved
apis/spaces/v1alpha1/simulation_types.go Outdated Show resolved Hide resolved
apis/spaces/v1alpha1/simulation_types.go Outdated Show resolved Hide resolved
apis/spaces/v1alpha1/simulation_types.go Show resolved Hide resolved
// +kubebuilder:default=AcceptingChanges
// +kubebuilder:validation:Enum=AcceptingChanges;Complete;Terminated
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Complete' ? self == 'Complete' || self == 'Terminated' : true",message="A complete Simulation can only be terminated"
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Terminated' ? self == oldSelf : true",message="A Simulation can't be un-terminated"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Terminated' ? self == oldSelf : true",message="A Simulation can't be un-terminated"
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Terminated' ? self == oldSelf : true",message="A Simulation can't be un-terminated"
// +optional

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you clarify why you're suggesting making this optional? It's not supposed to be an optional field.

Copy link
Member

Choose a reason for hiding this comment

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

It has a default value, so user doesn't have to provide it meaning it is optional.
But probably having a default is different than being optional 🤔

// A CompletionCriterion specifies when a simulation is complete.
type CompletionCriterion struct {
// Type of criterion.
// +kubebuilder:validation:Enum=Duration
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// +kubebuilder:validation:Enum=Duration
// +kubebuilder:default=Duration
// +kubebuilder:validation:Enum=Duration

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure how I feel about defaulting this to Duration.

Right now it's the only choice, but I think we'll add more values in future. I don't think we'd make duration the default once there are more options - there wouldn't be a default. So feel it could be surprising to users to make it the default now, but then not in future. It's a subtle difference, but I think I prefer requiring folks to explicitly specify the one allowed value.


// CompletionCriteria specify how Spaces should determine when the
// simulation is complete. If any of the criteria are met, Spaces will set
// the Simulation's desired state to complete. Omit the criteria if you want
Copy link
Member

Choose a reason for hiding this comment

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

If any of the criteria are met, Spaces will set the Simulation's desired state to complete.

Will it edit spec.desiredState ?
What if the user already set it to Complete or Terminated in the beginning? Would CompletionCriteria be ignored then? Any practical reason for someone to set it any value other than AcceptingChanges ? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Will it edit spec.desiredState ?

Yes, it will.

What if the user already set it to Complete or Terminated in the beginning?

Yes, if the simulation is already complete (or terminated) the completion criteria are ignored.

Any practical reason for someone to set it any value other than AcceptingChanges ?

You mean spec.desiredState? If so:

  • You'd set spec.desiredState to Complete to manually mark the simulation complete, and thus trigger detection of the changes that happened while it was accepting changes. In this case you'd probably leave the completion criteria empty. Though you could also set the completion criteria to say 10 minutes but then later decide to manually mark the simulation complete (by changing spec.desiredState after 5 minutes.

  • You'd set spec.desiredState to Terminated to terminate the simulation. This is the only way a simulation can be terminated. (A terminated simulation no longer has a control plane, but still exists so you can see the change summary in status.)

I'm open to updating the comment if there's a relatively succinct way to make this clearer.

Copy link
Contributor

@sttts sttts left a comment

Choose a reason for hiding this comment

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

Just nits.

@negz negz merged commit 9b966ac into upbound:main Aug 20, 2024
5 checks passed
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