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

Normalize options on the stub and update the normalized CR #54

Merged

Conversation

jpkrohling
Copy link
Contributor

@jpkrohling jpkrohling commented Oct 9, 2018

This PR moves some of the normalization logic to the stub from the controller. Once the CR is normalized, it's stored back. The side effect is that the controller will only get valid CRs, so that messages related to the normalization will happen only once.

Before this PR:

INFO[0005] Storage type wasn't provided for the Jaeger instance 'simplest'. Falling back to 'memory' 
INFO[0005] Created 'simplest'                           
INFO[0005] Created 'simplest'                           
INFO[0005] Created 'simplest'                           
INFO[0005] Created 'simplest'                           
INFO[0005] Created 'simplest'                           
INFO[0005] Created 'simplest'                           
INFO[0005] Storage type wasn't provided for the Jaeger instance 'simplest'. Falling back to 'memory' 
INFO[0010] Storage type wasn't provided for the Jaeger instance 'simplest'. Falling back to 'memory' 
INFO[0015] Storage type wasn't provided for the Jaeger instance 'simplest'. Falling back to 'memory' 

After this PR:

INFO[0009] Storage type wasn't provided for the Jaeger instance 'simplest'. Falling back to 'memory' 
INFO[0009] Configured simplest                          
^CINFO[0211] Jaeger Operator finished                     

Closes #53
Signed-off-by: Juraci Paixão Kröhling [email protected]

@jpkrohling jpkrohling requested a review from pavolloffay October 9, 2018 14:01
@jpkrohling
Copy link
Contributor Author

This change is Reviewable

@jpkrohling
Copy link
Contributor Author

Would you like to review this one, @pavolloffay ?

@pavolloffay
Copy link
Member

sure going to have a look

}

// normalize the deployment strategy
if strings.ToLower(o.Spec.Strategy) != "production" {
Copy link
Member

Choose a reason for hiding this comment

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

does this operator support deploying all-in-one with real storage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes


// check for incompatible options
// if the storage is `memory`, then the only possible strategy is `all-in-one`
if strings.ToLower(o.Spec.Storage.Type) == "memory" && o.Spec.Strategy != "all-in-one" {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there be ToLower on strategy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@@ -59,3 +104,20 @@ func (h *Handler) Handle(ctx context.Context, event sdk.Event) error {
}
return nil
}

func unknownStorage(typ string) bool {
known := []string{
Copy link
Member

Choose a reason for hiding this comment

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

map/set seems more suitable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Map or set? Do you mean, to ensure the list does not contain duplicate entries? As this is a very small static array, I don't see much value in having a map here instead of an array, but perhaps I'm missing something.

o.Spec.Storage.Type = "memory"
}

if unknownStorage(o.Spec.Storage.Type) {
Copy link
Member

Choose a reason for hiding this comment

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

The previous if could be merged into this.

"The provided storage type for the Jaeger instance '%v' is ('%v') Should be one of.... Falling back to 'memory'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could, but the way it is, it provides a more specific log message to the user.

Copy link
Member

Choose a reason for hiding this comment

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

What I liked from my proposal is to write all valid options in the log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This?

time="2018-10-10T13:09:15+02:00" level=info msg="The provided storage type for the Jaeger instance 'TestNewControllerForProduction' is unknown ('unknown'). Falling back to 'memory'. Known options: [memory kafka elasticsearch cassandra]"

@pavolloffay
Copy link
Member

It's my first review in this repo. I have looked at it from the language side not feature side

@jpkrohling jpkrohling force-pushed the 53-Avoid-duplicate-messages branch from e418edb to 56028e5 Compare October 10, 2018 09:44
@codecov
Copy link

codecov bot commented Oct 10, 2018

Codecov Report

Merging #54 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #54   +/-   ##
=======================================
  Coverage   99.17%   99.17%           
=======================================
  Files          16       16           
  Lines         603      603           
=======================================
  Hits          598      598           
  Misses          5        5
Impacted Files Coverage Δ
pkg/controller/controller.go 100% <100%> (ø) ⬆️

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 ade28ed...c3dd985. Read the comment docs.

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 5 unresolved discussions (waiting on @pavolloffay and @jpkrohling)


pkg/controller/controller_test.go, line 87 at r3 (raw file):

}

func TestIncompatibleStorageForProduction(t *testing.T) {

nice test!

@jpkrohling jpkrohling merged commit d68e5de into jaegertracing:master Oct 10, 2018
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.

2 participants