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

Global deploy 2 #602

Merged
merged 9 commits into from
Nov 7, 2019
Merged

Global deploy 2 #602

merged 9 commits into from
Nov 7, 2019

Conversation

dturn
Copy link
Contributor

@dturn dturn commented Oct 22, 2019

What are you trying to accomplish with this PR?
Second attempt to build a global deploy task.

How is this accomplished?
Three major differences from #574.

  1. The global_deploy_task.rb doesn't inherit from deploy_task.rb.

  2. I created a concern(module) for the code that should be shared. There is still duplicate code, but what's duplicated is either commonly duplicated in the codebase (kubectl) or small snippets that might look different in the future without causing harm to the other task.

  3. New class introduced: ResourceDeployer.

ToDo

  • Write more tests
  • Rebsae after the rename PR merged

What could go wrong?
This doesn't support pruning, that will come in a follow-up PR.

Something subtle and untested breaks (or changes) behavior in deploy_test.rb due to it being in the new concern or class.

@dturn dturn force-pushed the global-deploy-2 branch 2 times, most recently from fb31d05 to e357af0 Compare October 22, 2019 18:56
include Krane::TemplateReporting

delegate :logger, to: :@task_config
attr_reader :statsd_tags
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed by KubernetesDeploy::StatsD::MeasureMethods

@dturn dturn marked this pull request as ready for review October 23, 2019 18:10
@dturn dturn requested review from KnVerey and a team October 23, 2019 18:11
@@ -317,7 +317,7 @@ def debug_message(cause = nil, info_hash = {})
def fetch_events(kubectl)
return {} unless exists?
out, _err, st = kubectl.run("get", "events", "--output=go-template=#{Event.go_template_for(type, name)}",
log_failure: false)
log_failure: false, use_namespace: !global?)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

kubectl api-resouces indicates that events are NAMESPACED. Running kubectl get events returns events about Nodes which are also global, so I believe this is the correct behavior.

@dturn dturn force-pushed the global-deploy-2 branch 2 times, most recently from 90bced6 to ea2a014 Compare October 24, 2019 21:39
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.

I haven't had a look at the tests yet, but I like where this is going 👌

lib/krane/cli/global_deploy_command.rb Outdated Show resolved Hide resolved
lib/krane/cli/krane.rb Outdated Show resolved Hide resolved
lib/krane/global_deploy_task.rb Outdated Show resolved Hide resolved
lib/krane/global_deploy_task.rb Outdated Show resolved Hide resolved
lib/krane/global_deploy_task.rb Outdated Show resolved Hide resolved
@@ -40,7 +40,7 @@ class KubernetesResource
SERVER_DRY_RUNNABLE = false

class << self
def build(namespace:, context:, definition:, logger:, statsd_tags:, crd: nil, global_names: [])
def build(namespace: nil, context:, definition:, logger:, statsd_tags:, crd: nil, global_names: [])
Copy link
Contributor

Choose a reason for hiding this comment

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

