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 resource for Bugsnag TPR #79

Merged
merged 1 commit into from Apr 21, 2017
Merged

Add resource for Bugsnag TPR #79

merged 1 commit into from Apr 21, 2017

Conversation

mkobetic
Copy link
Contributor

Apps using the Bugsnag TPR are failing to deploy because of a chicken/egg situation with this resource. This PR makes it deploy early and also checks that the corresponding secret is created.

/cc @Shopify/cloudplatform @lyninx

@mkobetic mkobetic requested a review from KnVerey April 20, 2017 17:13
@found = st.success?
if @found
secrets, _err, st = run_kubectl("get", "secrets", "--output=jsonpath='{.items[*].metadata.name}'")
@secret_found = secrets.split.any?{|s| s.end_with?("-bugsnag")}
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'm still unsure what exactly should the secret name be, so this just looks if we have any bugsnag secret. Should be fine as long as apps don't start having multiples (unclear why would that be desirable)

Copy link
Contributor

@n1koo n1koo Apr 20, 2017

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but that's unless they call the resource something else, so I'd say it's really <%= @name %>-bugsnag, but that's going to change soon too. I also dislike duplicating the same assumption in several places (source, templates, deploys)

Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

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

A couple small things to fix, and there's a bug sitting on master that I'll make a PR for. Here's how to tophat:

image

end

def exists?
@secret_found
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be @found -- it's asking whether the resource itself exists, not whether it is ready

end

def deploy_succeeded?
exists?
Copy link
Contributor

Choose a reason for hiding this comment

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

And this should be @secret_found.

