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 cluster type to telemetry #4763

Merged
merged 20 commits into from
Jun 30, 2021

Conversation

valaparthvi
Copy link
Contributor

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 or odo project create and see if the data is visible on Segment.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation labels Jun 1, 2021
@openshift-ci openshift-ci bot requested review from dharmit and prietyc123 June 1, 2021 08:32
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jun 1, 2021
}
}

func fakeClusterVersion(fakeClientset *occlient.FakeClientset) {
Copy link
Contributor

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.

Comment on lines 1225 to 1228
func (c *Client) IsOpenshift4() (bool, error) {
return c.GetKubeClient().IsResourceSupported("config.openshift.io", "v1", "clusterversions")
}

Copy link
Contributor Author

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.

Copy link
Contributor

@mik-dass mik-dass Jun 4, 2021

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.

@openshift-ci openshift-ci bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jun 3, 2021
@valaparthvi valaparthvi changed the title WIP: Add cluster type to telemetry Add cluster type to telemetry Jun 3, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 3, 2021
client.GetKubeClient().SetDiscoveryInterface(fakeDiscoveryWithRoute)
//client.GetKubeClient().SetDiscoveryInterface(fakeDiscoveryWithRoute)
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 has been commented out because it gets overriden by the next statement.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

@@ -234,6 +234,21 @@ func (c *Client) IsResourceSupported(apiGroup, apiVersion, resourceName string)
return supported, nil
}

func (c *Client) IsResourceGroupSupported(apiGroup string) (bool, error) {
Copy link
Contributor

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

Copy link
Contributor Author

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.

}
}

func SetClusterType(ctx context.Context, client *occlient.Client) {
Copy link
Contributor

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

Comment on lines 81 to 82
if isOC, _ := client.IsProjectSupported(); isOC {
if isOC4, _ := client.IsOpenshift4(); isOC4 {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

@@ -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()
Copy link
Contributor

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

Comment on lines 42 to 55
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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@valaparthvi
Copy link
Contributor Author

/test psi-unit-test-windows

-unit-pr-build_PR_4763/repo/.gocache
[ssh:Windows 10] ++ GOCACHE='C:\Users\Admin\amqp_ci_rcv_odo-windows-unit-pr-build_PR_4763\repo\.gocache'
[ssh:Windows 10] +++ cygpath -pw /cygdrive/c/Users/Admin/amqp_ci_rcv_odo-windows-unit-pr-build_PR_4763/repo/artifacts
[ssh:Windows 10] ++ CUSTOM_HOMEDIR='C:\Users\Admin\amqp_ci_rcv_odo-windows-unit-pr-build_PR_4763\repo\artifacts'
[ssh:Windows 10] ++ shout 'Setting PATH'
[ssh:Windows 10] ++ set +x
[ssh:Windows 10] ++ export 'PATH=/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Go/bin:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/TDM-GCC-64/bin:/cygdrive/c/Users/cyg_server/AppData/Local/Microsoft/WindowsApps:C:\Users\Admin\amqp_ci_rcv_odo-windows-unit-pr-build_PR_4763\repo\bin'
[ssh:Windows 10] ++ PATH='/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Go/bin:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/TDM-GCC-64/bin:/cygdrive/c/Users/cyg_server/AppData/Local/Microsoft/WindowsApps:C:\Users\Admin\amqp_ci_rcv_odo-windows-unit-pr-build_PR_4763\repo\bin'

[ssh:Windows 10] + . ./scripts/run_script_unit.sh
[ssh:Windows 10] ++ shout 'Running unit tests'
[ssh:Windows 10] ++ set +x
[ssh:Windows 10] ++ [[ windows == \w\i\n\d\o\w\s ]]
[ssh:Windows 10] ++ GOFLAGS=-mod=vendor
[ssh:Windows 10] ++ make test-windows
[ssh:Windows 10] make: *** [Makefile:155: test-windows] Error 1

[ssh:Windows 10] !!!run failed, skipping!!!

2021/06/04 10:49:16 : failed due to err Failed the test, see logs above ^
{"component":"entrypoint","error":"wrapped process failed: exit status 1","file":"prow/entrypoint/run.go:80","func":"k8s.io/test-infra/prow/entrypoint.Options.Run","level":"error","msg":"Error executing test process","severity":"error","time":"2021-06-04T10:49:16Z"}
error: failed to execute wrapped command: exit status 1

@valaparthvi
Copy link
Contributor Author

valaparthvi commented Jun 7, 2021

/test psi-unit-test-windows

@openshift-ci
Copy link

openshift-ci bot commented Jun 7, 2021

@valaparthvi: The /retest command does not accept any targets.
The following commands are available to trigger jobs:

  • /test psi-kubernetes-integration-e2e
  • /test psi-unit-test-mac
  • /test psi-unit-test-windows
  • /test unit
  • /test v4.5-images
  • /test v4.6-images
  • /test v4.7-images
  • /test v4.7-integration-e2e
  • /test v4.8-images

Use /test all to run the following jobs:

  • pull-ci-openshift-odo-main-psi-kubernetes-integration-e2e
  • pull-ci-openshift-odo-main-psi-unit-test-mac
  • pull-ci-openshift-odo-main-psi-unit-test-windows
  • pull-ci-openshift-odo-main-unit
  • pull-ci-openshift-odo-main-v4.7-integration-e2e

In response to this:

/retest psi-unit-test-windows

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.

@valaparthvi
Copy link
Contributor Author

/retest

1 similar comment
@valaparthvi
Copy link
Contributor Author

/retest

@valaparthvi
Copy link
Contributor Author

/override ci/prow/psi-kubernetes-integration-e2e
Reason - #4776

@openshift-ci
Copy link

openshift-ci bot commented Jun 8, 2021

@valaparthvi: Overrode contexts on behalf of valaparthvi: ci/prow/psi-kubernetes-integration-e2e

In response to this:

/override ci/prow/psi-kubernetes-integration-e2e
Reason - #4776

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.

value = "not-found"
} else {
if isOC {
if isOC4, _ := client.GetKubeClient().IsCSVSupported(); isOC4 {
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@mik-dass mik-dass left a comment

Choose a reason for hiding this comment

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

/lgtm

@valaparthvi
Copy link
Contributor Author

/test v4.7-integration-e2e

Error-ed out while collecting console logs.

Gathering console logs for i-07ec01954a84e305a

'ascii' codec can't encode character '\u2026' in position 18189: ordinal not in range(128)
{"component":"entrypoint","error":"wrapped process failed: exit status 1","file":"prow/entrypoint/run.go:80","func":"k8s.io/test-infra/prow/entrypoint.Options.Run","level":"error","msg":"Error executing test process","severity":"error","time":"2021-06-30T06:29:22Z"}
error: failed to execute wrapped command: exit status 1

@valaparthvi
Copy link
Contributor Author

/retest

Failure on v4.7-integration-e2e job looks like a flake-

 ------------------------------
• Failure [116.321 seconds]
odo devfile push command tests
/go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:18
  verify command executions
  /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:464
    when default build and run commands are defined
[Fail] odo devfile push command tests verify command executions when default build and run commands are defined [It] should execute correct commands 
/go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:514
Ran 188 of 195 Specs in 1055.057 seconds
FAIL! -- 187 Passed | 1 Failed | 1 Pending | 6 Skipped 

Same for psi-kubernetes-integration-e2e -

"kubernetes-integration-e2e" test steps failed: ["kubernetes-integration-e2e" pod "kubernetes-integration-e2e-kubernetes-integration-e2e-steps" failed: context canceled
Link to step on registry info site: https://steps.ci.openshift.org/reference/kubernetes-integration-e2e-steps
Link to job on registry info site: https://steps.ci.openshift.org/job?org=openshift&repo=odo&branch=main&test=kubernetes-integration-e2e&variant=psi, cancelled]

Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

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

/approve

pkg/segment/context/context.go Show resolved Hide resolved
pkg/segment/context/context.go Outdated Show resolved Hide resolved
pkg/odo/cli/component/create_helpers.go Outdated Show resolved Hide resolved
@openshift-ci
Copy link

openshift-ci bot commented Jun 30, 2021

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jun 30, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 30, 2021
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link

openshift-ci bot commented Jun 30, 2021

@valaparthvi: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/psi-kubernetes-integration-e2e fd86e46 link /test psi-kubernetes-integration-e2e

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.

@openshift-merge-robot openshift-merge-robot merged commit f6714b0 into redhat-developer:main Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants