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

Add support for UI configuration #115

Merged
merged 3 commits into from
Nov 21, 2018
Merged

Add support for UI configuration #115

merged 3 commits into from
Nov 21, 2018

Conversation

objectiser
Copy link
Contributor

No description provided.

@jpkrohling
Copy link
Contributor

This change is Reviewable

@codecov
Copy link

codecov bot commented Nov 16, 2018

Codecov Report

Merging #115 into master will decrease coverage by 0.15%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
- Coverage   92.28%   92.12%   -0.16%     
==========================================
  Files          25       27       +2     
  Lines        1063     1143      +80     
==========================================
+ Hits          981     1053      +72     
- Misses         82       86       +4     
- Partials        0        4       +4
Impacted Files Coverage Δ
pkg/apis/io/v1alpha1/jaeger_types.go 100% <ø> (ø) ⬆️
pkg/deployment/query.go 100% <100%> (ø) ⬆️
pkg/deployment/all-in-one.go 100% <100%> (ø) ⬆️
pkg/controller/jaeger/production.go 94.44% <33.33%> (-5.56%) ⬇️
pkg/controller/jaeger/all-in-one.go 93.54% <33.33%> (-6.46%) ⬇️
pkg/apis/io/v1alpha1/freeform.go 85.71% <85.71%> (ø)
pkg/configmap/ui.go 96.42% <96.42%> (ø)

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 4d9b695...b5b9742. Read the comment docs.

@jpkrohling
Copy link
Contributor

I'll wait a couple of days to review/merge this one, as I'm currently working on #66, which will have a lot of changes, potentially conflicting with the ones from this PR.

@objectiser
Copy link
Contributor Author

No problem - thanks.

@jpkrohling
Copy link
Contributor

jpkrohling commented Nov 20, 2018

The migration to the new operator SDK is now complete. Please, rebase and update this PR.

Looks like you just did.

@objectiser
Copy link
Contributor Author

@jpkrohling Although running the e2e tests, looks like the UI test has failed - so need to investigate, not sure whether something has changed with the UI config format :(

@objectiser
Copy link
Contributor Author

@jpkrohling When running just the new allInOneWithUIConfigTest test, I found it was using jaegertracing/jaeger-operator:1.8.0. I updated the operator.yaml to use the image built/pushed during the make test, and it worked fine - so looks like the e2e tests needs to be updated to use the built image.

However when I uncommented all of the other tests, still using the locally built image, it started failing on that new UI test again.

It appears that if allInOneTest is uncommented, the problem occurs (i.e. allInOneTest and allInOneWithUIConfigTest running together). However allInOneWithUIBasePathTest and allInOneWithUIConfigTest seem to run fine together without allInOneTest.

I can't see any reason why the tests would interfere with each other - could you try running the same locally to see if you see the same results?

@objectiser
Copy link
Contributor Author

@jpkrohling I found a workaround - just combining the two UI (base path and config) tests - so if you can't spot anything obvious I will commit this change.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewed 12 of 12 files at r1.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @objectiser)


deploy/examples/all-in-one-with-options.yaml, line 16 at r1 (raw file):

    options:
      dependencies:
        menuEnabled: false

Could it be named enabled instead? I know it's not technically correct, as it's just hiding the menu option, but I think consistency is a bit better than technical correctness in this case.


pkg/apis/io/v1alpha1/freeform.go, line 7 at r1 (raw file):

)

// FreeForm defines a common options parameter to the different structs

I now understand why we have an Options object and a FreeForm, but I wonder if we could have one generic construct that would work for both cases. If not, it would probably be good to have a few words as documentation explaining why we need both.


pkg/apis/io/v1alpha1/freeform.go, line 9 at r1 (raw file):

// FreeForm defines a common options parameter to the different structs
type FreeForm struct {
	json []byte

As your marshaling of the map doesn't have a custom logic, you could probably just have a type FreeForm map[string]interface{}.


pkg/configmap/ui.go, line 6 at r1 (raw file):

	"fmt"

	"github.com/sirupsen/logrus"

Note to self: we have usage like this in some places, and we are aliasing it to log in others. We should do go over the code and be consistent. It looks like the best practice is to alias to log.


pkg/configmap/ui.go, line 30 at r1 (raw file):

	}

	json, err := u.jaeger.Spec.UI.Options.MarshalJSON()

