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

Log deployed resources in alphabetical order for ease of comparison #441

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Arguments to `--bindings` will now be deep merged. ([#419](https://github.com/Shopify/kubernetes-deploy/pull/419))
- `kubernetes-deploy` and `kubernetes-render` now support reading templates from STDIN. ([#415](https://github.com/Shopify/kubernetes-deploy/pull/415))
- Support for specifying a `--selector`, a label with which all deployed resources are expected to have, and by which prunable resources will be filtered. This permits sharing a namespace with resources managed by third-parties, including other kubernetes-deploy deployments. ([#439](https://github.com/Shopify/kubernetes-deploy/pull/439))
- Lists of resources printed during deployments will now be sorted alphabetically. ([#441](https://github.com/Shopify/kubernetes-deploy/pull/441))

*Features*

Expand Down
7 changes: 4 additions & 3 deletions lib/kubernetes-deploy/deploy_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def discover_resources
@logger.warn("Detected non-namespaced #{'resource'.pluralize(global.count)} which will never be pruned:")
global.each { |r| @logger.warn(" - #{r.id}") }
end
resources
resources.sort
end
measure_method(:discover_resources)

Expand Down Expand Up @@ -369,6 +369,9 @@ def deploy_resources(resources, prune: false, verify:, record_summary: true)

if resources.length > 1
@logger.info("Deploying resources:")
resources.each do |r|
@logger.info("- #{r.id} (#{r.pretty_timeout_type})")
end
else
resource = resources.first
@logger.info("Deploying #{resource.id} (#{resource.pretty_timeout_type})")
Expand All @@ -381,7 +384,6 @@ def deploy_resources(resources, prune: false, verify:, record_summary: true)
applyables += individuals.select { |r| pruneable_types.include?(r.type) }

individuals.each do |r|
@logger.info("- #{r.id} (#{r.pretty_timeout_type})") if resources.length > 1
r.deploy_started_at = Time.now.utc
case r.deploy_method
when :replace
Expand Down Expand Up @@ -425,7 +427,6 @@ def apply_all(resources, prune)

Dir.mktmpdir do |tmp_dir|
resources.each do |r|
@logger.info("- #{r.id} (#{r.pretty_timeout_type})") if resources.length > 1
FileUtils.symlink(r.file_path, tmp_dir)
r.deploy_started_at = Time.now.utc
end
Expand Down
4 changes: 4 additions & 0 deletions lib/kubernetes-deploy/kubernetes_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def id
"#{type}/#{name}"
end

def <=>(other)
id <=> other.id
end

def file_path
file.path
end
Expand Down
6 changes: 3 additions & 3 deletions test/integration/kubernetes_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ def test_can_deploy_template_dir_with_only_secrets_ejson
assert_logs_match_all([
"Result: SUCCESS",
%r{Secret\/catphotoscom\s+Available},
%r{Secret\/unused-secret\s+Available},
%r{Secret\/monitoring-token\s+Available},
%r{Secret\/unused-secret\s+Available},
], in_order: true)
end

Expand Down Expand Up @@ -756,10 +756,10 @@ def test_scale_existing_deployment_down_to_zero
hello_cloud.assert_pod_status(pod_name, pod_status, target)

assert_logs_match_all([
%r{Service/web\s+Selects at least 1 pod},
%r{Deployment/web\s+1 replica, 1 updatedReplica, 1 availableReplica},
%r{Service/web\s+Doesn't require any endpoint},
%r{Service/web\s+Selects at least 1 pod},
%r{Deployment/web\s+0 replicas},
%r{Service/web\s+Doesn't require any endpoint},
], in_order: true)
end

Expand Down