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: avoid invalid replica in workloadRef #1304

Merged
merged 1 commit into from
Jul 2, 2021

Conversation

huikang
Copy link
Member

@huikang huikang commented Jun 24, 2021

  • defaulting replica after workload ref is resolved

Signed-off-by: Hui Kang [email protected]

close #1302

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

@codecov
Copy link

codecov bot commented Jun 24, 2021

Codecov Report

Merging #1304 (1c063ea) into master (96ba030) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1304   +/-   ##
=======================================
  Coverage   81.41%   81.41%           
=======================================
  Files         106      106           
  Lines        9702     9702           
=======================================
  Hits         7899     7899           
  Misses       1266     1266           
  Partials      537      537           
Impacted Files Coverage Δ
rollout/controller.go 78.35% <100.00%> (ø)

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 96ba030...1c063ea. Read the comment docs.

@huikang huikang force-pushed the 1302-worload-ref-valid branch from 63b2fa0 to 23a621d Compare June 24, 2021 17:01
- defaulting replica after workload ref is resolved

Signed-off-by: Hui Kang <[email protected]>
@huikang huikang force-pushed the 1302-worload-ref-valid branch from 23a621d to 1c063ea Compare June 24, 2021 17:21
@sonarcloud
Copy link

sonarcloud bot commented Jun 24, 2021

Kudos, SonarCloud 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

@jessesuen
Copy link
Member

@huikang I'm having trouble understanding how moving the defaulting of spec.replicas fixes the problem and why the problem only happens if there is an analysis in the steps. Could you explain how this fixes it?

@huikang
Copy link
Member Author

huikang commented Jun 24, 2021

@huikang I'm having trouble understanding how moving the defaulting of spec.replicas fixes the problem and why the problem only happens if there is an analysis in the steps. Could you explain how this fixes it?

Sure thing. In the original implementation, if the rollout refers to a deployment and does not have replica set, it will call the update method before resolving the template. Since the template is empty, i.e., no container in the struct), update will return error.

r.Spec.Replicas = pointer.Int32Ptr(defaults.DefaultReplicas)
_, err := c.argoprojclientset.ArgoprojV1alpha1().Rollouts(r.Namespace).Update(ctx, r, metav1.UpdateOptions{})

This PR changes the order of update() and resolve() such that update can return successfully with defaulted replica.
Hope it makes sense to you.

@jessesuen
Copy link
Member

Since the template is empty, i.e., no container in the struct), update will return error.

This is what was surprising to me. I didn't think the Update() would fail in that manner. In any case I see this fixes the issue. Thanks!

@jessesuen jessesuen merged commit 335326b into argoproj:master Jul 2, 2021
jessesuen pushed a commit that referenced this pull request Jul 2, 2021
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.

Validation error when using workloadRef
2 participants