MarshalJSON is part of the interface that the json library uses. The usual way to get a JSON from an object is via json.Marshal(u.jaeger.Spec.UI.Options).

https://blog.golang.org/json-and-go


pkg/controller/jaeger/all-in-one.go, line 68 at r1 (raw file):

	}

	// add the config map

Shouldn't this be created before the Query deployment? Probably doesn't matter much, as it will probably be ready before the Query can consume it.


pkg/controller/jaeger/production.go, line 74 at r1 (raw file):

	}

	// add the config map

Same here: I would move it to before the // add the deployments section


test/e2e/all_in_one_test.go, line 234 at r1 (raw file):

		}

		if !strings.Contains(string(body), TrackingID) {

Nice trick to check the content 👍

@jpkrohling
Copy link
Contributor

By the way: the e2e tests are failing to me. Besides the DaemonSet one, the following are failing:

        --- FAIL: TestJaeger/jaeger-group/my-jaeger (100.76s)
            all_in_one_test.go:36: body does not include tracking id: MyTrackingId
        --- FAIL: TestJaeger/jaeger-group/my-other-jaeger (100.81s)
            all_in_one_test.go:36: body does not include tracking id: MyTrackingId

Copy link
Contributor Author

@objectiser objectiser 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: all files reviewed, 7 unresolved discussions (waiting on @jpkrohling and @objectiser)


deploy/examples/all-in-one-with-options.yaml, line 16 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

Could it be named enabled instead? I know it's not technically correct, as it's just hiding the menu option, but I think consistency is a bit better than technical correctness in this case.

All of the content under the "options:" node is the Jaeger UI configuration format: https://www.jaegertracing.io/docs/1.8/deployment/#UIConfiguration


pkg/configmap/ui.go, line 30 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

MarshalJSON is part of the interface that the json library uses. The usual way to get a JSON from an object is via json.Marshal(u.jaeger.Spec.UI.Options).

https://blog.golang.org/json-and-go

Will do


pkg/controller/jaeger/all-in-one.go, line 68 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

Shouldn't this be created before the Query deployment? Probably doesn't matter much, as it will probably be ready before the Query can consume it.

Yes I think it would be ready - but if it did turn out to be a problem in the future, what would be the approach to use, to ensure thinks are set up in a particular order? Would it need to be defined in the Dependencies list?


pkg/controller/jaeger/production.go, line 74 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

Same here: I would move it to before the // add the deployments section

Sure, will change the order - although I assume it will be deployed at the same time as all of the other objects.

Copy link
Contributor

@jpkrohling jpkrohling 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: 11 of 12 files reviewed, 6 unresolved discussions (waiting on @jpkrohling and @objectiser)


deploy/examples/all-in-one-with-options.yaml, line 16 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

All of the content under the "options:" node is the Jaeger UI configuration format: https://www.jaegertracing.io/docs/1.8/deployment/#UIConfiguration

My bad, sorry!


pkg/controller/jaeger/all-in-one.go, line 68 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

Yes I think it would be ready - but if it did turn out to be a problem in the future, what would be the approach to use, to ensure thinks are set up in a particular order? Would it need to be defined in the Dependencies list?

Yes, using the dependencies would be appropriate if we are not sure the resource will be ready by the time it's consumed. A Route or ConfigMap is usually ready right away, even if it's not an atomic operation.

Copy link
Contributor Author

@objectiser objectiser 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: 11 of 12 files reviewed, 6 unresolved discussions (waiting on @jpkrohling and @objectiser)


pkg/apis/io/v1alpha1/freeform.go, line 9 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

As your marshaling of the map doesn't have a custom logic, you could probably just have a type FreeForm map[string]interface{}.

Unfortunately does not work, due to generated code not liking interface{}: pkg/apis/io/v1alpha1/zz_generated.deepcopy.go:37:22: val.DeepCopyinterface undefined (type interface {} is interface with no methods)


pkg/configmap/ui.go, line 30 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

Will do

Remember why it had to be done this way now - the type (FreeForm in this case) can't have a field with type interface{} as it causes a problem with the generated code. Hence using the wrapper to convert to byte[] straightaway and then return it via the MarshallJSON method.


pkg/controller/jaeger/all-in-one.go, line 68 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

Yes, using the dependencies would be appropriate if we are not sure the resource will be ready by the time it's consumed. A Route or ConfigMap is usually ready right away, even if it's not an atomic operation.

Done.


pkg/controller/jaeger/production.go, line 74 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

Sure, will change the order - although I assume it will be deployed at the same time as all of the other objects.

Done.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @objectiser)


pkg/apis/io/v1alpha1/freeform.go, line 9 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

Unfortunately does not work, due to generated code not liking interface{}: pkg/apis/io/v1alpha1/zz_generated.deepcopy.go:37:22: val.DeepCopyinterface undefined (type interface {} is interface with no methods)

True, I think I bumped into that one as well with Options.


pkg/configmap/ui.go, line 30 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

Remember why it had to be done this way now - the type (FreeForm in this case) can't have a field with type interface{} as it causes a problem with the generated code. Hence using the wrapper to convert to byte[] straightaway and then return it via the MarshallJSON method.

Does it mean that json.Marshal(freeForm) won't work? If so, could you check the output of kubectl get jaeger my-jaeger -o yaml for a my-jaeger that specifies a UI config? That YAML output is generated by Kubernetes calling json.Marshal(obj) at the top-level Jaeger object, which ends up doing the same for the FreeForm.


test/e2e/all_in_one_test.go, line 113 at r1 (raw file):

	}

	err = WaitForIngress(t, f.KubeClient, namespace, "all-in-one-with-base-path-query", retryInterval, timeout)

This might have been the problem before: IIRC, I did have problems with ingresses not getting updated between tests.

Copy link
Contributor Author

@objectiser objectiser 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: all files reviewed, 3 unresolved discussions (waiting on @objectiser)


pkg/configmap/ui.go, line 30 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

Does it mean that json.Marshal(freeForm) won't work? If so, could you check the output of kubectl get jaeger my-jaeger -o yaml for a my-jaeger that specifies a UI config? That YAML output is generated by Kubernetes calling json.Marshal(obj) at the top-level Jaeger object, which ends up doing the same for the FreeForm.

Just tried doing the update you suggested, but has the following test failure:

--- FAIL: TestWithUIConfig (0.00s)
	ui_test.go:41: 
			Error Trace:	ui_test.go:41
			Error:      	Not equal: 
			            	expected: "{\"tracking\":{\"gaID\":\"UA-000000-2\"}}"
			            	actual  : "{}"
			            	
			            	Diff:
			            	--- Expected
			            	+++ Actual
			            	@@ -1 +1 @@
			            	-{"tracking":{"gaID":"UA-000000-2"}}
			            	+{}
			Test:       	TestWithUIConfig

The output from the kubectl get jaeger my-jaeger -o yaml command, using the current approach is:

apiVersion: io.jaegertracing/v1alpha1
kind: Jaeger
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"io.jaegertracing/v1alpha1","kind":"Jaeger","metadata":{"annotations":{},"name":"my-jaeger","namespace":"default"},"spec":{"allInOne":{"image":"jaegertracing/all-in-one:1.8","options":{"log-level":"debug","query":{"base-path":"/jaeger"}}},"storage":{"options":{"memory":{"max-traces":100000}}},"strategy":"allInOne","ui":{"options":{"dependencies":{"menuEnabled":false},"menu":[{"items":[{"label":"Documentation","url":"https://www.jaegertracing.io/docs/latest"}],"label":"About Jaeger"}],"tracking":{"gaID":"UA-000000-2"}}}}}
  clusterName: ""
  creationTimestamp: 2018-11-21T12:13:47Z
  generation: 1
  name: my-jaeger
  namespace: default
  resourceVersion: "610"
  selfLink: /apis/io.jaegertracing/v1alpha1/namespaces/default/jaegers/my-jaeger
  uid: e645eb1a-ed86-11e8-a975-70277121420b
