krane 1.1.1 → 1.1.2

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: e54a6c3238bfeef82657d2f105794a52aeb23fc33a70f0183372c852a8e0c4f4
4
- data.tar.gz: 12282bbe487b74d6d0d7cdda4429c6db426e7fe2a15aa4e1ba1be2c03b29d53f
3
+ metadata.gz: 78d05d646de5dda6c38cd1fec3e5abca3964b656e7bd432ebb4f9e537dd3a88c
4
+ data.tar.gz: 41a4ed27fc0a646c4471f4c6505ec24eb8ff605565f86eef1ea78ff75b614f7d
5
5
  SHA512:
6
- metadata.gz: d92649d9edeec0f4800c36f58a8b48224dad57521cb5aeaa2f94878c9ee5e48d96e6c68a4928ca3182e3aaf8675e83b80cff4308b14080e6a3eaedff10ac2de3
7
- data.tar.gz: 2d7478c0870c8ec53f4bba63889aaf96c06b230f7ae146c1486094d913ce69dca0ab9b3fff9c804a56e3378477df4392c656f20e89dcf6f09a6b1b6f7bada354
6
+ metadata.gz: c8f7269fb7fb49b758bf6ac8127adf93bdcc59417ca6a3789b879e28cde2628e1bfacef8bda9f0b3534acc03792d359e5fbfad70260dab173179db362c007255
7
+ data.tar.gz: cda59df1d38965783cf146c847db571b697ab23737655744f4123fa7b169f72aa0aaf9305b82f145b68792e1a58cf5b2571427db9cef340864c660b21ae82c61
@@ -0,0 +1 @@
1
+ * @Shopify/krane
@@ -1,3 +1,5 @@
1
+ # Recommended rubocop version: ~> 0.78.0
2
+
1
3
  AllCops:
2
4
  Exclude:
3
5
  - 'db/schema.rb'
@@ -20,7 +22,7 @@ Style/Alias:
20
22
  - prefer_alias
21
23
  - prefer_alias_method
22
24
 
23
- Layout/AlignHash:
25
+ Layout/HashAlignment:
24
26
  EnforcedHashRocketStyle: key
25
27
  EnforcedColonStyle: key
26
28
  EnforcedLastArgumentHashStyle: ignore_implicit
@@ -30,7 +32,7 @@ Layout/AlignHash:
30
32
  - ignore_implicit
31
33
  - ignore_explicit
32
34
 
33
- Layout/AlignParameters:
35
+ Layout/ParameterAlignment:
34
36
  EnforcedStyle: with_fixed_indentation
35
37
  SupportedStyles:
36
38
  - with_first_parameter
@@ -172,7 +174,7 @@ Naming/FileName:
172
174
  Regex:
173
175
  IgnoreExecutableScripts: true
174
176
 
175
- Layout/IndentFirstArgument:
177
+ Layout/FirstArgumentIndentation:
176
178
  EnforcedStyle: consistent
177
179
  SupportedStyles:
178
180
  - consistent
@@ -225,7 +227,7 @@ Layout/IndentationConsistency:
225
227
  Layout/IndentationWidth:
226
228
  Width: 2
227
229
 
228
- Layout/IndentFirstArrayElement:
230
+ Layout/FirstArrayElementIndentation:
229
231
  EnforcedStyle: consistent
230
232
  SupportedStyles:
231
233
  - special_inside_parentheses
@@ -233,10 +235,10 @@ Layout/IndentFirstArrayElement:
233
235
  - align_brackets
234
236
  IndentationWidth:
235
237
 
236
- Layout/IndentAssignment:
238
+ Layout/AssignmentIndentation:
237
239
  IndentationWidth:
238
240
 
239
- Layout/IndentFirstHashElement:
241
+ Layout/FirstHashElementIndentation:
240
242
  EnforcedStyle: consistent
241
243
  SupportedStyles:
242
244
  - special_inside_parentheses
@@ -340,9 +342,9 @@ Style/PercentQLiterals:
340
342
  Naming/PredicateName:
341
343
  NamePrefix:
342
344
  - is_
343
- NamePrefixBlacklist:
345
+ ForbiddenPrefixes:
344
346
  - is_
345
- NameWhitelist:
347
+ AllowedMethods:
346
348
  - is_a?
347
349
  Exclude:
348
350
  - 'spec/**/*'
@@ -467,7 +469,7 @@ Style/TernaryParentheses:
467
469
  - require_no_parentheses
468
470
  AllowSafeAssignment: true
469
471
 
470
- Layout/TrailingBlankLines:
472
+ Layout/TrailingEmptyLines:
471
473
  EnforcedStyle: final_newline
472
474
  SupportedStyles:
473
475
  - final_newline
@@ -478,7 +480,7 @@ Style/TrivialAccessors:
478
480
  AllowPredicates: true
479
481
  AllowDSLWriters: false
480
482
  IgnoreClassMethods: false
481
- Whitelist:
483
+ AllowedMethods:
482
484
  - to_ary
483
485
  - to_a
484
486
  - to_c
@@ -509,7 +511,7 @@ Style/WhileUntilModifier:
509
511
  Metrics/BlockNesting:
510
512
  Max: 3
511
513
 
512
- Metrics/LineLength:
514
+ Layout/LineLength:
513
515
  Max: 120
514
516
  AllowHeredoc: true
515
517
  AllowURI: true
@@ -561,7 +563,7 @@ Lint/UnusedMethodArgument:
561
563
  Naming/AccessorMethodName:
562
564
  Enabled: true
563
565
 
564
- Layout/AlignArray:
566
+ Layout/ArrayAlignment:
565
567
  Enabled: true
566
568
 
567
569
  Style/ArrayJoin:
@@ -840,7 +842,7 @@ Style/WhileUntilDo:
840
842
  Style/ZeroLengthPredicate:
841
843
  Enabled: true
842
844
 
843
- Layout/IndentHeredoc:
845
+ Layout/HeredocIndentation:
844
846
  EnforcedStyle: squiggly
845
847
 
846
848
  Lint/AmbiguousOperator:
@@ -864,7 +866,7 @@ Lint/DeprecatedClassMethods:
864
866
  Lint/DuplicateMethods:
865
867
  Enabled: true
866
868
 
867
- Lint/DuplicatedKey:
869
+ Lint/DuplicateHashKey:
868
870
  Enabled: true
869
871
 
870
872
  Lint/EachWithObjectArgument:
@@ -891,7 +893,7 @@ Lint/FloatOutOfRange:
891
893
  Lint/FormatParameterMismatch:
892
894
  Enabled: true
893
895
 
894
- Lint/HandleExceptions:
896
+ Lint/SuppressedException:
895
897
  AllowComments: true
896
898
 
897
899
  Lint/ImplicitStringConcatenation:
@@ -947,7 +949,7 @@ Lint/ShadowedException:
947
949
  Lint/ShadowingOuterLocalVariable:
948
950
  Enabled: true
949
951
 
950
- Lint/StringConversionInInterpolation:
952
+ Lint/RedundantStringCoercion:
951
953
  Enabled: true
952
954
 
953
955
  Lint/UnderscorePrefixedVariableName:
@@ -3,15 +3,3 @@ inherit_from:
3
3
 
4
4
  AllCops:
5
5
  TargetRubyVersion: 2.4
6
-
7
- Naming/FileName:
8
- Enabled: true
9
- Exclude:
10
- - lib/krane.rb
11
-
12
- Sorbet/ConstantsFromStrings:
13
- Enabled: false
14
-
15
- Layout/Tab:
16
- Exclude:
17
- - test/integration/krane_deploy_test.rb
@@ -1,5 +1,20 @@
1
1
  ## next
2
2
 
3
+ ...
4
+
5
+ ## 1.1.2
6
+ *Enhancements*
7
+ - Don't treat `containerCannotRun` termination reason as a fatal deploy failure, since it is usually transient. [#694](https://github.com/Shopify/krane/pull/694)
8
+
9
+ *Bug Fixes*
10
+ - Help ruby correctly identify kubectl output encoding. [#646](https://github.com/Shopify/krane/pull/646)
11
+ - Add an override for Job kind for version `batch/v2alpha1` [#696](https://github.com/Shopify/krane/pull/696)
12
+
13
+ *Other*
14
+ - `--stdin` flag is deprecated. To read from STDIN, use `-f -` (can be combined with other files/directories) [#684](https://github.com/Shopify/krane/pull/684).
15
+ - Reduces the number of container logs printed for failures from 250 to 25 to reduce noise. [#676](https://github.com/Shopify/krane/pull/676)
16
+ - Remove hardcoded cloudsql class. [#680](https://github.com/Shopify/krane/pull/680)
17
+
3
18
  ## 1.1.1
4
19
 
5
20
  *Enhancements*
@@ -159,6 +159,6 @@ Please make sure you run the tests locally before submitting your PR (see [Runni
159
159
 
160
160
  #### Employees: Triggering CI for a contributed PR
161
161
 
162
- Go to the [krane pipeline](https://buildkite.com/shopify/kubernetes-deploy) and click "New Build". Use branch `external_contrib_ci` and the specific sha of the commit you want to build. Add `BUILDKITE_REFSPEC="refs/pull/${PR_NUM}/head"` in the Environment Variables section. Since CI is only visible to Shopify employees, you will need to provide any failing tests and output to the the contributor.
162
+ Go to the [krane pipeline](https://buildkite.com/shopify/krane) and click "New Build". Use branch `external_contrib_ci` and the specific sha of the commit you want to build. Add `BUILDKITE_REFSPEC="refs/pull/${PR_NUM}/head"` in the Environment Variables section. Since CI is only visible to Shopify employees, you will need to provide any failing tests and output to the the contributor.
163
163
 
164
164
  <img width="350" alt="build external contrib PR" src="https://screenshot.click/2017-11-07--163728_7ovek-wrpwq.png">
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # krane [![Build status](https://badge.buildkite.com/35c56e797c3bbd6ba50053aefdded0715898cd8e8c86f7e462.svg)](https://buildkite.com/shopify/krane) [![codecov](https://codecov.io/gh/Shopify/kubernetes-deploy/branch/master/graph/badge.svg)](https://codecov.io/gh/Shopify/kubernetes-deploy)
1
+ # krane [![Build status](https://badge.buildkite.com/35c56e797c3bbd6ba50053aefdded0715898cd8e8c86f7e462.svg?branch=master)](https://buildkite.com/shopify/krane) [![codecov](https://codecov.io/gh/Shopify/kubernetes-deploy/branch/master/graph/badge.svg)](https://codecov.io/gh/Shopify/kubernetes-deploy)
2
2
 
3
3
  > This project used to be called `kubernetes-deploy`. Check out our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) for more information including details about breaking changes.
4
4
 
@@ -112,8 +112,7 @@ official compatibility chart below.
112
112
  Refer to `krane help` for the authoritative set of options.
113
113
 
114
114
 
115
- - `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed.
116
- - `--stdin`: Read from STDIN. Can be combined with `-f` Example: `cat templates_from_stdin/*.yml | krane deploy ns ctx -f path/to/dir path/to/file.yml --stdin`
115
+ - `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed, use `-` to specify reading from STDIN.
117
116
  - `--no-prune`: Skips pruning of resources that are no longer in your Kubernetes template set. Not recommended, as it allows your namespace to accumulate cruft that is not reflected in your deploy directory.
118
117
  - `--global-timeout=duration`: Raise a timeout error if it takes longer than _duration_ for any
119
118
  resource to deploy.
@@ -138,7 +137,7 @@ If you need to share a namespace with resources which are managed by other tools
138
137
  All templates must be YAML formatted.
139
138
  We recommended storing each app's templates in a single directory, `{app root}/config/deploy/{env}`. However, you may use multiple directories.
140
139
 
141
- If you want dynamic templates, you may render ERB with `krane render` and then pipe that result to `krane deploy --stdin`. `krane deploy` supports using both `--filenames` and `--stdin` together.
140
+ If you want dynamic templates, you may render ERB with `krane render` and then pipe that result to `krane deploy -f -`.
142
141
 
143
142
  ### Customizing behaviour with annotations
144
143
  - `krane.shopify.io/timeout-override`: Override the tool's hard timeout for one specific resource. Both full ISO8601 durations and the time portion of ISO8601 durations are valid. Value must be between 1 second and 24 hours.
@@ -329,7 +328,7 @@ Let's walk through what happens when you run the `deploy` task with [this direct
329
328
  You can test this out for yourself by running the following command:
330
329
 
331
330
  ```bash
332
- krane render -f test/fixtures/hello-cloud --current-sha 1 | krane deploy my-namespace my-k8s-cluster --stdin
331
+ krane render -f test/fixtures/hello-cloud --current-sha 1 | krane deploy my-namespace my-k8s-cluster -f -
333
332
  ```
334
333
 
335
334
  As soon as you run this, you'll start seeing some output being streamed to STDERR.
@@ -434,8 +433,7 @@ $ krane global-deploy my-k8s-context -f my-template.yml --selector app=krane
434
433
 
435
434
  Refer to `krane global-deploy help` for the authoritative set of options.
436
435
 
437
- - `--filenames / -if [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed
438
- - `--stdin`: Read from STDIN. Can be combined with `-f`
436
+ - `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed. Use `-` to specify STDIN.
439
437
  - `--no-prune`: Skips pruning of resources that are no longer in your Kubernetes template set. Not recommended, as it allows your namespace to accumulate cruft that is not reflected in your deploy directory.
440
438
  - `--selector`: Instructs krane to only prune resources which match the specified label selector, such as `environment=staging`. By using this option, all resource templates must specify matching labels. See [Sharing a namespace](#sharing-a-namespace) below.
441
439
  - `--global-timeout=duration`: Raise a timeout error if it takes longer than _duration_ for any
@@ -542,8 +540,7 @@ krane render -f ./path/to/template/dir/template.yaml.erb > template.yaml
542
540
 
543
541
  *Options:*
544
542
 
545
- - `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed.
546
- - `--stdin`: Read from STDIN. Can be combined with `-f` Example: `cat templates_from_stdin/*.yml | krane render -f path/to/dir path/to/file.yml --stdin`
543
+ - `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed. Use `-` to specify STDIN.
547
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`.
548
545
  - `--current-sha`: Expose SHA `current_sha` in ERB bindings
549
546
 
@@ -565,6 +562,9 @@ $ krane render --bindings='@config/production.json'
565
562
 
566
563
  # Load YAML file from ./config (.yaml or yml supported)
567
564
  $ krane render --bindings='@config/production.yaml'
565
+
566
+ # Load multiple files via a space separated string
567
+ $ krane render --bindings='@config/production.yaml' '@config/common.yaml'
568
568
  ```
569
569
 
570
570
  #### Using partials
data/bin/test CHANGED
@@ -41,7 +41,7 @@ bundle exec rake unit_test
41
41
  print_header "Run Non-Parallel Integration Tests"
42
42
  bundle exec rake serial_integration_test
43
43
 
44
- print_header "Run Parallel Integration Tests (N=$PARALLELISM)"
45
- PARALLELIZE_ME=1 N=$PARALLELISM bundle exec rake integration_test
44
+ print_header "Run Parallel Integration Tests (MT_CPU=$PARALLELISM)"
45
+ PARALLELIZE_ME=1 MT_CPU=$PARALLELISM bundle exec rake integration_test
46
46
 
47
47
  test $err -eq 0
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency("oj", "~> 3.0")
34
34
  spec.add_dependency("concurrent-ruby", "~> 1.1")
35
35
  spec.add_dependency("jsonpath", "~> 0.9.6")
36
- spec.add_dependency("thor", ">= 0.20.3", "< 2.0")
36
+ spec.add_dependency("thor", ">= 1.0", "< 2.0")
37
37
 
38
38
  # Basics
39
39
  spec.add_development_dependency("bundler")
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency("yard")
42
42
 
43
43
  # Test framework
44
- spec.add_development_dependency("minitest", "~> 5.0")
44
+ spec.add_development_dependency("minitest", "~> 5.12")
45
45
  spec.add_development_dependency("minitest-stub-const", "~> 0.6")
46
46
  spec.add_development_dependency("minitest-reporters")
47
47
  spec.add_development_dependency("mocha", "~> 1.5")
@@ -54,6 +54,6 @@ Gem::Specification.new do |spec|
54
54
  spec.add_development_dependency("byebug")
55
55
  spec.add_development_dependency("ruby-prof")
56
56
  spec.add_development_dependency("ruby-prof-flamegraph")
57
- spec.add_development_dependency("rubocop", "~> 0.76.0")
57
+ spec.add_development_dependency("rubocop", "~> 0.78.0")
58
58
  spec.add_development_dependency("codecov")
59
59
  end
@@ -14,7 +14,7 @@ module Krane
14
14
  aliases: :f, required: false, default: [],
15
15
  desc: "Directories and files that contains the configuration to apply" },
16
16
  "stdin" => { type: :boolean, default: false,
17
- desc: "Read resources from stdin" },
17
+ desc: "[DEPRECATED] Read resources from stdin" },
18
18
  "global-timeout" => { type: :string, banner: "duration", default: DEFAULT_DEPLOY_TIMEOUT,
19
19
  desc: "Max duration to monitor workloads correctly deployed" },
20
20
  "protected-namespaces" => { type: :array, banner: "namespace1 namespace2 namespaceN",
@@ -46,11 +46,10 @@ module Krane
46
46
  protected_namespaces = []
47
47
  end
48
48
 
49
- # never mutate options directly
50
49
  filenames = options[:filenames].dup
51
50
  filenames << "-" if options[:stdin]
52
51
  if filenames.empty?
53
- raise Thor::RequiredArgumentMissingError, 'At least one of --filenames or --stdin must be set'
52
+ raise(Thor::RequiredArgumentMissingError, '--filenames must be set and not empty')
54
53
  end
55
54
 
56
55
  ::Krane::OptionsHelper.with_processed_template_paths(filenames) do |paths|
@@ -8,7 +8,8 @@ module Krane
8
8
  "filenames" => { type: :array, banner: 'config/deploy/production config/deploy/my-extra-resource.yml',
9
9
  aliases: :f, required: false, default: [],
10
10
  desc: "Directories and files that contains the configuration to apply" },
11
- "stdin" => { type: :boolean, default: false, desc: "Read resources from stdin" },
11
+ "stdin" => { type: :boolean, default: false,
12
+ desc: "[DEPRECATED] Read resources from stdin" },
12
13
  "global-timeout" => { type: :string, banner: "duration", default: DEFAULT_DEPLOY_TIMEOUT,
13
14
  desc: "Max duration to monitor workloads correctly deployed" },
14
15
  "verify-result" => { type: :boolean, default: true,
@@ -28,11 +29,10 @@ module Krane
28
29
 
29
30
  selector = ::Krane::LabelSelector.parse(options[:selector])
30
31
 
31
- # never mutate options directly
32
32
  filenames = options[:filenames].dup
33
33
  filenames << "-" if options[:stdin]
34
34
  if filenames.empty?
35
- raise Thor::RequiredArgumentMissingError, 'At least one of --filenames or --stdin must be set'
35
+ raise(Thor::RequiredArgumentMissingError, '--filenames must be set and not empty')
36
36
  end
37
37
 
38
38
  ::Krane::OptionsHelper.with_processed_template_paths(filenames) do |paths|
@@ -7,7 +7,8 @@ module Krane
7
7
  "bindings" => { type: :array, banner: "foo=bar abc=def", desc: 'Bindings for erb' },
8
8
  "filenames" => { type: :array, banner: 'config/deploy/production config/deploy/my-extra-resource.yml',
9
9
  required: false, default: [], aliases: 'f', desc: 'Directories and files to render' },
10
- "stdin" => { type: :boolean, desc: "Read resources from stdin", default: false },
10
+ "stdin" => { type: :boolean, default: false,
11
+ desc: "[DEPRECATED] Read resources from stdin" },
11
12
  "current-sha" => { type: :string, banner: "SHA", desc: "Expose SHA `current_sha` in ERB bindings",
12
13
  lazy_default: '' },
13
14
  }
@@ -20,11 +21,10 @@ module Krane
20
21
  bindings_parser = ::Krane::BindingsParser.new
21
22
  options[:bindings]&.each { |b| bindings_parser.add(b) }
22
23
 
23
- # never mutate options directly
24
24
  filenames = options[:filenames].dup
25
25
  filenames << "-" if options[:stdin]
26
26
  if filenames.empty?
27
- raise Thor::RequiredArgumentMissingError, 'At least one of --filenames or --stdin must be set'
27
+ raise(Thor::RequiredArgumentMissingError, '--filenames must be set and not empty')
28
28
  end
29
29
 
30
30
  ::Krane::OptionsHelper.with_processed_template_paths(filenames, render_erb: true) do |paths|
@@ -85,7 +85,8 @@ module Krane
85
85
  def version_for_kind(versions, kind)
86
86
  # Override list for kinds that don't appear in the lastest version of a group
87
87
  version_override = { "CronJob" => "v1beta1", "VolumeAttachment" => "v1beta1",
88
- "CSIDriver" => "v1beta1", "Ingress" => "v1beta1", "CSINode" => "v1beta1" }
88
+ "CSIDriver" => "v1beta1", "Ingress" => "v1beta1",
89
+ "CSINode" => "v1beta1", "Job" => "v1" }
89
90
 
90
91
  pattern = /v(?<major>\d+)(?<pre>alpha|beta)?(?<minor>\d+)?/
91
92
  latest = versions.sort_by do |version|
@@ -3,7 +3,7 @@ module Krane
3
3
  class ContainerLogs
4
4
  attr_reader :lines, :container_name
5
5
 
6
- DEFAULT_LINE_LIMIT = 250
6
+ DEFAULT_LINE_LIMIT = 25
7
7
 
8
8
  def initialize(parent_id:, container_name:, namespace:, context:, logger:)
9
9
  @parent_id = parent_id
@@ -10,7 +10,6 @@ require 'krane/resource_cache'
10
10
  require 'krane/kubernetes_resource'
11
11
  %w(
12
12
  custom_resource
13
- cloudsql
14
13
  config_map
15
14
  deployment
16
15
  ingress
@@ -34,7 +34,16 @@ module Krane
34
34
  (1..attempts).to_a.each do |current_attempt|
35
35
  logger.debug("Running command (attempt #{current_attempt}): #{cmd.join(' ')}")
36
36
  out, err, st = Open3.capture3(*cmd)
37
- logger.debug("Kubectl out: " + out.gsub(/\s+/, ' ')) unless output_is_sensitive
37
+
38
+ # https://github.com/Shopify/krane/issues/395
39
+ unless out.valid_encoding?
40
+ out = out.dup.force_encoding(Encoding::UTF_8)
41
+ end
42
+
43
+ if logger.debug? && !output_is_sensitive
44
+ # don't do the gsub unless we're going to print this
45
+ logger.debug("Kubectl out: " + out.gsub(/\s+/, ' '))
46
+ end
38
47
 
39
48
  break if st.success?
40
49
  raise(ResourceNotFoundError, err) if err.match(ERROR_MATCHERS[:not_found]) && raise_if_not_found
@@ -219,14 +219,7 @@ module Krane
219
219
  limbo_reason = @status.dig("state", "waiting", "reason")
220
220
  limbo_message = @status.dig("state", "waiting", "message")
221
221
 
222
- if @status.dig("lastState", "terminated", "reason") == "ContainerCannotRun"
223
- # ref: https://github.com/kubernetes/kubernetes/blob/562e721ece8a16e05c7e7d6bdd6334c910733ab2/pkg/kubelet/dockershim/docker_container.go#L353
224
- exit_code = @status.dig('lastState', 'terminated', 'exitCode')
225
- "Failed to start (exit #{exit_code}): #{@status.dig('lastState', 'terminated', 'message')}"
226
- elsif @status.dig("state", "terminated", "reason") == "ContainerCannotRun"
227
- exit_code = @status.dig('state', 'terminated', 'exitCode')
228
- "Failed to start (exit #{exit_code}): #{@status.dig('state', 'terminated', 'message')}"
229
- elsif limbo_reason == "CrashLoopBackOff"
222
+ if limbo_reason == "CrashLoopBackOff"
230
223
  exit_code = @status.dig('lastState', 'terminated', 'exitCode')
231
224
  "Crashing repeatedly (exit #{exit_code}). See logs for more information."
232
225
  elsif limbo_reason == "ErrImagePull" && limbo_message.match(/not found/i)
@@ -234,6 +227,17 @@ module Krane
234
227
  "Did you wait for it to be built and pushed to the registry before deploying?"
235
228
  elsif limbo_reason == "CreateContainerConfigError"
236
229
  "Failed to generate container configuration: #{limbo_message}"
230
+ elsif @status.dig("lastState", "terminated", "reason") == "ContainerCannotRun"
231
+ # ref: https://github.com/kubernetes/kubernetes/blob/562e721ece8a16e05c7e7d6bdd6334c910733ab2/pkg/kubelet/dockershim/docker_container.go#L353
232
+ exit_code = @status.dig('lastState', 'terminated', 'exitCode')
233
+ # We've observed failures here that are actually issues with the node or kube infra, and not with the
234
+ # container. These issues have been transient and result in a 128 exit code, so do not treat these as fatal.
235
+ return if exit_code == 128
236
+ "Failed to start (exit #{exit_code}): #{@status.dig('lastState', 'terminated', 'message')}"
237
+ elsif @status.dig("state", "terminated", "reason") == "ContainerCannotRun"
238
+ exit_code = @status.dig('state', 'terminated', 'exitCode')
239
+ return if exit_code == 128
240
+ "Failed to start (exit #{exit_code}): #{@status.dig('state', 'terminated', 'message')}"
237
241
  end
238
242
  end
239
243
 
@@ -68,7 +68,7 @@ module Krane
68
68
  end
69
69
 
70
70
  def global_timeout?(started_at)
71
- @timeout && (Time.now.utc - started_at > @timeout)
71
+ @timeout && (Time.now.utc - started_at >= @timeout)
72
72
  end
73
73
 
74
74
  def sleep_until_next_sync(min_interval)
@@ -150,7 +150,7 @@ module Krane
150
150
 
151
151
  if rendering_erb_disabled? && deploying_with_erb_files?
152
152
  errors << "ERB template discovered with rendering disabled. If you were trying to render ERB and " \
153
- "deploy the result, try piping the output of `krane render` to `krane-deploy` with the --stdin flag"
153
+ "deploy the result, try piping the output of `krane render` to `krane-deploy -f -`"
154
154
  end
155
155
 
156
156
  errors
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Krane
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
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.1
4
+ version: 1.1.2
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-01-22 00:00:00.000000000 Z
13
+ date: 2020-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -150,7 +150,7 @@ dependencies:
150
150
  requirements:
151
151
  - - ">="
152
152
  - !ruby/object:Gem::Version
153
- version: 0.20.3
153
+ version: '1.0'
154
154
  - - "<"
155
155
  - !ruby/object:Gem::Version
156
156
  version: '2.0'
@@ -160,7 +160,7 @@ dependencies:
160
160
  requirements:
161
161
  - - ">="
162
162
  - !ruby/object:Gem::Version
163
- version: 0.20.3
163
+ version: '1.0'
164
164
  - - "<"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '2.0'
@@ -212,14 +212,14 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '5.0'
215
+ version: '5.12'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '5.0'
222
+ version: '5.12'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: minitest-stub-const
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -366,14 +366,14 @@ dependencies:
366
366
  requirements:
367
367
  - - "~>"
368
368
  - !ruby/object:Gem::Version
369
- version: 0.76.0
369
+ version: 0.78.0
370
370
  type: :development
371
371
  prerelease: false
372
372
  version_requirements: !ruby/object:Gem::Requirement
373
373
  requirements:
374
374
  - - "~>"
375
375
  - !ruby/object:Gem::Version
376
- version: 0.76.0
376
+ version: 0.78.0
377
377
  - !ruby/object:Gem::Dependency
378
378
  name: codecov
379
379
  requirement: !ruby/object:Gem::Requirement
@@ -398,7 +398,10 @@ extensions: []
398
398
  extra_rdoc_files: []
399
399
  files:
400
400
  - ".buildkite/pipeline.nightly.yml"
401
+ - ".github/CODEOWNERS"
402
+ - ".github/ISSUE_TEMPLATE.md"
401
403
  - ".github/probots.yml"
404
+ - ".github/pull_request_template.md"
402
405
  - ".gitignore"
403
406
  - ".rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml"
404
407
  - ".rubocop.yml"
@@ -409,7 +412,6 @@ files:
409
412
  - CODE_OF_CONDUCT.md
410
413
  - CONTRIBUTING.md
411
414
  - Gemfile
412
- - ISSUE_TEMPLATE.md
413
415
  - LICENSE.txt
414
416
  - README.md
415
417
  - Rakefile
@@ -447,7 +449,6 @@ files:
447
449
  - lib/krane/kubeclient_builder.rb
448
450
  - lib/krane/kubectl.rb
449
451
  - lib/krane/kubernetes_resource.rb
450
- - lib/krane/kubernetes_resource/cloudsql.rb
451
452
  - lib/krane/kubernetes_resource/config_map.rb
452
453
  - lib/krane/kubernetes_resource/cron_job.rb
453
454
  - lib/krane/kubernetes_resource/custom_resource.rb
@@ -489,7 +490,6 @@ files:
489
490
  - lib/krane/task_config_validator.rb
490
491
  - lib/krane/template_sets.rb
491
492
  - lib/krane/version.rb
492
- - pull_request_template.md
493
493
  - screenshots/deploy-demo.gif
494
494
  - screenshots/migrate-logs.png
495
495
  - screenshots/missing-secret-fail.png
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
- module Krane
3
- class Cloudsql < KubernetesResource
4
- TIMEOUT = 10.minutes
5
- SYNC_DEPENDENCIES = %w(Deployment Service)
6
-
7
- def sync(cache)
8
- super
9
- @proxy_deployment = cache.get_instance(Deployment.kind, "cloudsql-#{cloudsql_resource_uuid}")
10
- @proxy_service = cache.get_instance(Service.kind, "cloudsql-#{@name}")
11
- end
12
-
13
- def status
14
- deploy_succeeded? ? "Provisioned" : "Unknown"
15
- end
16
-
17
- def deploy_succeeded?
18
- proxy_deployment_ready? && proxy_service_ready?
19
- end
20
-
21
- def deploy_failed?
22
- false
23
- end
24
-
25
- private
26
-
27
- def proxy_deployment_ready?
28
- return false unless (status = @proxy_deployment["status"])
29
- # all cloudsql-proxy pods are running
30
- status.fetch("availableReplicas", -1) == status.fetch("replicas", 0)
31
- end
32
-
33
- def proxy_service_ready?
34
- return false unless @proxy_service.present?
35
- # the service has an assigned cluster IP and is therefore functioning
36
- @proxy_service.dig("spec", "clusterIP").present?
37
- end
38
-
39
- def cloudsql_resource_uuid
40
- return unless @instance_data
41
- @instance_data.dig("metadata", "uid")
42
- end
43
- end
44
- end