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

chore: delete triggeredAt for AutoOps #1179

Merged
merged 11 commits into from
Aug 16, 2024
Merged

Conversation

kakcy
Copy link
Contributor

@kakcy kakcy commented Aug 1, 2024

No description provided.

@kakcy kakcy marked this pull request as ready for review August 5, 2024 02:25
Copy link
Contributor

@kentakozuka kentakozuka left a comment

Choose a reason for hiding this comment

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

Thanks! left comments. ptal.

@@ -789,7 +789,7 @@ message AutoOpsRuleCreatedEvent {
string feature_id = 1;
bucketeer.autoops.OpsType ops_type = 2;
repeated bucketeer.autoops.Clause clauses = 3;
int64 triggered_at = 4 [deprecated = true];
reserved 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
reserved 4;
reserved 4; // int64 triggered_at = 4 [deprecated = true];

@@ -85,8 +85,7 @@ message UpdateAutoOpsRuleResponse {}
message ExecuteAutoOpsRequest {
string environment_namespace = 1;
string id = 2;
ChangeAutoOpsRuleTriggeredAtCommand
change_auto_ops_rule_triggered_at_command = 3 [deprecated = true];
reserved 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
reserved 3;
reserved 3; // ChangeAutoOpsRuleTriggeredAtCommand
change_auto_ops_rule_triggered_at_command = 3 [deprecated = true];

@@ -24,7 +24,7 @@ message AutoOpsRule {
string feature_id = 2;
OpsType ops_type = 3;
repeated Clause clauses = 4;
int64 triggered_at = 6 [deprecated = true];
reserved 6;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
reserved 6;
reserved 6; // int64 triggered_at = 6 [deprecated = true];

@@ -706,7 +706,7 @@ func (s *AutoOpsService) UpdateAutoOpsRule(
return err
}

if autoOpsRule.AlreadyTriggered() || autoOpsRule.IsFinished() || autoOpsRule.IsStopped() {
if autoOpsRule.IsFinished() || autoOpsRule.IsStopped() {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about adding a new method IsCompleted() to the domain?

Copy link
Member

Choose a reason for hiding this comment

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

The isCompleted will be confusing IMHO.
Because the complete and finish have the same meaning in this case.
It will be easier to understand and leave it as it is. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cre8ivejp @kentakozuka

It may be confusing how to use it.
Add deleted to the condition,
How about changing it to IsInactive()?

Copy link
Member

Choose a reason for hiding this comment

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

@kakcy, the issue is not the function name. By creating IsInactive or isCompleted, we are creating a new state that doesn't exist in the auto_ops_rule domain layer, which is confusing because completed and finished words have the same meaning in this case.
So, my suggestion is to leave it as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cre8ivejp @kentakozuka
Since there were multiple locations that made the same judgment, we decided that it would be better to add a new one to improve the readability of the code.

However, as you pointed out, IsCompleted() does not exist in AutoOpsStatus, and having a function that determines a similar status causes confusion when used, so I will discontinue it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted IsCompleted().
1aae01c

Copy link
Contributor Author

@kakcy kakcy left a comment

Choose a reason for hiding this comment

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

I have corrected the points pointed out.
Please check it when you have time.

@@ -135,20 +120,19 @@ func (a *AutoOpsRule) IsStopped() bool {
return a.AutoOpsStatus == proto.AutoOpsStatus_STOPPED
}

func (a *AutoOpsRule) IsCompleted() bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add IsCompleted()

@@ -179,7 +182,7 @@ func (s *autoOpsRuleStorage) ListAutoOpsRules(
&autoOpsRule.FeatureId,
&opsType,
&mysql.JSONObject{Val: &autoOpsRule.Clauses},
&autoOpsRule.TriggeredAt,
&tmpTriggeredAt, // ToDo: TriggeredAt is deprecated. Remove this line after migration.
Copy link
Member

Choose a reason for hiding this comment

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

By removing this line, we don't need to wait for the migration.

@@ -139,7 +141,7 @@ func (s *autoOpsRuleStorage) GetAutoOpsRule(
&autoOpsRule.FeatureId,
&opsType,
&mysql.JSONObject{Val: &autoOpsRule.Clauses},
&autoOpsRule.TriggeredAt,
&tmpTriggeredAt, // ToDo: TriggeredAt is deprecated. Remove this line after migration.
Copy link
Member

Choose a reason for hiding this comment

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

By removing this line, we don't need to wait for the migration.

@@ -102,7 +102,7 @@ func (s *autoOpsRuleStorage) UpdateAutoOpsRule(
e.FeatureId,
int32(e.OpsType),
mysql.JSONObject{Val: e.Clauses},
e.TriggeredAt,
0, // ToDo: TriggeredAt is deprecated. Remove this line after migration.
Copy link
Member

Choose a reason for hiding this comment

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

By removing this line, we don't need to wait for the migration.

@@ -75,7 +75,7 @@ func (s *autoOpsRuleStorage) CreateAutoOpsRule(
e.FeatureId,
int32(e.OpsType),
mysql.JSONObject{Val: e.Clauses},
e.TriggeredAt,
0, // ToDo: TriggeredAt is deprecated. Remove this line after migration.
Copy link
Member

Choose a reason for hiding this comment

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

It will be safer if you alter the triggered_at column and set a default value to zero. Then, you can remove this line without waiting for the migration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cre8ivejp
Thank you!
I tried to respond with this commit, please check if there is any problem with the response method.

@@ -4,7 +4,7 @@ SET
feature_id = ?,
ops_type = ?,
clauses = ?,
triggered_at = ?,
triggered_at = 0,
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to set this to zero.
You can remove this line from the query because the field is not required when updating.

@kakcy kakcy force-pushed the delete-triggered-at-for-auto-ops branch from df69d39 to 1aae01c Compare August 6, 2024 02:27
Copy link
Contributor Author

@kakcy kakcy left a comment

Choose a reason for hiding this comment

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

I have corrected the points pointed out.
Please check it when you have time.

@@ -706,7 +706,7 @@ func (s *AutoOpsService) UpdateAutoOpsRule(
return err
}

if autoOpsRule.AlreadyTriggered() || autoOpsRule.IsFinished() || autoOpsRule.IsStopped() {
if autoOpsRule.IsFinished() || autoOpsRule.IsStopped() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted IsCompleted().
1aae01c

@@ -4,7 +4,6 @@ SET
feature_id = ?,
ops_type = ?,
clauses = ?,
triggered_at = ?,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I deleted it.

@kakcy kakcy force-pushed the delete-triggered-at-for-auto-ops branch from 7eb8ba5 to ab36dfa Compare August 15, 2024 07:19
Copy link
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

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

Thank you!

@kakcy kakcy merged commit 3df9296 into main Aug 16, 2024
22 checks passed
@kakcy kakcy deleted the delete-triggered-at-for-auto-ops branch August 16, 2024 03:03
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