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

Use new servicelog endpoint for listing service logs #447

Conversation

AlexVulaj
Copy link
Contributor

@AlexVulaj AlexVulaj commented Sep 26, 2023

Resolves https://issues.redhat.com/browse/OSD-18457. At a high level, this converts our API call from

/api/service_logs/v1/clusters/bar/cluster_logs

to

/api/service_logs/v1/clusters/cluster_logs?cluster_id="foo"&cluster_uuid="bar"

I refactored the command itself to be more inline with how we declare command structs and flags now.

I also refactored to use the data models directly from the ocm sdk, which led to the following PRs.

Model:
openshift-online/ocm-api-model#844
openshift-online/ocm-api-model#845

SDK:
openshift-online/ocm-sdk-go#847
openshift-online/ocm-sdk-go#848

@openshift-ci openshift-ci bot requested review from clcollins and mjlshen September 26, 2023 15:29
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 26, 2023
@AlexVulaj AlexVulaj force-pushed the show-service-logs-internal-id branch from dd0fc6d to a6b5854 Compare September 26, 2023 15:57
@AlexVulaj
Copy link
Contributor Author

/hold

We'll need to wait for a new ocm-sdk to be built after openshift-online/ocm-sdk-go#847 is merged

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 26, 2023
cmd/servicelog/list.go Outdated Show resolved Hide resolved
Copy link
Member

@typeid typeid left a comment

Choose a reason for hiding this comment

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

Looking good, thanks for refactoring the flags on the way :)

formatMessage = fmt.Sprintf(`search=cluster_id = '%s'`, cluster.ID())
}
// TODO uncomment these fields after https://github.com/openshift-online/ocm-sdk-go/pull/847 is merged
type LogEntryView struct {
Copy link
Member

Choose a reason for hiding this comment

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

Question: Why can't we use the slv1.LogEntry type directly? Is it to have everything as string for a proper print format after viewBytes, err := json.Marshal(view)?

Copy link
Contributor Author

@AlexVulaj AlexVulaj Sep 27, 2023

Choose a reason for hiding this comment

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

We can't marshal it because the fields aren't exported unfortunately. This is the struct:

type LogEntry struct {
	bitmap_        uint32
	id             string
	href           string
	clusterID      string
	clusterUUID    string
	description    string
	eventStreamID  string
	logType        LogType
	serviceName    string
	severity       Severity
	subscriptionID string
	summary        string
	timestamp      time.Time
	username       string
	internalOnly   bool
}

After chatting with the OCM team, this was determined to be the best path forward.

@AlexVulaj AlexVulaj force-pushed the show-service-logs-internal-id branch 2 times, most recently from d438e91 to c124d09 Compare September 26, 2023 18:14
@AlexVulaj AlexVulaj force-pushed the show-service-logs-internal-id branch from c124d09 to ea9e445 Compare September 27, 2023 14:58
@AlexVulaj
Copy link
Contributor Author

/unhold

After updating ocm-api-model and ocm-sdk-go, we can now get the missing fields from the new endpoint.
PRs here for those interested:

openshift-online/ocm-api-model#844
openshift-online/ocm-api-model#845
openshift-online/ocm-sdk-go#847
openshift-online/ocm-sdk-go#848

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 27, 2023

@AlexVulaj: all tests passed!

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.

Copy link
Member

@typeid typeid left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 28, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 28, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlexVulaj, typeid

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-merge-robot openshift-merge-robot merged commit 902d8a2 into openshift:master Sep 28, 2023
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants