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

Allow overriding json values before sending #644

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

smarthall
Copy link

Combined with the -i option this makes it possible to send a servicelog without using a template at all.

Solves: https://issues.redhat.com/browse/OSD-26164

@openshift-ci openshift-ci bot requested review from clcollins and typeid December 17, 2024 03:48
Copy link
Contributor

openshift-ci bot commented Dec 17, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: smarthall
Once this PR has been reviewed and has the lgtm label, please assign dustman9000 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

cmd/servicelog/post.go Outdated Show resolved Hide resolved
cmd/servicelog/post.go Outdated Show resolved Hide resolved
cmd/servicelog/post.go Show resolved Hide resolved
cmd/servicelog/post.go Outdated Show resolved Hide resolved
cmd/servicelog/post.go Outdated Show resolved Hide resolved
cmd/servicelog/common.go Outdated Show resolved Hide resolved
@smarthall smarthall force-pushed the override_json_values branch from 0624bf7 to 6d981fd Compare December 19, 2024 06:13
@smarthall smarthall force-pushed the override_json_values branch from 6d981fd to 0a393ad Compare January 20, 2025 01:20
@smarthall smarthall requested a review from bmeng January 20, 2025 01:22
cmd/servicelog/post.go Outdated Show resolved Hide resolved
@bmeng
Copy link
Contributor

bmeng commented Jan 20, 2025

only one typo, other than that lgtm. Tested on my cluster and it works as expected.

$ osdctl2 servicelog post 2gdo36f2qql2cesgk8l7qk3btjl3ma0c -i -r summary=test -r description="test message"
WARN: The current version (v0.40.0-next) is different than the latest released version (v0.40.0). It is recommended that you update to the latest released version to ensure that no known bugs or issues are hit.
Continue? (y/N): y
INFO[0001] Overrode 'summary' to 'test'                 
INFO[0001] Overrode 'description' to 'test message'     
INFO[0002] The following clusters match the given parameters: 
Name                ID                                 State               Version             Cloud Provider      Region
bmeng-hcp           2gdo36f2qql2cesgk8l7qk3btjl3ma0c   validating          4.16.16             aws                 us-west-2

INFO[0003] The following template will be sent:         
{
  "severity":"Info",
  "service_name":"SREManualAction",
  "summary":"test",
  "description":"test message",
  "internal_only":true,
  "event_stream_id":"",
  "doc_references":null
}
Continue? (y/N): y
INFO[0014] Success: 1, Failed: 0

@smarthall smarthall force-pushed the override_json_values branch from fddb753 to ce9c13e Compare January 21, 2025 22:11
@smarthall smarthall requested a review from bmeng January 21, 2025 22:32
Copy link
Member

@clcollins clcollins left a comment

Choose a reason for hiding this comment

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

Just some minor comments. Looks good otherwise!

# Post an internal-only service log message
osdctl servicelog post ${CLUSTER_ID} -i -p "MESSAGE=This is an internal message" --dry-run

# Post a short external message
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, but here under "external message", the command has a lot of "internal message" content for the summary and description. Not a real issue, but might confuse someone

Copy link
Member

@clcollins clcollins Jan 22, 2025

Choose a reason for hiding this comment

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

Actually, I'm not quite sure why you can override the -i (--internal) here, with -r internal_only=False. That seems unintuitive. That might be a good use case to say something like "-i is incompatible with -r internal_only=false". Definitely an edge case, though.

Can you elaborate?

Copy link
Author

Choose a reason for hiding this comment

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

I wanted to avoid adding another command line argument (like -e) that includes a blank template, or a template with some sane defaults. As we discussed lets come back and add it in the future if required.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel it would be a bit confusing if we have to use -i to combine with the -r. I will make me think the override works for internal messages only.
Could it be possible we just can make the template optional if the -r specified?

Copy link
Author

@smarthall smarthall Jan 23, 2025

Choose a reason for hiding this comment

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

Okay I'll make a change to that if neither -t or -i is specified, and at least one -r option is supplied the following template is used by default:

{
	"severity": "Info",
	"service_name": "SREManualAction",
	"internal_only": true
}

This way the user has to explicitly override the summary and description. Then if they want to send it to the customer they also have to explicitly override the internal_only variable.

cmd/servicelog/post.go Outdated Show resolved Hide resolved
cmd/servicelog/post.go Outdated Show resolved Hide resolved
cmd/servicelog/post.go Outdated Show resolved Hide resolved
@smarthall smarthall force-pushed the override_json_values branch from 95cd1e3 to 42fc354 Compare January 23, 2025 01:00
Combined with the `-i` option this makes it possible to send a
servicelog without using a template at all.
@smarthall smarthall force-pushed the override_json_values branch from 42fc354 to 93409e1 Compare January 23, 2025 01:18
Copy link
Contributor

openshift-ci bot commented Jan 23, 2025

@smarthall: 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-sigs/prow repository. I understand the commands that are listed here.

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.

3 participants