-
Notifications
You must be signed in to change notification settings - Fork 244
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 cluster type to telemetry #4763
Add cluster type to telemetry #4763
Conversation
pkg/segment/context/context_test.go
Outdated
} | ||
} | ||
|
||
func fakeClusterVersion(fakeClientset *occlient.FakeClientset) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can return a configv1.ClusterVersion
here when the user list
for clusterversion
. if you want to verify what parameters to add here, maybe add a PrependReactor
for anything called on the fake client, and then print the arguments. That way you would know which calls you need to mock.
pkg/occlient/occlient.go
Outdated
func (c *Client) IsOpenshift4() (bool, error) { | ||
return c.GetKubeClient().IsResourceSupported("config.openshift.io", "v1", "clusterversions") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it alright to place this method here?
I can move this function to segment/context/context.go if it might not be used in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should call it something related to the resource like IsClusterVersionsSupported
similar to IsProjectSupported
. Please add some comments for the function.
pkg/occlient/fakeclient.go
Outdated
client.GetKubeClient().SetDiscoveryInterface(fakeDiscoveryWithRoute) | ||
//client.GetKubeClient().SetDiscoveryInterface(fakeDiscoveryWithRoute) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been commented out because it gets overriden by the next statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the comments for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting I keep it as it is for now? I can do that, I have issue #4773 open, I can fix this when I work on that issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we should remove it for now
pkg/kclient/kclient.go
Outdated
@@ -234,6 +234,21 @@ func (c *Client) IsResourceSupported(apiGroup, apiVersion, resourceName string) | |||
return supported, nil | |||
} | |||
|
|||
func (c *Client) IsResourceGroupSupported(apiGroup string) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment for the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted this method. I am no longer using it.
pkg/segment/context/context.go
Outdated
} | ||
} | ||
|
||
func SetClusterType(ctx context.Context, client *occlient.Client) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some comments for the function
pkg/segment/context/context.go
Outdated
if isOC, _ := client.IsProjectSupported(); isOC { | ||
if isOC4, _ := client.IsOpenshift4(); isOC4 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle the errors from these two calls. We should default to kubernetes
etc only when there are no errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you suggest we do error handling for if isOC4, _ := client.IsOpenshift4(); isOC4 {
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you suggest we do error handling for if isOC4, _ := client.IsOpenshift4(); isOC4 { as well?
Yes
pkg/segment/segment.go
Outdated
@@ -205,6 +205,9 @@ func RunningInTerminal() bool { | |||
|
|||
// IsTelemetryEnabled returns true if user has consented to telemetry | |||
func IsTelemetryEnabled(cfg *preference.PreferenceInfo) bool { | |||
if cfg == nil { | |||
cfg, _ = preference.New() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle the error here
PIt("should fail", func() { | ||
helper.Chdir(commonVar.OriginalWorkingDirectory) | ||
helper.CmdShouldPass("odo", "create", "nodejs", "--project", commonVar.Project, "--context", commonVar.Context, cmpName) | ||
output := helper.CmdShouldFail("odo", "watch", "--context", commonVar.Context) | ||
Expect(output).To(ContainSubstring("component does not exist. Please use `odo push` to create your component")) | ||
}) | ||
|
||
It("should error out on devfile flag", func() { | ||
PIt("should error out on devfile flag", func() { | ||
helper.CmdShouldFail("odo", "watch", "--devfile", "invalid.yaml") | ||
}) | ||
}) | ||
|
||
Context("when executing odo watch after odo push", func() { | ||
It("should listen for file changes", func() { | ||
XIt("should listen for file changes", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we marking them as pending?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to remove them. Done.
/test psi-unit-test-windows
|
/test psi-unit-test-windows |
@valaparthvi: The
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/retest |
1 similar comment
/retest |
/override ci/prow/psi-kubernetes-integration-e2e |
@valaparthvi: Overrode contexts on behalf of valaparthvi: ci/prow/psi-kubernetes-integration-e2e In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pkg/segment/context/context.go
Outdated
value = "not-found" | ||
} else { | ||
if isOC { | ||
if isOC4, _ := client.GetKubeClient().IsCSVSupported(); isOC4 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the error here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering whether I should, because if it throws an error we still know that it is an openshift cluster. What value do you suggest we assign in case this throws an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in case of an connection error to the cluster, this might lead to false assumptions about the type of openshift cluster.
What value do you suggest we assign in case this throws an error?
I would suggest not setting the property at all or defaulting to just openshift
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to go with openshift
but then it would mean adding a unit test for it which would mean mocking the IsCSVSupported
function to return an error and all of this seems like a stretch to me.
If you still think that it's worth the effort, I'll go with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's default to openshift
when an error occurs. We can skip the unit test case for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/test v4.7-integration-e2e Error-ed out while collecting console logs.
|
/retest Failure on v4.7-integration-e2e job looks like a flake-
Same for psi-kubernetes-integration-e2e -
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dharmit The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@valaparthvi: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What type of PR is this?
/kind feature
What does this PR do / why we need it:
This PR adds information about cluster type to telemetry data. Currently it detects k8s, openshift4 and openshift3.
Which issue(s) this PR fixes:
Fixes part of #4462
PR acceptance criteria:
Unit test
Integration test
Documentation
Update changelog
I have read the test guidelines
How to test changes / Special notes to the reviewer:
Run
odo push
orodo project create
and see if the data is visible on Segment.