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

CLOUDP-62053: It is not possible to unack an alert #160

Merged
merged 11 commits into from
May 7, 2020

Conversation

andreaangiolillo
Copy link
Collaborator

Proposed changes

Jira ticket: CLOUDP-62053

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • I have tested it using my local OM

Further comments

ACK:

./bin/mongocli om alerts ack 5eac0cb0323b0e4445a7b477  -P OPS --until 2021-10-01T00:00:00-0400
{
	"id": "5eac0cb0323b0e4445a7b477",
	"groupId": "5ea6a50fec050149b3105d1e",
	"alertConfigId": "5ea6a50fec050149b3105d1f",
	"eventTypeName": "MONITORING_AGENT_DOWN",
	"created": "2020-05-01T11:49:04Z",
	"updated": "2020-05-07T10:51:18Z",
	"status": "OPEN",
	"lastNotified": "2020-05-07T08:20:29Z",
	"acknowledgedUntil": "2021-10-01T03:59:18Z",
	"acknowledgingUsername": "crzrxjqz"
}

ACK FOREVER:

./bin/mongocli om alerts ack 5eac0cb0323b0e4445a7b477  -P OPS --forever
{
	"id": "5eac0cb0323b0e4445a7b477",
	"groupId": "5ea6a50fec050149b3105d1e",
	"alertConfigId": "5ea6a50fec050149b3105d1f",
	"eventTypeName": "MONITORING_AGENT_DOWN",
	"created": "2020-05-01T11:49:04Z",
	"updated": "2020-05-07T10:50:27Z",
	"status": "OPEN",
	"lastNotified": "2020-05-07T08:20:29Z",
	"acknowledgedUntil": "2120-06-08T11:49:27Z",
	"acknowledgingUsername": "crzrxjqz"
}

UNACK:

./bin/mongocli om alerts ack 5eac0cb0323b0e4445a7b477  -P OPS
{
	"id": "5eac0cb0323b0e4445a7b477",
	"groupId": "5ea6a50fec050149b3105d1e",
	"alertConfigId": "5ea6a50fec050149b3105d1f",
	"eventTypeName": "MONITORING_AGENT_DOWN",
	"created": "2020-05-01T11:49:04Z",
	"updated": "2020-05-07T10:51:26Z",
	"status": "OPEN",
	"lastNotified": "2020-05-07T08:20:29Z"
}

@andreaangiolillo andreaangiolillo requested a review from gssbzn May 7, 2020 11:15
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

Fix looks good to me I just have a question and is more out of curiosity than anything else

}

return &atlas.AcknowledgeRequest{
AcknowledgedUntil: until,
AcknowledgedUntil: opts.until,
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] do we need to update the client? this field has an omit empty so I'm wondering how is it working with blank?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we have to update the atlas client. The field is set to nil when the until flag is black which is what we want here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

AcknowledgedUntil is not a pointer so it can't be nil, only empty ("")
when we serialize it it would only be something like an empty object {} so maybe the API is assuming that since there's no key is null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought that the serialization of an empty string with omitempty was nil since I got null when I printed the value of until in the server.

Copy link
Collaborator

Choose a reason for hiding this comment

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

omitempty means that it won't serialize/deserialize that key not about its content, the content defines the rule for omitempty, which in the case of string is the empty string ""

Copy link
Collaborator Author

@andreaangiolillo andreaangiolillo May 7, 2020

Choose a reason for hiding this comment

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

Yes, I noticed it, I was reading this article https://www.sohamkamani.com/golang/2018-07-19-golang-omitempty/ that explains it very well. Regarding your question, as you previously said, the only explanation seems to be that the API sets the object to null when there is no key (which makes sense).

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, omitempty is confusing, I know, is one of the things took me the most to get on go, and we can trip a lot with it
if you are sure this works as expected we can merge but we need to be aware that a change on the API can break this command

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am quite confident that it is working as expected but we can make AcknowledgedUntil in the atlas client a pointer just to be sure that this behaviour is not going to change in the future. Let me know if you want me to open a PR in the altlas go client.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@andreaangiolillo sorry, was busy and forgot about this, up to you, I'm ok to merge this as it is and we can improve the client later

@andreaangiolillo andreaangiolillo merged commit edf3235 into master May 7, 2020
@andreaangiolillo andreaangiolillo deleted the CLOUDP-62053 branch May 7, 2020 17:33
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