krane 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78d05d646de5dda6c38cd1fec3e5abca3964b656e7bd432ebb4f9e537dd3a88c
4
- data.tar.gz: 41a4ed27fc0a646c4471f4c6505ec24eb8ff605565f86eef1ea78ff75b614f7d
3
+ metadata.gz: d24b8a158239b66ab2f5ee126937935c9942dfea2336fe213410326e446c30dc
4
+ data.tar.gz: 44ee52b5123fd507c62f266b371f14edc606f2738550e47c39b5e2995b907b0b
5
5
  SHA512:
6
- metadata.gz: c8f7269fb7fb49b758bf6ac8127adf93bdcc59417ca6a3789b879e28cde2628e1bfacef8bda9f0b3534acc03792d359e5fbfad70260dab173179db362c007255
7
- data.tar.gz: cda59df1d38965783cf146c847db571b697ab23737655744f4123fa7b169f72aa0aaf9305b82f145b68792e1a58cf5b2571427db9cef340864c660b21ae82c61
6
+ metadata.gz: 37c9f7d48d131277dac55b357ef895b63e5822ab7428954a1d7b871ce50594908df47bfc82320dd4f01b4e6d790b3383e9eb214ba42f98f03afd0c5332ebcb4c
7
+ data.tar.gz: e3f98ac0a1c55fdb63f88977cc9fad4d72c3ec437f7795ceaffbcc2664387b60d7f4ea6e75e3cc596f73b823371063d7dcc5d80ba63efe44b000dd9b02498551
@@ -1,5 +1,3 @@
1
- # Recommended rubocop version: ~> 0.78.0
2
-
3
1
  AllCops:
4
2
  Exclude:
5
3
  - 'db/schema.rb'
@@ -78,13 +76,6 @@ Style/BlockDelimiters:
78
76
  - proc
79
77
  - it
80
78
 
81
- Style/BracesAroundHashParameters:
82
- EnforcedStyle: no_braces
83
- SupportedStyles:
84
- - braces
85
- - no_braces
86
- - context_dependent
87
-
88
79
  Layout/CaseIndentation:
89
80
  EnforcedStyle: end
90
81
  SupportedStyles:
@@ -1,6 +1,6 @@
1
1
  containers:
2
2
  default:
3
- docker: circleci/ruby:2.4.6-node-browsers
3
+ docker: circleci/ruby:2.5.7
4
4
 
5
5
  steps:
6
6
  - label: Lint
@@ -9,6 +9,21 @@ steps:
9
9
  - bundle exec rubocop
10
10
  dependencies:
11
11
  - bundler
12
+ - label: 'Run Test Suite (:kubernetes: 1.17-latest :ruby: 2.7)'
13
+ command: bin/ci
14
+ agents:
15
+ queue: k8s-ci
16
+ env:
17
+ LOGGING_LEVEL: "4"
18
+ KUBERNETES_VERSION: v1.17-latest
19
+ RUBY_VERSION: "2.7"
20
+ - label: 'Run Test Suite (:kubernetes: 1.17-latest)'
21
+ command: bin/ci
22
+ agents:
23
+ queue: k8s-ci
24
+ env:
25
+ LOGGING_LEVEL: "4"
26
+ KUBERNETES_VERSION: v1.17-latest
12
27
  - label: 'Run Test Suite (:kubernetes: 1.16-latest)'
13
28
  command: bin/ci
14
29
  agents:
@@ -51,4 +66,3 @@ steps:
51
66
  env:
52
67
  LOGGING_LEVEL: "4"
53
68
  KUBERNETES_VERSION: v1.11-latest
54
-
data/1.0-Upgrade.md CHANGED
@@ -119,7 +119,7 @@ Old flag | New flag | Comments
119
119
  --skip-wait | --verify-result=true |
120
120
  --allow-protected-ns | --protected-namespaces=default,kube-system,kube-public | Added the ability to specify which namespaces are protected
121
121
  --no-prune | --prune=true |
122
- --template-dir | -f, --filename | Makes all krane commands accept this argument, which is now required for the deploy task
122
+ --template-dir | -f, --filenames | Makes all krane commands accept this argument, which is now required for the deploy task
123
123
  --verbose-log-prefix | --verbose-log-prefix |
124
124
  --max-watch-seconds=seconds | --global-timeout=300s | Changed flag name and default value to be a duration (expressed using strings like "300s" or "1h")
