Skip to content

Commit 280e4da

Browse files
Anandaraju Coimbatore SivarajuAlena Kastsiukavets
authored andcommitted
[Agent 1.1.2] COE AI to fix unzip fallback to ruby unzip util
Why is this change needed? --------- Prior to this change, customers had issue with fallback to ruby unzip util, because there were partially unzipped files and ruby unzip didn't override them. How does it address the issue? --------- This change will rescue any exit code other than 0 and use override parameter set to true, so it would not throw Zip::DestinationFileExistsError during ruby unzip
1 parent 71cb2c6 commit 280e4da

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

lib/instance_agent/platform/linux_util.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,12 @@ def self.execute_zip_command(cmd)
133133
log(:debug, "Command status: #{$?}")
134134
log(:debug, "Command output: #{output}")
135135

136-
if !validZipExitStatus(exit_status)
136+
if exit_status != 0
137137
msg = "Error extracting zip archive: #{exit_status}"
138138
log(:error, msg)
139139
raise msg
140140
end
141141
end
142-
143-
private
144-
def self.validZipExitStatus(exit_status)
145-
exit_status == 0 || isWarningStatus(exit_status)
146-
end
147-
148-
private
149-
def self.isWarningStatus(exit_status)
150-
exit_status == 1
151-
end
152142

153143
private
154144
def self.log(severity, message)

lib/instance_agent/plugins/codedeploy/command_executor.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,16 @@ def unpack_bundle(cmd, bundle_file, deployment_spec)
384384
begin
385385
InstanceAgent::Platform.util.extract_zip(bundle_file, dst)
386386
rescue
387+
log(:warn, "Encountered non-zero exit code with default system unzip util. Hence falling back to ruby unzip to mitigate any partially unzipped or skipped zip files.")
387388
Zip::File.open(bundle_file) do |zipfile|
388389
zipfile.each do |f|
389390
file_dst = File.join(dst, f.name)
390391
FileUtils.mkdir_p(File.dirname(file_dst))
391-
zipfile.extract(f, file_dst)
392+
zipfile.extract(f, file_dst) { true }
392393
end
393394
end
394395
end
395396
else
396-
# If the bundle was a generated through a Sabini Repository
397-
# it will be in tar format, and it won't have a bundle type
398397
InstanceAgent::Platform.util.extract_tar(bundle_file, dst)
399398
end
400399

0 commit comments

Comments
 (0)