floe 0.6.0 → 0.6.1

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: 58ace49051c911efbe352b2b882cc663aea3be231e6c8dcf138864e340ae2de6
4
- data.tar.gz: d422be1ce106663dd1dc40b7ddb52024f9eb9b0e85f807572d66f31fcdf16e51
3
+ metadata.gz: b92b3c488e49ea77447b370e9152c49e11036e8295c6a781feda666662927f9e
4
+ data.tar.gz: c553deab6491c9876e28a816cb2422a1318ac6f91a9f9f75cbfc5a144a84d248
5
5
  SHA512:
6
- metadata.gz: e5eab9d1763c723d8bb913e31bb736d0ba3c3e6d6d63585031e30adc5cbd3049105c756b89eee6999df2d6a0dcfd35e6a1ae4a39c10ce949387e91aae30acf32
7
- data.tar.gz: 3249cce513b7195ce5ed791c300d9df62159febeb522c45db36dda38244c76f9290af3157ac744fa0757417ce327f95eea80c704375310ed3181e05426208e3b
6
+ metadata.gz: 3f5c210d2a745aaed8e3419e228465203dcebb02ee678c1d2b47285083e1f154118c25864e51360d3d062ca0cfade9baa84f5a932804b586f26607a195acc710
7
+ data.tar.gz: 238fd469915e8682c449abd26e1950f68fd4b032a32fcace11130109d46dc6962b29e4ce381734d167f5328ef16ee2fdd4bb250f844644abebc571fc001ab2dd
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.6.1] - 2023-11-21
8
+ ### Fixed
9
+ - Return an error payload if run_async! fails ([#143](https://github.com/ManageIQ/floe/pull/143))
10
+
11
+ ### Changed
12
+ - Extract run_container_params for docker/podman ([#142](https://github.com/ManageIQ/floe/pull/142))
13
+
7
14
  ## [0.6.0] - 2023-11-09
8
15
  ### Added
9
16
  - Prefix pod names with 'floe-' ([#132](https://github.com/ManageIQ/floe/pull/132))
@@ -99,7 +106,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99
106
  ### Added
100
107
  - Initial release
101
108
 
102
- [Unreleased]: https://github.com/ManageIQ/floe/compare/v0.6.0...HEAD
109
+ [Unreleased]: https://github.com/ManageIQ/floe/compare/v0.6.1...HEAD
110
+ [0.6.1]: https://github.com/ManageIQ/floe/compare/v0.6.0...v0.6.1
103
111
  [0.6.0]: https://github.com/ManageIQ/floe/compare/v0.5.0...v0.6.0
104
112
  [0.5.0]: https://github.com/ManageIQ/floe/compare/v0.4.1...v0.5.0
105
113
  [0.4.1]: https://github.com/ManageIQ/floe/compare/v0.4.0...v0.4.1
data/lib/floe/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Floe
4
- VERSION = "0.6.0".freeze
4
+ VERSION = "0.6.1".freeze
5
5
  end
@@ -30,12 +30,11 @@ module Floe
30
30
 
31
31
  begin
32
32
  runner_context["container_ref"] = run_container(image, env, runner_context["secrets_ref"])
33
- rescue
33
+ runner_context
34
+ rescue AwesomeSpawn::CommandResultError => err
34
35
  cleanup(runner_context)
35
- raise
36
+ {"Error" => "States.TaskFailed", "Cause" => err.to_s}
36
37
  end
37
-
38
- runner_context
39
38
  end
40
39
 
41
40
  def cleanup(runner_context)
@@ -46,11 +45,13 @@ module Floe
46
45
  end
47
46
 
48
47
  def status!(runner_context)
48
+ return if runner_context.key?("Error")
49
+
49
50
  runner_context["container_state"] = inspect_container(runner_context["container_ref"]).first&.dig("State")
50
51
  end
51
52
 
52
53
  def running?(runner_context)
53
- runner_context.dig("container_state", "Running")
54
+ !!runner_context.dig("container_state", "Running")
54
55
  end
55
56
 
56
57
  def success?(runner_context)
@@ -58,6 +59,8 @@ module Floe
58
59
  end
59
60
 
60
61
  def output(runner_context)
62
+ return runner_context.slice("Error", "Cause") if runner_context.key?("Error")
63
+
61
64
  output = docker!("logs", runner_context["container_ref"], :combined_output => true).output
62
65
  runner_context["output"] = output
63
66
  end
@@ -67,6 +70,15 @@ module Floe
67
70
  attr_reader :network
68
71
 
69
72
  def run_container(image, env, secrets_file)
73
+ params = run_container_params(image, env, secrets_file)
74
+
75
+ logger.debug("Running #{AwesomeSpawn.build_command_line("docker", params)}")
76
+
77
+ result = docker!(*params)
78
+ result.output
79
+ end
80
+
81
+ def run_container_params(image, env, secrets_file)
70
82
  params = ["run"]
71
83
  params << :detach
72
84
  params += env.map { |k, v| [:e, "#{k}=#{v}"] }
@@ -75,11 +87,6 @@ module Floe
75
87
  params << [:v, "#{secrets_file}:/run/secrets:z"] if secrets_file
76
88
  params << [:name, container_name(image)]
77
89
  params << image
78
-
79
- logger.debug("Running docker: #{AwesomeSpawn.build_command_line("docker", params)}")
80
-
81
- result = docker!(*params)
82
- result.output
83
90
  end
84
91
 
85
92
  def inspect_container(container_id)
@@ -56,15 +56,16 @@ module Floe
56
56
 
57
57
  begin
58
58
  create_pod!(name, image, env, secret)
59
- rescue
59
+ runner_context
60
+ rescue Kubeclient::HttpError => err
60
61
  cleanup(runner_context)
61
- raise
62
+ {"Error" => "States.TaskFailed", "Cause" => err.to_s}
62
63
  end
63
-
64
- runner_context
65
64
  end
66
65
 
67
66
  def status!(runner_context)
67
+ return if runner_context.key?("Error")
68
+
68
69
  runner_context["container_state"] = pod_info(runner_context["container_ref"]).to_h.deep_stringify_keys["status"]
69
70
  end
70
71
 
@@ -83,13 +84,14 @@ module Floe
83
84
  end
84
85
 
85
86
  def output(runner_context)
86
- runner_context["output"] =
87
- if container_failed?(runner_context)
88
- failed_state = failed_container_states(runner_context).first
89
- {"Error" => failed_state["reason"], "Cause" => failed_state["message"]}
90
- else
91
- kubeclient.get_pod_log(runner_context["container_ref"], namespace).body
92
- end
87
+ if runner_context.key?("Error")
88
+ runner_context.slice("Error", "Cause")
89
+ elsif container_failed?(runner_context)
90
+ failed_state = failed_container_states(runner_context).first
91
+ {"Error" => failed_state["reason"], "Cause" => failed_state["message"]}
92
+ else
93
+ runner_context["output"] = kubeclient.get_pod_log(runner_context["container_ref"], namespace).body
94
+ end
93
95
  end
94
96
 
95
97
  def cleanup(runner_context)
@@ -30,7 +30,7 @@ module Floe
30
30
 
31
31
  private
32
32
 
33
- def run_container(image, env, secret)
33
+ def run_container_params(image, env, secret)
34
34
  params = ["run"]
35
35
  params << :detach
36
36
  params += env.map { |k, v| [:e, "#{k}=#{v}"] }
@@ -39,11 +39,6 @@ module Floe
39
39
  params << [:secret, secret] if secret
40
40
  params << [:name, container_name(image)]
41
41
  params << image
42
-
43
- logger.debug("Running podman: #{AwesomeSpawn.build_command_line("podman", params)}")
44
-
45
- result = podman!(*params)
46
- result.output
47
42
  end
48
43
 
49
44
  def create_secret(secrets)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: floe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_spawn