spec:
  agent:
    image: jaegertracing/jaeger-agent:1.8
    options: {}
    resources: {}
    strategy: ""
    volumeMounts: null
    volumes: null
  allInOne:
    image: jaegertracing/all-in-one:1.8
    options:
      log-level: debug
      query.base-path: /jaeger
    resources: {}
    volumeMounts: null
    volumes: null
  collector:
    image: ""
    options: {}
    resources: {}
    size: 0
    volumeMounts: null
    volumes: null
  ingress:
    enabled: null
    resources: {}
    security: ""
    volumeMounts: null
    volumes: null
  query:
    image: ""
    options: {}
    resources: {}
    size: 0
    volumeMounts: null
    volumes: null
  resources: {}
  storage:
    cassandraCreateSchema:
      datacenter: ""
      enabled: null
      image: ""
      mode: ""
    options:
      memory.max-traces: "100000"
    type: memory
  strategy: allInOne
  ui:
    options:
      dependencies:
        menuEnabled: false
      menu:
      - items:
        - label: Documentation
          url: https://www.jaegertracing.io/docs/latest
        label: About Jaeger
      tracking:
        gaID: UA-000000-2
  volumeMounts: null
  volumes: null
status: {}

So looks like it is fine.

Copy link
Contributor

@jpkrohling jpkrohling 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: all files reviewed, 3 unresolved discussions (waiting on @objectiser)


pkg/configmap/ui.go, line 30 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

Just tried doing the update you suggested, but has the following test failure:

--- FAIL: TestWithUIConfig (0.00s)
	ui_test.go:41: 
			Error Trace:	ui_test.go:41
			Error:      	Not equal: 
			            	expected: "{\"tracking\":{\"gaID\":\"UA-000000-2\"}}"
			            	actual  : "{}"
			            	
			            	Diff:
			            	--- Expected
			            	+++ Actual
			            	@@ -1 +1 @@
			            	-{"tracking":{"gaID":"UA-000000-2"}}
			            	+{}
			Test:       	TestWithUIConfig

The output from the kubectl get jaeger my-jaeger -o yaml command, using the current approach is:

apiVersion: io.jaegertracing/v1alpha1
kind: Jaeger
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"io.jaegertracing/v1alpha1","kind":"Jaeger","metadata":{"annotations":{},"name":"my-jaeger","namespace":"default"},"spec":{"allInOne":{"image":"jaegertracing/all-in-one:1.8","options":{"log-level":"debug","query":{"base-path":"/jaeger"}}},"storage":{"options":{"memory":{"max-traces":100000}}},"strategy":"allInOne","ui":{"options":{"dependencies":{"menuEnabled":false},"menu":[{"items":[{"label":"Documentation","url":"https://www.jaegertracing.io/docs/latest"}],"label":"About Jaeger"}],"tracking":{"gaID":"UA-000000-2"}}}}}
  clusterName: ""
  creationTimestamp: 2018-11-21T12:13:47Z
  generation: 1
  name: my-jaeger
  namespace: default
  resourceVersion: "610"
  selfLink: /apis/io.jaegertracing/v1alpha1/namespaces/default/jaegers/my-jaeger
  uid: e645eb1a-ed86-11e8-a975-70277121420b
spec:
  agent:
    image: jaegertracing/jaeger-agent:1.8
    options: {}
    resources: {}
    strategy: ""
    volumeMounts: null
    volumes: null
  allInOne:
    image: jaegertracing/all-in-one:1.8
    options:
      log-level: debug
      query.base-path: /jaeger
    resources: {}
    volumeMounts: null
    volumes: null
  collector:
    image: ""
    options: {}
    resources: {}
    size: 0
    volumeMounts: null
    volumes: null
  ingress:
    enabled: null
    resources: {}
    security: ""
    volumeMounts: null
    volumes: null
  query:
    image: ""
    options: {}
    resources: {}
    size: 0
    volumeMounts: null
    volumes: null
  resources: {}
  storage:
    cassandraCreateSchema:
      datacenter: ""
      enabled: null
      image: ""
      mode: ""
    options:
      memory.max-traces: "100000"
    type: memory
  strategy: allInOne
  ui:
    options:
      dependencies:
        menuEnabled: false
      menu:
      - items:
        - label: Documentation
          url: https://www.jaegertracing.io/docs/latest
        label: About Jaeger
      tracking:
        gaID: UA-000000-2
  volumeMounts: null
  volumes: null
status: {}

So looks like it is fine.

There's clearly something I'm missing, but it does look like it's working.

:lgtm:

Copy link
Contributor

@jpkrohling jpkrohling 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: all files reviewed, 1 unresolved discussion (waiting on @objectiser)

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Dismissed @objectiser from a discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@jpkrohling jpkrohling merged commit 0439534 into jaegertracing:master Nov 21, 2018
@objectiser objectiser deleted the uiconfig branch January 29, 2019 12:37
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