-
Notifications
You must be signed in to change notification settings - Fork 153
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 checkReplicasChange function to detect changes in replicas field #5341
base: master
Are you sure you want to change the base?
Conversation
…iveValue Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
if node.TypeX == nil { | ||
// The replicas field is not found in the old manifest. | ||
before = "" | ||
} |
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.
🤔 oops, we should put this before as "nil"
?
I could not determine whether the empty string or "nil"
is better.
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.
@khanhtc1202 @t-kikuc @ffjlabo
WDYT about this?
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.
@Warashi
When does node.TypeX == nil
occur?
I think we should clarify the situation to determine it.
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.
@ffjlabo Sorry for forgetting to write it.
When the replicas field is not found in the old manifests, node.TypeX
becomes nil
and node.ValueX
becomes invalid value.
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.
@ffjlabo Sorry for forgetting to write it.
When the replicas field is not found in the old manifests, node.TypeX becomes nil and node.ValueX becomes invalid value.
Thanks.
When the replicas field is not found in the old manifests,
It seems that the node
is the one that has spec.replicas
extracting by the logic before.
So we might not need to check it.
const replicasQuery = `^spec\.replicas$`
node, err := ns.FindOne(replicasQuery)
I'm sorry if I misunderstood. 🙏
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.
Thanks 👍🏻
BTW, I realized it's better to return "<nil>"
instead of an empty string because the before and after are used in this context.
pipecd/pkg/app/piped/planner/kubernetes/kubernetes.go
Lines 311 to 313 in 23eddac
if before, after, changed := checkReplicasChange(d); changed { | |
scales = append(scales, fmt.Sprintf("%s/%s from %s to %s", k.Kind, k.Name, before, after)) | |
} |
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.
fixed on this commit
13625ca
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.
@Warashi
Nice catch! I agree with it! The case is when there is nothing spec.replicas
.
I think the <nil>
value should be defined as const value. WDYT?
We might use it to express the same situation. e.g. checkImageTags.
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.
@ffjlabo
I think it's too early to make "<nil>"
as constant because we use this only two places in one function, and we should use "<nil>"
carefully because whether the "<nil>"
or an empty string should be used is case-by-case.
For example, I think the image nginx
should be just nginx
, not nginx:<nil>
.
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.
@Warashi
I agree with it. Thanks. So let's rethink it when the same situation will occur. 👌
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5341 +/- ##
=======================================
Coverage 25.31% 25.32%
=======================================
Files 444 444
Lines 47641 47688 +47
=======================================
+ Hits 12059 12075 +16
- Misses 34640 34668 +28
- Partials 942 945 +3 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
…s field in manifests Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
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.
LGTM 🆗
What this PR does:
Why we need it:
We chose a quick sync strategy when the diffs are only replicas.
We must build a summary message with the workload changed, so we must check it.
Which issue(s) this PR fixes:
Part of #4980
Does this PR introduce a user-facing change?: Yes
How are users affected by this change:
When users delete or add the spec.replicas field on the Deployment manifest, they can view the plan summary as expected. Without this PR, they will see an invalid value.
Is this breaking change: No
How to migrate (if breaking change): N/A