-
Notifications
You must be signed in to change notification settings - Fork 0
Implement disabled reason for flow #782
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ class FlowHandler < Tucana::Sagittarius::FlowService::Service | |
| def self.update_runtime(runtime) | ||
| flows = [] | ||
| runtime.project_assignments.compatible.each do |assignment| | ||
| assignment.namespace_project.flows.each do |flow| | ||
| assignment.namespace_project.flows.enabled.each do |flow| | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| flows << flow.to_grpc | ||
| end | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,17 @@ class Flow < ApplicationRecord | |
| allow_blank: false, | ||
| uniqueness: { case_sensitive: false, scope: :project_id } | ||
|
|
||
| validates :disabled_reason, presence: false, | ||
| allow_blank: true, | ||
| length: { maximum: 100, minimum: 0 } | ||
|
|
||
| scope :enabled, -> { where(disabled_reason: nil) } | ||
| scope :disabled, -> { where.not(disabled_reason: nil) } | ||
|
|
||
| def disabled? | ||
| disabled_reason.present? | ||
| end | ||
|
|
||
| def to_grpc | ||
| Tucana::Shared::ValidationFlow.new( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add |
||
| flow_id: id, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class AddDisabledReasontoFlows < Code0::ZeroTrack::Database::Migration[1.0] | ||
| def change | ||
| add_column :flows, :disabled_reason, :text, null: true, default: nil | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this should be an enum on the model, this should be changed to an integer |
||
| add_index :flows, :disabled_reason, length: 100 | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 4b5be2b087ebee13e1319410194a92b64672b7cf3b7b1c9abb7e8bc59d2e94e5 |
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.
I wouldn't have exposed this to the user because the reason would for example be used when a flow gets disabled because the namespace reached its execution quota and we don't want the user to re-enable the flow themself by just removing the
disabled_reason.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.
I thought thats a user string to disable the flow, maybe we should add translations there for different messages, like quota and other stuff
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.
In the database this would most likely be an enum column like we have with DataTypeRule.variant. For now I would say that the user is not able to change it and it is a system defined value. For example
quota_exceeded,invalid_flowor things like thatThere 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 should be removed, because the user should not set a disabled reason themself as Niklas explained.