Skip to content
This repository was archived by the owner on Oct 11, 2019. It is now read-only.

VYGR-391: Add OpsGenie integration manager client - #119

Merged
fcobb merged 4 commits into
masterfrom
fcobb/VYGR-391-create-opsgenie-int-manager-client
Feb 13, 2019
Merged

VYGR-391: Add OpsGenie integration manager client#119
fcobb merged 4 commits into
masterfrom
fcobb/VYGR-391-create-opsgenie-int-manager-client

Conversation

@fcobb

@fcobb fcobb commented Feb 5, 2019

Copy link
Copy Markdown

This is a follow on from getting team from service central PR - #107

This adds a client that will be used in the next PR. #120

ash2k
ash2k previously requested changes Feb 5, 2019
Comment thread pkg/opsgenieIntegrationManager/client.go Outdated
Comment thread pkg/opsgenieIntegrationManager/BUILD.bazel
)

const (
asapAudience = "micros-server"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

integration manager? We probably should use a separate audience, otherwise we wouldn't be able to migrate it to a separate service. We should have built a separate service in the first place.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we want to optimize for migration to a separate service in the future, we could also make this configurable.

@jokeyrhyme can you confirm the ASAP audience to be used there? agree with Mikhail that it shouldn't be tied to micros-server.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I asked @jokeyrhyme on Slack and he replied that we can set whatever we like. I'll set this and comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, this is... not secure. The server must check audience otherwise someone can use any valid ASAP token to talk to it. e.g. I can generate a token myself and use it. /cc @jokeyrhyme

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it probably has a whitelist of issuers though? otherwise audience is useless.
@ash2k I think you're confusing issuers and audience.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fcobb what about issuers? Can you double check that issuers are whitelisted (i.e. only voyager synchronizer and micros-server are allowed to talk to Opsgenie integration manager)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I ran the manual client test (found in this PR) using the asap-creator secret and it worked.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry, I was previously tuning out from GitHub notifications, because there are multiple teams worth of activity here, but I've adjusted this now so mentions will stand out :)
I've commented on MICROS-6953 about this, after taking a quick look
We don't check claims.aud in our code or dependencies anywhere as far as I can see, but we do check claims.iss to assert that it matches

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fcobb do creator and synchronization share the same issuer then?

@fcobb fcobb Feb 13, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@nilebox No.
kubectl -n voyager get secrets asap-voyager-synchronization gives me issuer: a3ViZS92b3lhZ2VyLXN5bmNocm9uaXphdGlvbg==
kubectl -n voyager get secrets asap-creator -o yaml gives me issuer: a3ViZS92b3lhZ2VyLWNyZWF0b3I=

Even the reporter ASAP secret works.

@jokeyrhyme "but we do check claims.iss to assert that it matches" What does it match exactly?

Comment thread pkg/opsgenieIntegrationManager/client.go Outdated
Comment thread pkg/opsgenieIntegrationManager/client.go
Comment thread pkg/opsgenieIntegrationManager/it/BUILD.bazel Outdated
Comment thread pkg/opsgenieIntegrationManager/it/client_manual_test.go Outdated
Comment thread pkg/opsgenieIntegrationManager/it/client_manual_test.go Outdated
Comment thread pkg/opsgenieIntegrationManager/it/client_manual_test.go Outdated
Comment thread pkg/opsgenieIntegrationManager/types.go Outdated
Comment thread pkg/opsgenieIntegrationManager/client.go Outdated
)

const (
asapAudience = "micros-server"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we want to optimize for migration to a separate service in the future, we could also make this configurable.

@jokeyrhyme can you confirm the ASAP audience to be used there? agree with Mikhail that it shouldn't be tied to micros-server.

Comment thread pkg/opsgenieIntegrationManager/client.go
Comment thread pkg/opsgenieIntegrationManager/client.go Outdated

retriable := false
switch response.StatusCode {
case http.StatusInternalServerError:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

any 5xx is theoretically retriable (as it's not caused by a client-side error)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Would you like me to add cases for the majority of the 5xx status codes? Seems odd to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think all 5xx's are retriable in an backoff-loop sense; 501 for example is http.StatusNotImplemented:

The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability (e.g., a new feature of a web-service API).[63]

return retriable, nil, errors.Wrap(err, "failed to read response body")
}

if response.StatusCode != http.StatusOK {

@nilebox nilebox Feb 5, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this was copied from Service Central client, and SC returns response with error details (see below that it's used for error message).
TODO: check the behavior of Opsgenie integration manager with non-200 code.

EDIT FROM FRASER:
I can't reply so editing here.
As mentioned elsewhere in this PR the swagger defines an error message response similar to the SC client. https://micros.prod.atl-paas.net/swagger/#!/opsgenie/getOrCreateOgIntegrations

I also tested this with a curl command.

Comment thread pkg/opsgenieIntegrationManager/client.go Outdated
@fcobb
fcobb changed the base branch from fcobb/VYGR-391-add-get-attributes-service-central to master February 11, 2019 05:31
@fcobb
fcobb force-pushed the fcobb/VYGR-391-create-opsgenie-int-manager-client branch from f6f5e25 to 04e1d7d Compare February 11, 2019 05:51
@fcobb
fcobb dismissed ash2k’s stale review February 12, 2019 05:18

addressed comments

@fcobb fcobb self-assigned this Feb 12, 2019
@fcobb fcobb changed the title [WIP] VYGR-391: Add OpsGenie integration manager client VYGR-391: Add OpsGenie integration manager client Feb 12, 2019
Comment thread pkg/opsgenie/client.go
}
defer util.CloseSilently(response.Body)

retriable := false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We really need a bit of code that determines where a response means a request can be retried.

The following could also be retriable:

http.StatusRequestTimeout
http.StatusServiceUnavailable

The error is also a *url.Error which has a Temporary() and Timeout() check to see what the cause might have been. I haven't been able to determine what causes a Temporary() or Timeout() to return true though.

I used them here in 732c738#diff-3ec5620e3479cc95305dc75d504a817eR84 if you want to check it out.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah as discussed IRL I like the idea but would like to make those in a follow up PR unless we decide it blocks this PR.
My intention here was to address the main use cases where we want to retry.

@scottgreenup scottgreenup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apart from some nits, let's get this through. I'd wait for @nilebox to check as well (as you mentioned).

@fcobb
fcobb merged commit ba30f9d into master Feb 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants