Skip to content

Fix overriding of prometheus scrape #624

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

Merged

Conversation

Waterdrips
Copy link
Contributor

@Waterdrips Waterdrips commented Apr 24, 2020

Description

The prometheus.io.scrape annotation was being overridden in faas-netes
if it was set. This means a user could never set it to true for a
functtion using something like faas-cli store deploy figlet --annotation
prometheus.io.scrape=true

Signed-off-by: Alistair Hey [email protected]

Motivation and Context

How Has This Been Tested?

This was tested by writing unit tests to validate that the operator did
not do the same thing and writing a new test for faas-netes's deployment
handler to check that if its set, its not overridden.

Then tested on k3d, using:

  1. k3d create
    2)arkade install openfaas
  2. set the faas-netes container to the one created from this commit
  3. faas-cli store deploy figlet --annotation prometheus.io.scrape=true
  4. validate that the annotation was not overridden (kubectl get deploy
    -n openfaas-fn figlet -o yaml)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

The prometheus.io.scrape annotation was being overridden in faas-netes
if it was set. This means a user could never set it to true for a
functtion using something like faas-cli store deploy figlet --annotation
prometheus.io.scrape=true

This was tested by writing unit tests to validate that the operator did
not do the same thing and writing a new test for faas-netes's deployment
handler to check that if its set, its not overridden.

Then tested on k3d, using:
1) k3d create
2)arkade install openfaas
3) set the faas-netes container to the one created from this commit
4) faas-cli store deploy figlet --annotation prometheus.io.scrape=true
5) validate that the annotation was not overridden (kubectl get deploy
-n openfaas-fn figlet -o yaml)

Signed-off-by: Alistair Hey <[email protected]>
@Waterdrips Waterdrips force-pushed the waterdrips-prom-scrape-override branch from 5f65bfd to b733782 Compare April 24, 2020 12:51
@Waterdrips
Copy link
Contributor Author

if merged this would need:

  • new faas-netes container build
  • chart faas-netes version bump and chart release

Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

That was quick! Here's a quick Q

annotations := buildAnnotations(request)

if len(annotations) != 1 {
t.Errorf("want: %d annotations got: %d", 1, len(annotations))
Copy link
Member

Choose a reason for hiding this comment

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

You could probably add a return there, or use t.Fatalf that @LucasRoesler introduced me to, which returns out of the test.

Also extract "true" to want := "true" please.

I'll merge, but send in the alteration after.

Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

Approved with a comment.

@alexellis alexellis merged commit 608968f into openfaas:master Apr 24, 2020
@Waterdrips Waterdrips deleted the waterdrips-prom-scrape-override branch April 24, 2020 15:07
Waterdrips pushed a commit to Waterdrips/faas-netes that referenced this pull request Apr 24, 2020
@Waterdrips Waterdrips mentioned this pull request Apr 24, 2020
11 tasks
alexellis pushed a commit that referenced this pull request Apr 24, 2020
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.

Allow Prometheus scraping annotation to be specified
3 participants