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: Modify validation to check Analysis args passed through RO spec #1215

Merged
merged 15 commits into from
May 25, 2021

Conversation

khhirani
Copy link
Contributor

Resolves #1208

Signed-off-by: khhirani [email protected]

@khhirani khhirani requested a review from jessesuen May 22, 2021 06:01
@codecov
Copy link

codecov bot commented May 22, 2021

Codecov Report

Merging #1215 (5a2cc9b) into master (9a028d1) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1215      +/-   ##
==========================================
+ Coverage   81.09%   81.14%   +0.05%     
==========================================
  Files         106      106              
  Lines        9519     9531      +12     
==========================================
+ Hits         7719     7734      +15     
+ Misses       1269     1267       -2     
+ Partials      531      530       -1     
Impacted Files Coverage Δ
.../apis/rollouts/validation/validation_references.go 79.33% <100.00%> (+3.27%) ⬆️
rollout/controller.go 76.10% <100.00%> (+0.25%) ⬆️

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 9a028d1...5a2cc9b. Read the comment docs.

@huikang
Copy link
Member

huikang commented May 22, 2021

Thanks for fixing.
Can we add some unit test or e2e test to avoid regression?

allErrs = append(allErrs, field.Invalid(fldPath, value, err.Error()))
return allErrs
}
err = analysisutil.ResolveArgs(flattenedTemplate.Spec.Args)
Copy link
Member

Choose a reason for hiding this comment

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

it seems this method can be removed as this is the only place to use it.

Copy link
Member

@jessesuen jessesuen left a comment

Choose a reason for hiding this comment

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

Tests?

@khhirani
Copy link
Contributor Author

@jessesuen I modified the existing tests to cover the change

@sonarcloud
Copy link

sonarcloud bot commented May 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

@@ -636,6 +636,7 @@ func (c *rolloutContext) getReferencedRolloutAnalyses() (*[]validation.AnalysisT
if err != nil {
return nil, err
}
templates.Args = blueGreen.PrePromotionAnalysis.Args
Copy link
Member

@jessesuen jessesuen May 24, 2021

Choose a reason for hiding this comment

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

  1. Are you modifying the AnalysisTemplate which was pulled off the informer store (lister)? Objects received form the store should not be modified. See:

https://github.com/kubernetes/sample-controller/blob/b8d9e8c247129e53962d0dcfc08a4e8b47477318/controller.go#L322-L324

  1. It seems we are clobbering the entire arguments of the template with the Arguments of the Rollout. Does this change support default values (i.e. some arguments values are in the AnalysisTemplate, but others are supplied by the rollout).

Copy link
Contributor Author

@khhirani khhirani May 24, 2021

Choose a reason for hiding this comment

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

It seems we are clobbering the entire arguments of the template with the Arguments of the Rollout.

Can you elaborate on this? I thought we did this anyway when we created the AnalysisRun from the templates (i.e. combine the templates’ args with the AnalysisRunArguments passed through the RO spec) in the function NewAnalysisRunFromTemplates

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you modifying the AnalysisTemplate which was pulled off the informer store (lister)?

I don't believe so. I'm copying the AnalysisRunArguments from the Rollout Spec into a AnalysisTemplatesWithType object, which is a struct I created for validation. I pass the templates and the args from the RO spec into NewAnalysisRunFromTemplates for validation, which doesn't seem to modify the templates.

Copy link
Member

@jessesuen jessesuen May 25, 2021

Choose a reason for hiding this comment

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

Can you elaborate on this?

Can you confirm that this is the behavior?

kind: AnalysisTemplate
...
args:
- name: aaa
  value: foo     # default value
- name: bbb  # mandatory supplied value
- name: ccc
  value: baz

Args supplied by rollout (note that aaa is omitted)

kind: Rollout
...
args:
- name: bbb
  value: "11111"
- name: ccc
  value: "2222"

The AnalysisRun should be created with

kind: AnalysisRun
args:
- name: aaa
  value: foo
- name: bbb
  value: "11111"
- name: ccc
  value: "2222"

Copy link
Member

Choose a reason for hiding this comment

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

I don't believe so. I'm copying the AnalysisRunArguments from the Rollout Spec into a AnalysisTemplatesWithType object, which is a struct I created for validation

I took a closer look. You're right. I mistakenly thought it was returning AnalysisTemplates

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jessesuen Can I merge this in then?

Copy link
Member

Choose a reason for hiding this comment

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

My first concern is not valid, but can you answer my second concern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jessesuen Yes, I confirm that the behavior in this comment is what happens.

@khhirani khhirani requested a review from jessesuen May 25, 2021 01:02
@khhirani khhirani merged commit ff65b39 into argoproj:master May 25, 2021
@khhirani khhirani deleted the fix-analysistemplate-validation branch May 25, 2021 22:02
caoyang001 pushed a commit to caoyang001/argo-rollouts that referenced this pull request Jun 4, 2021
…rgoproj#1215)

* fix: Modify validation to check Analysis args passed through RO spec

Signed-off-by: khhirani <[email protected]>
Signed-off-by: caoyang001 <[email protected]>
caoyang001 pushed a commit to caoyang001/argo-rollouts that referenced this pull request Jun 12, 2021
…rgoproj#1215)

* fix: Modify validation to check Analysis args passed through RO spec

Signed-off-by: khhirani <[email protected]>
Signed-off-by: caoyang001 <[email protected]>
caoyang001 pushed a commit to caoyang001/argo-rollouts that referenced this pull request Jun 12, 2021
…rgoproj#1215)

* fix: Modify validation to check Analysis args passed through RO spec

Signed-off-by: khhirani <[email protected]>
Signed-off-by: caoyang001 <[email protected]>
huikang pushed a commit to huikang/argo-rollouts that referenced this pull request Sep 16, 2021
…rgoproj#1215)

* fix: Modify validation to check Analysis args passed through RO spec

Signed-off-by: khhirani <[email protected]>
Signed-off-by: caoyang001 <[email protected]>
huikang pushed a commit to huikang/argo-rollouts that referenced this pull request Sep 16, 2021
…rgoproj#1215)

* fix: Modify validation to check Analysis args passed through RO spec

Signed-off-by: khhirani <[email protected]>
Signed-off-by: caoyang001 <[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.

Analysis Template argument without default value can not be resolved in the rollout yaml
3 participants