If we put the ClusterResourceDisovery stuff in the TaskConfig, this could have a much smaller signature, without namespace being oddly optional: build(task_config:, definition:, statsd_tags:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we've got a tracking issue for making build take a task_config.

lib/kubernetes-deploy/resource_cache.rb Outdated Show resolved Hide resolved
lib/kubernetes-deploy/resource_deployer.rb Outdated Show resolved Hide resolved
lib/kubernetes-deploy/resource_deployer.rb Outdated Show resolved Hide resolved
end

output_is_sensitive = resources.any?(&:sensitive_template_content?)
global_mode = resources.all?(&:global?)
Copy link
Contributor

Choose a reason for hiding this comment

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

So in the mixed-mode scenario currently possible under the old deploy task, we pass a namespace arg that is just ignored by kubectl as appropriate? I guess that's what we've always done, and it works. 🤔

@dturn dturn force-pushed the global-deploy-2 branch 4 times, most recently from 60397c5 to 09c68db Compare October 29, 2019 18:48
@dturn dturn requested a review from KnVerey October 29, 2019 18:59
lib/krane/deploy_task_config_validator.rb Outdated Show resolved Hide resolved
lib/krane/global_deploy_task.rb Outdated Show resolved Hide resolved
lib/krane/global_deploy_task.rb Outdated Show resolved Hide resolved

def check_initial_status(resources)
cache = Krane::ResourceCache.new(@task_config)
Krane::Concurrency.split_across_threads(resources) { |r| r.sync(cache) }
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to prewarm here when Ryan's PR merges.

lib/krane/task_config.rb Outdated Show resolved Hide resolved
test/integration-serial/serial_deploy_test.rb Show resolved Hide resolved
test/unit/resource_cache_test.rb Outdated Show resolved Hide resolved
test/exe/global_deploy_test.rb Outdated Show resolved Hide resolved
test/exe/global_deploy_test.rb Outdated Show resolved Hide resolved
test/unit/krane/resource_deployer_test.rb Show resolved Hide resolved
@dturn dturn force-pushed the global-deploy-2 branch 2 times, most recently from 5994edb to 9467bc6 Compare November 2, 2019 20:50
@dturn
Copy link
Contributor Author

dturn commented Nov 4, 2019

Pruning draft PR #612

Copy link
Contributor

@RyanBrushett RyanBrushett left a comment

Choose a reason for hiding this comment

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

Couple questions but looks pretty good.

lib/krane/cluster_resource_discovery.rb Show resolved Hide resolved
lib/krane/global_deploy_task.rb Show resolved Hide resolved
lib/krane/global_deploy_task.rb Show resolved Hide resolved
lib/krane/global_deploy_task.rb Show resolved Hide resolved
test/fixtures/globals/storage_classes.yml Show resolved Hide resolved
test/helpers/fixture_deploy_helper.rb Outdated Show resolved Hide resolved
test/unit/krane/resource_deployer_test.rb Show resolved Hide resolved
test/unit/krane/resource_deployer_test.rb Outdated Show resolved Hide resolved
test/unit/krane/resource_deployer_test.rb Outdated Show resolved Hide resolved
@timothysmith0609
Copy link
Contributor

One more note is to fix the linter error being thrown in CI

@dturn dturn force-pushed the global-deploy-2 branch 2 times, most recently from 62c4cdc to 3cc40d8 Compare November 6, 2019 18:11
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.

Almost there!

lib/krane/deploy_task_config_validator.rb Outdated Show resolved Hide resolved
lib/krane/deprecated_deploy_task.rb Outdated Show resolved Hide resolved
def global_kinds
@global_kinds ||= begin
cluster_resource_discoverer = ClusterResourceDiscovery.new(task_config: self)
cluster_resource_discoverer.global_resource_kinds
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you missed the question in my last pass: this seems to be the only place this method is called. Why not move the method body here and not expose it on two different classses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changes a in the pruning PR. I'd like to defer this question till that PR.

test/helpers/fixture_deploy_helper.rb Outdated Show resolved Hide resolved
test/helpers/fixture_deploy_helper.rb Outdated Show resolved Hide resolved
test/integration-serial/serial_deploy_test.rb Show resolved Hide resolved
test/integration-serial/serial_deploy_test.rb Outdated Show resolved Hide resolved
test/integration/global_deploy_test.rb Show resolved Hide resolved
test/integration/global_deploy_test.rb Outdated Show resolved Hide resolved
test/integration/global_deploy_test.rb Outdated Show resolved Hide resolved
template_paths = filenames.map { |path| File.expand_path(path) }

@task_config = TaskConfig.new(context, nil)
@task_config = TaskConfig.new(context, nil, logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's default this like the old task does, so they don't have to pass one in.

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.

Just this one last thing, then 🚢

d7de6cc#r343733769

%r{Deploying StorageClass\/testing-storage-class[\w-]+ \(timeout: 300s\)},
"Don't know how to monitor resources of type StorageClass.",
%r{Assuming StorageClass\/testing-storage-class[\w-]+ deployed successfully.},
%r{Successfully deployed in 0.[\d]+s: StorageClass\/testing-storage-class},
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this needs to be relaxed:

Successfully deployed in 0.[\d]+s: StorageClass/testing-storage-class)' not found in the following logs:
Because it took more than a second for whatever reason

%r{Deploying StorageClass\/testing-storage-class[\w-]+ \(timeout: 300s\)},
"Don't know how to monitor resources of type StorageClass.",
%r{Assuming StorageClass\/testing-storage-class[\w-]+ deployed successfully.},
%r{Successfully deployed in 0.[\d]+s: StorageClass\/testing-storage-class},
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here I imagine

@dturn dturn merged commit 42f0a97 into master Nov 7, 2019
@dturn dturn mentioned this pull request Nov 12, 2019
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

4 participants