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

fix: Use actual weight from status field on rollout object #1937

Merged
merged 10 commits into from
Apr 1, 2022

Conversation

zachaller
Copy link
Collaborator

This fixes #1812 by pulling the actual weight from the status field instead
of the SetWeight.

Signed-off-by: zachaller [email protected]

@codecov
Copy link

codecov bot commented Mar 28, 2022

Codecov Report

Merging #1937 (c8095b8) into master (55a041a) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1937      +/-   ##
==========================================
+ Coverage   82.40%   82.42%   +0.02%     
==========================================
  Files         119      119              
  Lines       16910    16913       +3     
==========================================
+ Hits        13934    13940       +6     
+ Misses       2285     2282       -3     
  Partials      691      691              
Impacted Files Coverage Δ
pkg/kubectl-argo-rollouts/info/rollout_info.go 89.63% <100.00%> (+1.74%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55a041a...c8095b8. Read the comment docs.

This fixes argoproj#1812 by pulling the actual weight from the status field instead
of the SetWeight.

Signed-off-by: zachaller <[email protected]>
if ro.Status.Canary.Weights != nil {
roInfo.ActualWeight = fmt.Sprintf("%d", ro.Status.Canary.Weights.Canary.Weight)
} else {
roInfo.ActualWeight = "n/a"
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of n/a, can we set to equal to
roInfo.ActualWeight = roInfo.SetWeight

Copy link
Contributor

Choose a reason for hiding this comment

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

also, can you verify if we can add a test for this use case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea I can set it back to

roInfo.ActualWeight = roInfo.SetWeight

I went back and for on that and n/a the reason I went with n/a was because I thought it was a bit strange from an end users perspective to have a slightly incorrect value and not knowing its incorrect vs 'n/a' however if you feel it should be n/a I will set it to that.

As for testing I did spend a little time looking into it but found that there was zero tests for rollout_info.go and it seemed a bit odd to test it at the api level when it should really be tested at say the UI side. I did not look if there was UI tests framework so I will spend some time looking into seeing if there is UI testing framework in place that I can use.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@harikrongali tests have been added

@zachaller zachaller marked this pull request as draft March 31, 2022 14:21
Signed-off-by: zachaller <[email protected]>
@zachaller zachaller marked this pull request as ready for review March 31, 2022 16:20
@@ -65,7 +65,11 @@ func NewRolloutInfo(
}
}
} else {
roInfo.ActualWeight = roInfo.SetWeight
if ro.Status.Canary.Weights != nil {
roInfo.ActualWeight = fmt.Sprintf("%d", ro.Status.Canary.Weights.Canary.Weight)
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks good..what happens for bluegreen ? is there a different object with weight?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This if statement can not be hit for blue green and blue green dose not have the ability to have a weight set as well. It dose not exist in the status object.

assert.Equal(t, rolloutObjs.Rollouts[4].Status.Canary.Weights.Canary.Weight, int32(actualWeightStringInt32))

//This test has a no canary weight object in the status field so we fall back to using SetWeight value
roInfo = NewRolloutInfo(rolloutObjs.Rollouts[5], rolloutObjs.ReplicaSets, rolloutObjs.Pods, rolloutObjs.Experiments, rolloutObjs.AnalysisRuns, nil)
Copy link
Contributor

@leoluz leoluz Mar 31, 2022

Choose a reason for hiding this comment

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

More as a suggestion but there is a more interesting pattern to use in tests when you want to validate 2 different scenarios like what you are doing. Instead of mixing the 2 scenarios in one single test case we can leverage testing.Run to run nested executions making more evident what exactly your are testing. See this example.

Advantages are:

  • Easier to understand what the test is doing
  • Test description in plain english
  • Better report when test fail
  • Running tests in parallel

Signed-off-by: zachaller <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Mar 31, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@alexmt alexmt merged commit 40c22b3 into argoproj:master Apr 1, 2022
@zachaller zachaller deleted the fix-1812 branch April 1, 2022 17:44
RaviHari pushed a commit to RaviHari/argo-rollouts that referenced this pull request Apr 5, 2022
…1937)

fix: Use actual weight from status field on rollout object (argoproj#1937)


Signed-off-by: zachaller <[email protected]>
RaviHari pushed a commit to RaviHari/argo-rollouts that referenced this pull request Apr 5, 2022
…1937)

fix: Use actual weight from status field on rollout object (argoproj#1937)

Signed-off-by: zachaller <[email protected]>
Signed-off-by: Ravi Hari <[email protected]>
jessesuen pushed a commit that referenced this pull request May 13, 2022
fix: Use actual weight from status field on rollout object (#1937)


Signed-off-by: zachaller <[email protected]>
@Rakhmanov
Copy link

Why is it better to look at the status?

Wouldn't it be potentially different (delayed) from desired replica count set in the spec? In cases when you come from the surge of traffic it would be higher when desired (in spec) is lower and after quick scaleup is in order. Status would lag behind? In this scenarios Canary might create not excessive or insufficient number of pods?

tperdue321 added a commit to rallyhealth/argo-rollouts that referenced this pull request Aug 30, 2022
* fix: Add pagination to FindLoadBalancerByDNSName (argoproj#1971)

* fix: this close issue argoproj#1963 by adding pagination to FindLoadBalancerByDNSName

This adds pagination to the FindLoadBalancerByDNSName function this
should allow argo rollouts to work with any number of loadbalancers.

Signed-off-by: zachaller <[email protected]>

* fix: missing lb event (argoproj#2021)

* fix: turn missing load balancer log into an event

Signed-off-by: zachaller <[email protected]>

* consistent naming

Signed-off-by: zachaller <[email protected]>

* fix: Use actual weight from status field on rollout object (argoproj#1937)

fix: Use actual weight from status field on rollout object (argoproj#1937)


Signed-off-by: zachaller <[email protected]>

* fix: build/lint is broken due to dependencies changes (argoproj#1958)

Signed-off-by: zachaller <[email protected]>

* following github workflow error prompt to fix

Signed-off-by: Travis Perdue <[email protected]>

* go fmt

Signed-off-by: Travis Perdue <[email protected]>

* make go-mod-vendor

Signed-off-by: Travis Perdue <[email protected]>

* fix path

Signed-off-by: Travis Perdue <[email protected]>

Signed-off-by: zachaller <[email protected]>
Signed-off-by: Travis Perdue <[email protected]>
Co-authored-by: Zach Aller <[email protected]>
Co-authored-by: Travis Perdue <[email protected]>
jenciso pushed a commit to jenciso/argo-rollouts that referenced this pull request Oct 25, 2022
…1937)

fix: Use actual weight from status field on rollout object (argoproj#1937)

Signed-off-by: zachaller <[email protected]>
Signed-off-by: Juan Enciso <[email protected]>
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.

Reported weight doesn't match actual Rollout/Traffic Split weight
5 participants