Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit dfa88c9

Browse files
authored
Merge pull request #15 from CSCfi/devel
bump version to 0.1.6
2 parents a17ae47 + 4338d97 commit dfa88c9

File tree

5 files changed

+49
-22
lines changed

5 files changed

+49
-22
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.7-alpine3.12 as BACKEND
1+
FROM python:3.8-alpine3.12 as BACKEND
22

33
RUN apk add --update \
44
&& apk add --no-cache build-base curl-dev linux-headers bash git\
@@ -13,15 +13,15 @@ RUN pip install --upgrade pip\
1313
&& pip install -r /root/swift_upload_runner/requirements.txt \
1414
&& pip install /root/swift_upload_runner
1515

16-
FROM python:3.7-alpine3.12
16+
FROM python:3.8-alpine3.12
1717

1818
RUN apk add --no-cache --update bash
1919

2020
LABEL maintainer "CSC Developers"
2121
LABEL org.label-schema.schema-version="1.0"
2222
LABEL org.label-schema.vcs-url="https://github.com/CSCFI/swift-upload-runner"
2323

24-
COPY --from=BACKEND /usr/local/lib/python3.7 /usr/local/lib/python3.7/
24+
COPY --from=BACKEND /usr/local/lib/python3.8 /usr/local/lib/python3.8/
2525

2626
COPY --from=BACKEND /usr/local/bin/gunicorn /usr/local/bin/
2727

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# Pick your license as you wish
4747
'License :: OSI Approved :: MIT License',
4848

49-
'Programming Language :: Python :: 3.6',
5049
'Programming Language :: Python :: 3.7',
50+
'Programming Language :: Python :: 3.8',
5151
],
5252
)

swift_upload_runner/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Runner for swift-browser-ui upload and replication operations."""
22

33
__name__ = "swift_upload_runner"
4-
__version__ = "0.1.5"
4+
__version__ = "0.1.6"
55
__author__ = "CSC Developers"
66
__license__ = "MIT License"

swift_upload_runner/replicate.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
import keystoneauth1.session
1111

1212
import swift_upload_runner.common as common
13-
13+
import ssl
14+
import certifi
1415

1516
LOGGER = logging.getLogger(__name__)
1617
LOGGER.setLevel(logging.DEBUG)
1718

19+
ssl_context = ssl.create_default_context()
20+
ssl_context.load_verify_locations(certifi.where())
21+
1822

1923
# The replication process needs a generous timeout, due to aiohttp having
2024
# a default value of 5 minutes. This is too low for the replication
@@ -81,7 +85,8 @@ async def a_create_container(
8185
headers={
8286
"Content-Length": str(0),
8387
"X-Auth-Token": self.auth.get_token()
84-
}
88+
},
89+
ssl=ssl_context
8590
) as resp:
8691
if resp.status not in {201, 202}:
8792
raise aiohttp.web.HTTPForbidden(
@@ -103,7 +108,8 @@ async def a_sync_object_segments(
103108
"X-Auth-Token": self.auth.get_token(),
104109
"Accept-Encoding": "identity"
105110
},
106-
timeout=REPL_TIMEOUT
111+
timeout=REPL_TIMEOUT,
112+
ssl=ssl_context
107113
) as resp:
108114
if resp.status == 404:
109115
raise aiohttp.web.HTTPNotFound(
@@ -140,7 +146,8 @@ async def a_sync_object_segments(
140146
"X-Auth-Token": self.auth.get_token(),
141147
"Accept-Encoding": "identity"
142148
},
143-
timeout=REPL_TIMEOUT
149+
timeout=REPL_TIMEOUT,
150+
ssl=ssl_context
144151
) as resp_g:
145152
length = int(resp_g.headers["Content-Length"])
146153
headers = {
@@ -166,7 +173,8 @@ async def a_sync_object_segments(
166173
to_url,
167174
data=self.a_generate_object_from_reader(resp_g),
168175
headers=headers,
169-
timeout=REPL_TIMEOUT
176+
timeout=REPL_TIMEOUT,
177+
ssl=ssl_context
170178
) as resp_p:
171179
LOGGER.debug(f"Segment {segment} status {resp_p.status}")
172180
if resp_p.status == 408:
@@ -197,7 +205,8 @@ async def a_copy_object(
197205
"X-Auth-Token": self.auth.get_token(),
198206
"Accept-Encoding": "identity"
199207
},
200-
timeout=REPL_TIMEOUT
208+
timeout=REPL_TIMEOUT,
209+
ssl=ssl_context
201210
) as resp_g:
202211
# If the source object doesn't exist, abort
203212
if resp_g.status != 200:
@@ -236,7 +245,8 @@ async def a_copy_object(
236245
),
237246
data=self.a_generate_object_from_reader(resp_g),
238247
headers=headers,
239-
timeout=REPL_TIMEOUT
248+
timeout=REPL_TIMEOUT,
249+
ssl=ssl_context
240250
) as resp_p:
241251
if resp_p.status == 408:
242252
raise aiohttp.web.HTTPRequestTimeout()
@@ -267,7 +277,8 @@ async def a_copy_object(
267277
),
268278
data=b"",
269279
headers=headers,
270-
timeout=REPL_TIMEOUT
280+
timeout=REPL_TIMEOUT,
281+
ssl=ssl_context
271282
) as resp:
272283
if resp.status != 201:
273284
raise aiohttp.web.HTTPInternalServerError(
@@ -294,7 +305,8 @@ async def a_copy_from_container(self) -> None:
294305
headers={
295306
"X-Auth-Token": self.auth.get_token()
296307
},
297-
timeout=REPL_TIMEOUT
308+
timeout=REPL_TIMEOUT,
309+
ssl=ssl_context
298310
) as resp:
299311
if resp.status != 200:
300312
LOGGER.debug(

swift_upload_runner/upload.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
import swift_upload_runner.common as common
1515

16+
import ssl
17+
import certifi
18+
19+
20+
ssl_context = ssl.create_default_context()
21+
ssl_context.load_verify_locations(certifi.where())
22+
1623

1724
LOGGER = logging.getLogger(__name__)
1825
LOGGER.setLevel(logging.DEBUG)
@@ -94,6 +101,7 @@ async def a_sync_segments(
94101
headers={
95102
"X-Auth-Token": self.auth.get_token()
96103
},
104+
ssl=ssl_context
97105
) as resp:
98106
if resp.status in {200}:
99107
segments = await resp.text()
@@ -121,7 +129,8 @@ async def a_create_container(
121129
headers={
122130
"Content-Length": str(0),
123131
"X-Auth-Token": self.auth.get_token()
124-
}
132+
},
133+
ssl=ssl_context
125134
) as resp:
126135
if resp.status not in {201, 202}:
127136
raise aiohttp.web.HTTPForbidden(
@@ -139,7 +148,8 @@ async def a_check_container(
139148
),
140149
headers={
141150
"X-Auth-Token": self.auth.get_token()
142-
}
151+
},
152+
ssl=ssl_context
143153
) as resp:
144154
if resp.status != 204:
145155
if self.project != self.auth.get_project_id():
@@ -155,7 +165,8 @@ async def a_check_container(
155165
),
156166
headers={
157167
"X-Auth-Token": self.auth.get_token()
158-
}
168+
},
169+
ssl=ssl_context
159170
) as resp:
160171
if resp.status != 204:
161172
if self.project != self.auth.get_project_id():
@@ -176,7 +187,8 @@ async def a_check_segment(
176187
self.url,
177188
headers={
178189
"X-Auth-Token": self.auth.get_token()
179-
}
190+
},
191+
ssl=ssl_context
180192
) as request:
181193
if request.status == 200:
182194
return aiohttp.web.Response(status=200)
@@ -201,7 +213,8 @@ async def a_add_manifest(
201213
headers={
202214
"X-Auth-Token": self.auth.get_token(),
203215
"X-Object-Manifest": manifest
204-
}
216+
},
217+
ssl=ssl_context
205218
) as resp:
206219
if resp.status != 201:
207220
raise aiohttp.web.HTTPBadRequest()
@@ -232,7 +245,8 @@ async def a_add_chunk(
232245
"Content-Length": query["resumableCurrentChunkSize"],
233246
"Content-Type": "application/swiftclient-segment",
234247
},
235-
timeout=UPL_TIMEOUT
248+
timeout=UPL_TIMEOUT,
249+
ssl=ssl_context
236250
) as resp:
237251
if resp.status == 408:
238252
raise aiohttp.web.HTTPRequestTimeout()
@@ -243,7 +257,7 @@ async def a_add_chunk(
243257
LOGGER.debug(f"Success in uploding chunk {chunk_number}")
244258
return aiohttp.web.Response(status=201)
245259
else:
246-
LOGGER.debug(f"Concatenatig chunk {chunk_number}")
260+
LOGGER.debug(f"Concatenating chunk {chunk_number}")
247261
await self.q.put((
248262
# Using chunk number as priority, to handle chunks in any
249263
# order
@@ -272,7 +286,8 @@ async def upload_file(self) -> None:
272286
"X-Auth-Token": self.auth.get_token(),
273287
"Content-Length": str(self.total_size),
274288
},
275-
timeout=UPL_TIMEOUT
289+
timeout=UPL_TIMEOUT,
290+
ssl=ssl_context
276291
) as resp:
277292
if resp.status == 408:
278293
raise aiohttp.web.HTTPRequestTimeout()

0 commit comments

Comments
 (0)