125
125
  --selector | --selector |
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  ## next
2
2
 
3
- ...
3
+ ## 1.1.3
4
+
5
+ *Bug Fixes*
6
+ - Retry dry-run validation when no error is returned. [#705](https://github.com/Shopify/krane/pull/705)
7
+ - Stop deploys if ClusterResourceDiscovery's kubectl calls fail. [#701](https://github.com/Shopify/krane/pull/701)
8
+
9
+ *Other*
10
+ - Dropped support for Ruby 2.4 since it will be EoL shortly. [#693](https://github.com/Shopify/krane/pull/693).
11
+ - Ruby 2.7 support: fix deprecation warnings, add testing. [#710](https://github.com/Shopify/krane/pull/705)
4
12
 
5
13
  ## 1.1.2
6
14
  *Enhancements*
data/README.md CHANGED
@@ -73,7 +73,7 @@ If you need the ability to render dynamic values in templates before deploying,
73
73
 
74
74
  ## Prerequisites
75
75
 
76
- * Ruby 2.4+
76
+ * Ruby 2.5+
77
77
  * Your cluster must be running Kubernetes v1.11.0 or higher<sup>1</sup>
78
78
 
79
79
  <sup>1</sup> We run integration tests against these Kubernetes versions. You can find our
@@ -103,7 +103,7 @@ official compatibility chart below.
103
103
 
104
104
  *Environment variables:*
105
105
 
106
- - `$KUBECONFIG`: points to one or multiple valid kubeconfig files that include the context you want to deploy to. File names are separated by colon for Linux and Mac, and semi-colon for Windows. If ommitted, will use the Kubernetes default of `~/.kube/config`.
106
+ - `$KUBECONFIG`: points to one or multiple valid kubeconfig files that include the context you want to deploy to. File names are separated by colon for Linux and Mac, and semi-colon for Windows. If omitted, Krane will use the Kubernetes default of `~/.kube/config`.
107
107
  - `$GOOGLE_APPLICATION_CREDENTIALS`: points to the credentials for an authenticated service account (required if your kubeconfig `user`'s auth provider is GCP)
108
108
 
109
109
 
@@ -544,9 +544,7 @@ krane render -f ./path/to/template/dir/template.yaml.erb > template.yaml
544
544
  - `--bindings=BINDINGS`: Makes additional variables available to your ERB templates. For example, `krane render --bindings=color=blue size=large -f some-template.yaml.erb` will expose `color` and `size` to `some-template.yaml.erb`.
545
545
  - `--current-sha`: Expose SHA `current_sha` in ERB bindings
546
546
 
547
- You can add additional variables using the `--bindings=BINDINGS` option which can be formated as a string, JSON string or path to a JSON or YAML file. Complex JSON or YAML data will be converted to a Hash for use in templates. To load a file the argument should include the relative
548
- file path prefixed with an `@` sign. An argument error will be raised if the string argument cannot be parsed, the referenced file does not include a
549
- valid extension (`.json`, `.yaml` or `.yml`) or the referenced file does not exist.
547
+ You can add additional variables using the `--bindings=BINDINGS` option which can be formatted as a string, JSON string or path to a JSON or YAML file. Complex JSON or YAML data will be converted to a Hash for use in templates. To load a file, the argument should include the relative file path prefixed with an `@` sign. An argument error will be raised if the string argument cannot be parsed, the referenced file does not include a valid extension (`.json`, `.yaml` or `.yml`) or the referenced file does not exist.
550
548
 
551
549
  #### Bindings examples
552
550
 
data/bin/ci CHANGED
@@ -17,5 +17,5 @@ docker run --rm \
17
17
  -e VERBOSE=1 \
18
18
  -e PARALLELISM=$PARALLELISM \
19
19
  -w /usr/src/app \
20
- ruby:2.4 \
20
+ ruby:"${RUBY_VERSION:-2.5}" \
21
21
  bin/test
data/dev.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: krane
3
3
  up:
4
- - ruby: 2.4.6 # Matches gemspec
4
+ - ruby: 2.5.7 # Matches gemspec
5
5
  - bundler
6
6
  - homebrew:
7
7
  - Caskroom/cask/minikube
data/krane.gemspec CHANGED
@@ -23,7 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = %w(lib)
25
25
 
26
- spec.required_ruby_version = '>= 2.4.0'
26
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
27
+
28
+ spec.required_ruby_version = '>= 2.5.0'
27
29
  spec.add_dependency("activesupport", ">= 5.0")
28
30
  spec.add_dependency("kubeclient", "~> 4.3")
29
31
  spec.add_dependency("googleauth", "~> 0.8")
@@ -37,7 +37,7 @@ module Krane
37
37
  def fetch_resources(namespaced: false)
38
38
  command = %w(api-resources)
39
39
  command << "--namespaced=#{namespaced}"
40
- raw, _, st = kubectl.run(*command, output: "wide", attempts: 5,
40
+ raw, err, st = kubectl.run(*command, output: "wide", attempts: 5,
41
41
  use_namespace: false)
42
42
  if st.success?
43
43
  rows = raw.split("\n")
@@ -59,7 +59,7 @@ module Krane
59
59
  resource
60
60
  end
61
61
  else
62
- []
62
+ raise FatalKubeAPIError, "Error retrieving api-resources: #{err}"
63
63
  end
64
64
  end
65
65
 
@@ -68,7 +68,7 @@ module Krane
68
68
  # kubectl api-versions returns a list of group/version strings e.g. autoscaling/v2beta2
69
69
  # A kind may not exist in all versions of the group.
70
70
  def fetch_api_versions
71
- raw, _, st = kubectl.run("api-versions", attempts: 5, use_namespace: false)
71
+ raw, err, st = kubectl.run("api-versions", attempts: 5, use_namespace: false)
72
72
  # The "core" group is represented by an empty string
73
73
  versions = { "" => %w(v1) }
74
74
  if st.success?
@@ -78,6 +78,8 @@ module Krane
78
78
  versions[group] ||= []
79
79
  versions[group] << version
80
80
  end
81
+ else
82
+ raise FatalKubeAPIError, "Error retrieving api-versions: #{err}"
81
83
  end
82
84
  versions
83
85
  end
@@ -98,12 +100,12 @@ module Krane
98
100
  end
99
101
 
100
102
  def fetch_crds
101
- raw_json, _, st = kubectl.run("get", "CustomResourceDefinition", output: "json", attempts: 5,
103
+ raw_json, err, st = kubectl.run("get", "CustomResourceDefinition", output: "json", attempts: 5,
102
104
  use_namespace: false)
103
105
  if st.success?
104
106
  JSON.parse(raw_json)["items"]
105
107
  else
106
- []
108
+ raise FatalKubeAPIError, "Error retrieving CustomResourceDefinition: #{err}"
107
109
  end
108
110
  end
109
111
 
@@ -116,8 +116,8 @@ module Krane
116
116
  # Runs the task, returning a boolean representing success or failure
117
117
  #
118
118
  # @return [Boolean]
119
- def run(*args)
120
- run!(*args)
119
+ def run(**args)
120
+ run!(**args)
121
121
  true
122
122
  rescue FatalDeploymentError
123
123
  false
@@ -46,8 +46,8 @@ module Krane
46
46
  # Runs the task, returning a boolean representing success or failure
47
47
  #
48
48
  # @return [Boolean]
49
- def run(*args)
50
- run!(*args)
49
+ def run(**args)
50
+ run!(**args)
51
51
  true
52
52
  rescue FatalDeploymentError
53
53
  false
data/lib/krane/kubectl.rb CHANGED
@@ -6,6 +6,7 @@ module Krane
6
6
  ERROR_MATCHERS = {
7
7
  not_found: /NotFound/,
8
8
  client_timeout: /Client\.Timeout exceeded while awaiting headers/,
9
+ empty: /\A\z/,
9
10
  }
10
11
  DEFAULT_TIMEOUT = 15
11
12
  MAX_RETRY_DELAY = 16
@@ -572,7 +572,7 @@ module Krane
572
572
  def validate_with_server_side_dry_run(kubectl)
573
573
  command = ["apply", "-f", file_path, "--server-dry-run", "--output=name"]
574
574
  kubectl.run(*command, log_failure: false, output_is_sensitive: sensitive_template_content?,
575
- retry_whitelist: [:client_timeout], attempts: 3)
575
+ retry_whitelist: [:client_timeout, :empty], attempts: 3)
576
576
  end
577
577
 
578
578
  # Local dry run is supported on only create and apply
@@ -582,7 +582,7 @@ module Krane
582
582
  verb = deploy_method == :apply ? "apply" : "create"
583
583
  command = [verb, "-f", file_path, "--dry-run", "--output=name"]
584
584
  kubectl.run(*command, log_failure: false, output_is_sensitive: sensitive_template_content?,
585
- retry_whitelist: [:client_timeout], attempts: 3, use_namespace: !global?)
585
+ retry_whitelist: [:client_timeout, :empty], attempts: 3, use_namespace: !global?)
586
586
  end
587
587
 
588
588
  def labels
@@ -62,7 +62,7 @@ module Krane
62
62
  kind
63
63
  end
64
64
 
65
- def validate_definition(*)
65
+ def validate_definition(*, **)
66
66
  super
67
67
 
68
68
  @crd.validate_rollout_conditions
@@ -66,7 +66,7 @@ module Krane
66
66
  @rollout_conditions = nil
67
67
  end
68
68
 
69
- def validate_definition(*)
69
+ def validate_definition(*, **)
70
70
  super
71
71
 
72
72
  validate_rollout_conditions
@@ -97,7 +97,7 @@ module Krane
97
97
  progress_condition.present? ? deploy_failing_to_progress? : super
98
98
  end
99
99
 
100
- def validate_definition(*)
100
+ def validate_definition(*, **)
101
101
  super
102
102
 
103
103
  unless REQUIRED_ROLLOUT_TYPES.include?(required_rollout) || percent?(required_rollout)
@@ -191,7 +191,7 @@ module Krane
191
191
  def min_available_replicas
192
192
  if percent?(required_rollout)
193
193
  (desired_replicas * required_rollout.to_i / 100.0).ceil
194
- elsif max_unavailable =~ /%/
194
+ elsif max_unavailable.is_a?(String) && max_unavailable =~ /%/
195
195
  (desired_replicas * (100 - max_unavailable.to_i) / 100.0).ceil
196
196
  else
197
197
  desired_replicas - max_unavailable.to_i
@@ -24,8 +24,8 @@ module Krane
24
24
  # Runs the task, returning a boolean representing success or failure
25
25
  #
26
26
  # @return [Boolean]
27
- def run(*args)
28
- run!(*args)
27
+ def run(**args)
28
+ run!(**args)
29
29
  true
30
30
  rescue Krane::FatalDeploymentError
31
31
  false
@@ -39,8 +39,8 @@ module Krane
39
39
  # Runs the task, returning a boolean representing success or failure
40
40
  #
41
41
  # @return [Boolean]
42
- def run(*args)
43
- perform!(*args)
42
+ def run(**args)
43
+ perform!(**args)
44
44
  true
45
45
  rescue FatalDeploymentError
46
46
  false
@@ -34,8 +34,8 @@ module Krane
34
34
  # Runs the task, returning a boolean representing success or failure
35
35
  #
36
36
  # @return [Boolean]
37
- def run(*args)
38
- run!(*args)
37
+ def run(**args)
38
+ run!(**args)
39
39
  true
40
40
  rescue DeploymentTimeoutError, FatalDeploymentError
41
41
  false
data/lib/krane/statsd.rb CHANGED
@@ -35,10 +35,10 @@ module Krane
35
35
  end
36
36
 
37
37
  metric ||= "#{method_name}.duration"
38
- self::InstrumentationProxy.send(:define_method, method_name) do |*args, &block|
38
+ self::InstrumentationProxy.send(:define_method, method_name) do |*args, **kwargs, &block|
39
39
  begin
40
40
  start_time = Time.now.utc
41
- super(*args, &block)
41
+ super(*args, **kwargs, &block)
42
42
  rescue
43
43
  error = true
44
44
  raise
data/lib/krane/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Krane
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.3"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krane
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Verey
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-02-25 00:00:00.000000000 Z
13
+ date: 2020-04-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -498,7 +498,8 @@ files:
498
498
  homepage: https://github.com/Shopify/krane
499
499
  licenses:
500
500
  - MIT
501
- metadata: {}
501
+ metadata:
502
+ allowed_push_host: https://rubygems.org
502
503
  post_install_message:
503
504
  rdoc_options: []
504
505
  require_paths:
@@ -507,7 +508,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
507
508
  requirements:
508
509
  - - ">="
509
510
  - !ruby/object:Gem::Version
510
- version: 2.4.0
511
+ version: 2.5.0
511
512
  required_rubygems_version: !ruby/object:Gem::Requirement
512
513
  requirements:
513
514
  - - ">="