Skip to content

Commit

Permalink
Merge pull request #750 from netgroup-polito/qcfe/strict-content-uplo…
Browse files Browse the repository at this point in the history
…ader
  • Loading branch information
kingmakerbot authored Feb 11, 2022
2 parents 5ca4899 + 5d3e6ba commit ae4776e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions operators/pkg/forge/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const (
HealthzEndpoint = "/healthz"
// CrownLabsUserID -> used as UID and GID for containers security context.
CrownLabsUserID = int64(1010)
// SubmissionJobMaxRetries -> max number of retries for submission jobs.
SubmissionJobMaxRetries = 10

containersTerminationGracePeriod = 10
)
Expand Down Expand Up @@ -151,6 +153,7 @@ func PodSpec(instance *clv1alpha2.Instance, environment *clv1alpha2.Environment,
// SubmissionJobSpec returns the job spec for the submission job.
func SubmissionJobSpec(instance *clv1alpha2.Instance, environment *clv1alpha2.Environment, opts *ContainerEnvOpts) batchv1.JobSpec {
return batchv1.JobSpec{
BackoffLimit: pointer.Int32(SubmissionJobMaxRetries),
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
Expand Down
1 change: 1 addition & 0 deletions operators/pkg/forge/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ var _ = Describe("Containers and Deployment spec forging", func() {

It("should return the correct podSpecification", func() {
Expect(actual).To(Equal(batchv1.JobSpec{
BackoffLimit: pointer.Int32Ptr(forge.SubmissionJobMaxRetries),
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
Expand Down
8 changes: 7 additions & 1 deletion provisioning/containers/utils/content-uploader/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ cd "$SOURCE_PATH"
zip "/tmp/$FILENAME.zip" -r .

echo "Uploading archive..."
curl -v --fail --request POST --form "binfile=@\"/tmp/$FILENAME.zip\"" --form "filename=$FILENAME.zip" "$DESTINATION_URL"
HTTP_CODE=$(curl -v --request --fail POST --form "binfile=@\"/tmp/$FILENAME.zip\"" --form "filename=$FILENAME.zip" "$DESTINATION_URL" --write-out "%{http_code}")

# return non zero if HTTP_CODE is less than 200 or greater equal than 300
if [ "$HTTP_CODE" -lt "200" ] || [ "$HTTP_CODE" -ge "300" ]; then
echo "Upload failed with HTTP code $HTTP_CODE"
exit 1
fi

0 comments on commit ae4776e

Please sign in to comment.