_, _err, st = run_kubectl("get", type, @name)
@found = st.success?
if @found
secrets, _err, _st = run_kubectl("get", "secrets", "--output=jsonpath='{.items[*].metadata.name}'")
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 just do --output=name to get this (well, they'll be secrets/foobar, but that should be workable I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes, i was trying to do the filtering in jsonpath at first and gave up.

@found = st.success?
if @found
secrets, _err, _st = run_kubectl("get", "secrets", "--output=jsonpath='{.items[*].metadata.name}'")
@secret_found = secrets.split.any? { |s| s.end_with?("-bugsnag") }
Copy link
Contributor

Choose a reason for hiding this comment

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

This should work, but it seems a bit sketchy. As part of the changes to this resource we'd been discussing, perhaps we should make it set a label or annotation on the secrets it creates so we can query for them more reliably. cc @n1koo

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'd be inclined to leave that to a second pass, rather than blocking this on the bugsnag issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, definitely agreed.

Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

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

:shipit: after rebase and final 🎩 (tophat is important because TPRs are not covered by the integration tests right now, since minikube does not run Shopify's controllers)

@mkobetic
Copy link
Contributor Author

mkobetic commented Apr 21, 2017

$  REVISION=foo ENVIRONMENT=production KUBECONFIG=~/.kube/config bx exe/kubernetes-deploy mk-test tierstaging --template-dir ../test-templates
[INFO][2017-04-21 12:11:47 -0400]
[INFO][2017-04-21 12:11:47 -0400]	---------------------------------Phase 1: Validating configuration----------------------------------
[INFO][2017-04-21 12:11:47 -0400]	All required parameters and files are present
[INFO][2017-04-21 12:11:47 -0400]
[INFO][2017-04-21 12:11:47 -0400]	-------------------------------Phase 2: Identifying deployment target-------------------------------
[INFO][2017-04-21 12:11:47 -0400]	Context tierstaging found
[INFO][2017-04-21 12:11:48 -0400]	Namespace mk-test found
[INFO][2017-04-21 12:11:48 -0400]
[INFO][2017-04-21 12:11:48 -0400]	----------------------------------Phase 3: Parsing deploy content-----------------------------------
[INFO][2017-04-21 12:11:49 -0400]	Discovered template for bugsnag/mk-test
[INFO][2017-04-21 12:11:49 -0400]
[INFO][2017-04-21 12:11:49 -0400]	----------------------------Phase 4: Checking initial resource statuses-----------------------------
[KUBESTATUS][2017-04-21 12:11:49 -0400]	[tierstaging][mk-test] {"group":"bugsnags","name":"mk-test","status_string":"Unknown","exists":false,"succeeded":false,"failed":false,"timed_out":false}
[INFO][2017-04-21 12:11:49 -0400]
[INFO][2017-04-21 12:11:49 -0400]	------------------------------Phase 5: Predeploying priority resources------------------------------
[INFO][2017-04-21 12:11:49 -0400]	Deploying resources:
[INFO][2017-04-21 12:11:49 -0400]	- Bugsnag/mk-test
[WARN][2017-04-21 12:11:50 -0400]	The following command failed: kubectl replace -f /var/folders/d6/sqkwj26x2mx7f2tf_wk_9vym0000gn/T/bugsnag.yml20170421-81721-15a5lhg --namespace\=mk-test --context\=tierstaging
[WARN][2017-04-21 12:11:50 -0400]	Error from server (NotFound): error when replacing "/var/folders/d6/sqkwj26x2mx7f2tf_wk_9vym0000gn/T/bugsnag.yml20170421-81721-15a5lhg": thirdpartyresourcedatas.extensions "mk-test" not found

[INFO][2017-04-21 12:11:51 -0400]	Waiting for Bugsnag/mk-test with 60s timeout
[KUBESTATUS][2017-04-21 12:11:52 -0400]	[tierstaging][mk-test] {"group":"bugsnags","name":"mk-test","status_string":"Unknown","exists":true,"succeeded":false,"failed":false,"timed_out":false}
[KUBESTATUS][2017-04-21 12:11:55 -0400]	[tierstaging][mk-test] {"group":"bugsnags","name":"mk-test","status_string":"Unknown","exists":true,"succeeded":false,"failed":false,"timed_out":false}
[KUBESTATUS][2017-04-21 12:11:58 -0400]	[tierstaging][mk-test] {"group":"bugsnags","name":"mk-test","status_string":"Unknown","exists":true,"succeeded":false,"failed":false,"timed_out":false}
[KUBESTATUS][2017-04-21 12:12:01 -0400]	[tierstaging][mk-test] {"group":"bugsnags","name":"mk-test","status_string":"Unknown","exists":true,"succeeded":false,"failed":false,"timed_out":false}
[KUBESTATUS][2017-04-21 12:12:04 -0400]	[tierstaging][mk-test] {"group":"bugsnags","name":"mk-test","status_string":"Available","exists":true,"succeeded":true,"failed":false,"timed_out":false}
[INFO][2017-04-21 12:12:04 -0400]	Spent 12.8s waiting for Bugsnag/mk-test
[INFO][2017-04-21 12:12:04 -0400]
[INFO][2017-04-21 12:12:04 -0400]	----------------------------------Phase 6: Deploying all resources----------------------------------
[INFO][2017-04-21 12:12:04 -0400]	Deploying resources:
[INFO][2017-04-21 12:12:04 -0400]	- Bugsnag/mk-test
[INFO][2017-04-21 12:12:04 -0400]	Waiting for Bugsnag/mk-test with 60s timeout
[KUBESTATUS][2017-04-21 12:12:05 -0400]	[tierstaging][mk-test] {"group":"bugsnags","name":"mk-test","status_string":"Available","exists":true,"succeeded":true,"failed":false,"timed_out":false}
[INFO][2017-04-21 12:12:05 -0400]	Spent 0.9s waiting for Bugsnag/mk-test
[INFO][2017-04-21 12:12:05 -0400]	Deploy succeeded!

🎉

@mkobetic mkobetic merged commit db5d55f into master Apr 21, 2017
@mkobetic mkobetic deleted the bugsnag_resource branch April 21, 2017 16:21
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.

None yet

3 participants