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

feat: add annotation to select container for version extraction #2471

Merged
merged 5 commits into from
Nov 15, 2023

Conversation

norman-zon
Copy link
Contributor

@norman-zon norman-zon commented Nov 10, 2023

Description

If a pod contains multiple containers the user can select which container the version should be extracted from by setting the keptn.sh/container annotation. If the annotation is set, but no container matches its name we assume something is wrong an throw an error.

Part-of #2464

How to test

The tests Test_calculateVersion were expanded to cover the added functionality

Checklist

  • My PR fulfills the Definition of Done of the corresponding issue and not more (or parts if the issue is separated
    into multiple PRs)
  • I used descriptive commit messages to help reviewers understand my thought process
  • I signed off all my commits according to the Developer Certificate of Origin (DCO)
    see Contribution Guide
  • My PR title is formatted according to the semantic PR conventions described in
    the Contribution Guide
  • My code follows the style guidelines of this project (golangci-lint passes, YAMLLint passes)
  • I regenerated the auto-generated docs for Helm and the CRD documentation (if applicable)
  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation (if needed)
  • My changes result in all-green PR checks (first-time contributors need to ask a maintainer to approve their test runs)
  • New and existing unit and integration tests pass locally with my changes

Copy link

netlify bot commented Nov 10, 2023

Deploy Preview for keptn-lifecycle-toolkit ready!

Name Link
🔨 Latest commit 239d451
🔍 Latest deploy log https://app.netlify.com/sites/keptn-lifecycle-toolkit/deploys/654dee8ec57c47000950266e
😎 Deploy Preview https://deploy-preview-2471--keptn-lifecycle-toolkit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

If a pod contains multiple containers the user can select which
container the version should be extracted from by setting the
keptn.sh/container annotation. If the annotation is set, but no
container matches its name we assume something is wrong an throw an
error.

Signed-off-by: Norman <[email protected]>
@norman-zon
Copy link
Contributor Author

Any advice on how to avoid the duplication and share the calculateVersion function between she scheduler and the lifecycle-operator is very welcome

@odubajDT
Copy link
Contributor

Any advice on how to avoid the duplication and share the calculateVersion function between she scheduler and the lifecycle-operator is very welcome

Hello, thank you for your contribution! Unfortunatelly, that's not possible, for now please duplicate it

Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #2471 (f72ca17) into main (8341dbf) will decrease coverage by 0.13%.
Report is 24 commits behind head on main.
The diff coverage is 85.07%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2471      +/-   ##
==========================================
- Coverage   85.77%   85.64%   -0.13%     
==========================================
  Files         161      170       +9     
  Lines       10202    10528     +326     
==========================================
+ Hits         8751     9017     +266     
- Misses       1181     1231      +50     
- Partials      270      280      +10     
Files Coverage Δ
...-operator/apis/lifecycle/v1alpha3/common/common.go 100.00% <ø> (ø)
...erator/webhooks/pod_mutator/handlers/objectmeta.go 100.00% <100.00%> (ø)
scheduler/pkg/klcpermit/workflow_manager.go 68.27% <90.32%> (+3.23%) ⬆️
...or/webhooks/pod_mutator/handlers/pod_annotation.go 76.69% <50.00%> (-4.83%) ⬇️

... and 16 files with indirect coverage changes

Flag Coverage Δ
certificate-operator 67.43% <ø> (ø)
component-tests 56.24% <ø> (-0.54%) ⬇️
lifecycle-operator 84.43% <80.55%> (-1.01%) ⬇️
metrics-operator 87.75% <ø> (+0.16%) ⬆️
scheduler 36.53% <90.32%> (+4.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

factor out the actual tag extraction logic form calculateVersion to
reduce duplication

Signed-off-by: Norman <[email protected]>
@odubajDT
Copy link
Contributor

@norman-zon thank you for your contribution! Would it be possible to introduce a full e2e test for this new feature? You can find lot's of examples already here. We are using kuttl for executing them. You can find more info in the official documentation

@mowies
Copy link
Member

mowies commented Nov 13, 2023

I created a follow up ticket for the documentation updates: #2484

Signed-off-by: Norman <[email protected]>
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

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
54.4% 54.4% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@norman-zon
Copy link
Contributor Author

@norman-zon thank you for your contribution! Would it be possible to introduce a full e2e test for this new feature? You can find lot's of examples already here. We are using kuttl for executing them. You can find more info in the official documentation

Sorry, @odubajDT I don't have the capacities right now to get into e2e testing. Could someone else please take upon this task?

@odubajDT
Copy link
Contributor

@norman-zon thank you for your contribution! Would it be possible to introduce a full e2e test for this new feature? You can find lot's of examples already here. We are using kuttl for executing them. You can find more info in the official documentation

Sorry, @odubajDT I don't have the capacities right now to get into e2e testing. Could someone else please take upon this task?

Sure, I can follow-up on that and create the e2e tests. Do you have the capacity to add the 2 requested use-cases in the unit tests ?

@norman-zon
Copy link
Contributor Author

Thanks for taking over, @odubajDT.
I pushed the added unit tests this morning 👍

@odubajDT
Copy link
Contributor

Thanks for taking over, @odubajDT. I pushed the added unit tests this morning 👍

Thank you!

@norman-zon
Copy link
Contributor Author

@odubajDT should I squash into a single commit for more clarity?

@odubajDT
Copy link
Contributor

odubajDT commented Nov 15, 2023

@odubajDT should I squash into a single commit for more clarity?

@norman-zon no need, the commits will be automatically squashed during merging, but thank you!

Copy link
Member

@thisthat thisthat left a comment

Choose a reason for hiding this comment

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

Thanks @norman-zon for your contribution! LGTM ✅
I left only a minor note that we might need to reconsider in the future, but nothing for this PR :)

@odubajDT odubajDT merged commit d093860 into keptn:main Nov 15, 2023
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants