Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified Dockerfile Image for Spark Jobs #174

Merged
merged 2 commits into from
Mar 8, 2023

Conversation

tushartathgur
Copy link
Contributor

@tushartathgur tushartathgur commented Mar 2, 2023

Currently Theia supports separate docker files for anomalydetector and policyrecommendation, this PR helps unify these docker files resulting into lesser storage space.

  • Unified Docker image now uses 1.4 GB of image space than earlier 2.4GB combined
  • Spark Jobs constants have been moved under utils.go in order to avoid duplicity of constants

Solve #161

@elton-furtado
Copy link
Contributor

Can you update the documentation to reflect the changes?

@tushartathgur tushartathgur force-pushed the unified_dockerfile branch 3 times, most recently from 470ad43 to bd70023 Compare March 4, 2023 00:02
@tushartathgur tushartathgur added this to the Theia v0.5 release milestone Mar 6, 2023
COPY plugins/policy-recommendation/policy_recommendation_job.py /opt/spark/work-dir/policy_recommendation_job.py
COPY plugins/policy-recommendation/policy_recommendation_utils.py /opt/spark/work-dir/policy_recommendation_utils.py
COPY plugins/policy-recommendation/antrea_crd.py /opt/spark/work-dir/antrea_crd.py
COPY plugins/anomaly-detection/AnomalyDetection.py /opt/spark/work-dir/AnomalyDetection.py
COPY plugins/anomaly-detection/requirements.txt /opt/spark/work-dir/requirements.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's have a dedicated filename for anomaly-detection/requirements.txt, since there might be other requirements.txt for future spark jobs.

RUN pip3 install --upgrade pip && \
pip3 install pyyaml && \
pip3 install kubernetes && \
pip3 install -r /opt/spark/work-dir/requirements.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent alignment

@@ -1,7 +1,7 @@
FROM gcr.io/spark-operator/spark-py:v3.1.1

LABEL maintainer="Antrea <[email protected]>"
LABEL description="A docker image to deploy policy recommendation Spark job."
LABEL description="A docker image to deploy policy recommendation and throughput anomaly detector Spark job."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detector->detection

Copy link
Contributor

@yanjunz97 yanjunz97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM


check-policy-recommendation-changes:
name: Check whether policy-recommendation image needs to be built based on diff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Remove the extra spaces?

RUN pip3 install --upgrade pip && \
pip3 install pyyaml && \
pip3 install kubernetes && \
pip3 install -r /opt/spark/work-dir/requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pip3 install -r /opt/spark/work-dir/requirements.txt
pip3 install -r /opt/spark/work-dir/requirements.txt

Extra space

@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

3 similar comments
@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

Copy link
Contributor

@yanjunz97 yanjunz97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please remember to edit your commit message merging. I guess "startTime: 2022-08-24T10:45:57Z" is added unexpectedly?

    Currently Theia supports separate dockerfiles for anomalydetector
and policyrecommendation, this PR helps unify these dockerfiles
resulting into lesser storage space.
    Unified Dockerimage now uses 1.4 GB of image space than earlier
2.4GB combined
    Spark Jobs constants have been moved under utils.go in order to
avoid duplicacy of constants

Solve #161

Signed-off-by: Tushar Tathgur <[email protected]>
@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

@codecov
Copy link

codecov bot commented Mar 7, 2023

Codecov Report

Merging #174 (557cd9a) into main (165ae97) will decrease coverage by 0.17%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #174      +/-   ##
==========================================
- Coverage   52.97%   52.80%   -0.17%     
==========================================
  Files          74       78       +4     
  Lines        5720     6692     +972     
  Branches       41        0      -41     
==========================================
+ Hits         3030     3534     +504     
- Misses       2379     2852     +473     
+ Partials      311      306       -5     
Flag Coverage Δ
unit-tests 51.92% <100.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/controller/util.go 48.68% <ø> (ø)
plugins/anomaly-detection/anomaly_detection.py 49.79% <ø> (ø)
pkg/controller/anomalydetector/controller.go 77.66% <100.00%> (ø)
...ntroller/networkpolicyrecommendation/controller.go 71.31% <100.00%> (ø)
...lugins/anomaly-detection/anomaly_detection_test.py 91.66% <100.00%> (ø)
pkg/apiserver/certificate/certificate.go 70.37% <0.00%> (-6.49%) ⬇️
...-plugins/grafana-sankey-plugin/src/SankeyPanel.tsx
...om-plugins/grafana-chord-plugin/src/ChordPanel.tsx
...licy-recommendation/policy_recommendation_utils.py 73.68% <0.00%> (ø)
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link

@dreamtalen dreamtalen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You can merge this pull request once you fix the file name issue and the test passes. Thanks for your work.

COPY plugins/policy-recommendation/policy_recommendation_job.py /opt/spark/work-dir/policy_recommendation_job.py
COPY plugins/policy-recommendation/policy_recommendation_utils.py /opt/spark/work-dir/policy_recommendation_utils.py
COPY plugins/policy-recommendation/antrea_crd.py /opt/spark/work-dir/antrea_crd.py
COPY plugins/anomaly-detection/AnomalyDetection.py /opt/spark/work-dir/AnomalyDetection.py
COPY plugins/anomaly-detection/requirements.txt /opt/spark/work-dir/anomaly_detector_requirements.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: follow our naming convention of python files, AnomalyDetection.py -> anomaly_detection.py, anomaly_detector_requirements.txt -> anomaly_detection_requirements.txt.

@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

2 similar comments
@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

@tushartathgur
Copy link
Contributor Author

/theia-test-e2e

@tushartathgur tushartathgur merged commit 4ddf56b into antrea-io:main Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants