Skip to content

Commit af11b8c

Browse files
authored
Merge pull request #1672 from wazuh/merge-4.11.0-into-4.12.0
2 parents 6a3b470 + 77ef56a commit af11b8c

File tree

5 files changed

+264
-26
lines changed

5 files changed

+264
-26
lines changed

Diff for: .github/free-disk-space/action.yml

+245
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
name: "Free Disk Space (Ubuntu)"
2+
description: "A configurable GitHub Action to free up disk space on an Ubuntu GitHub Actions runner."
3+
4+
# Thanks @jlumbroso for the action code https://github.com/jlumbroso/free-disk-space/
5+
# See: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#branding
6+
7+
inputs:
8+
android:
9+
description: "Remove Android runtime"
10+
required: false
11+
default: "true"
12+
dotnet:
13+
description: "Remove .NET runtime"
14+
required: false
15+
default: "true"
16+
haskell:
17+
description: "Remove Haskell runtime"
18+
required: false
19+
default: "true"
20+
21+
# option inspired by:
22+
# https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
23+
large-packages:
24+
description: "Remove large packages"
25+
required: false
26+
default: "true"
27+
28+
docker-images:
29+
description: "Remove Docker images"
30+
required: false
31+
default: "true"
32+
33+
# option inspired by:
34+
# https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
35+
tool-cache:
36+
description: "Remove image tool cache"
37+
required: false
38+
default: "false"
39+
40+
swap-storage:
41+
description: "Remove swap storage"
42+
required: false
43+
default: "true"
44+
45+
runs:
46+
using: "composite"
47+
steps:
48+
- shell: bash
49+
run: |
50+
51+
# ======
52+
# MACROS
53+
# ======
54+
55+
# macro to print a line of equals
56+
# (silly but works)
57+
printSeparationLine() {
58+
str=${1:=}
59+
num=${2:-80}
60+
counter=1
61+
output=""
62+
while [ $counter -le $num ]
63+
do
64+
output="${output}${str}"
65+
counter=$((counter+1))
66+
done
67+
echo "${output}"
68+
}
69+
70+
# macro to compute available space
71+
# REF: https://unix.stackexchange.com/a/42049/60849
72+
# REF: https://stackoverflow.com/a/450821/408734
73+
getAvailableSpace() { echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}'); }
74+
75+
# macro to make Kb human readable (assume the input is Kb)
76+
# REF: https://unix.stackexchange.com/a/44087/60849
77+
formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); }
78+
79+
# macro to output saved space
80+
printSavedSpace() {
81+
saved=${1}
82+
title=${2:-}
83+
84+
echo ""
85+
printSeparationLine '*' 80
86+
if [ ! -z "${title}" ]; then
87+
echo "=> ${title}: Saved $(formatByteCount $saved)"
88+
else
89+
echo "=> Saved $(formatByteCount $saved)"
90+
fi
91+
printSeparationLine '*' 80
92+
echo ""
93+
}
94+
95+
# macro to print output of dh with caption
96+
printDH() {
97+
caption=${1:-}
98+
99+
printSeparationLine '=' 80
100+
echo "${caption}"
101+
echo ""
102+
echo "$ dh -h /"
103+
echo ""
104+
df -h /
105+
echo "$ dh -a /"
106+
echo ""
107+
df -a /
108+
echo "$ dh -a"
109+
echo ""
110+
df -a
111+
printSeparationLine '=' 80
112+
}
113+
114+
115+
116+
# ======
117+
# SCRIPT
118+
# ======
119+
120+
# Display initial disk space stats
121+
122+
AVAILABLE_INITIAL=$(getAvailableSpace)
123+
AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/')
124+
125+
printDH "BEFORE CLEAN-UP:"
126+
echo ""
127+
128+
129+
# Option: Remove Android library
130+
131+
if [[ ${{ inputs.android }} == 'true' ]]; then
132+
BEFORE=$(getAvailableSpace)
133+
134+
sudo rm -rf /usr/local/lib/android || true
135+
136+
AFTER=$(getAvailableSpace)
137+
SAVED=$((AFTER-BEFORE))
138+
printSavedSpace $SAVED "Android library"
139+
fi
140+
141+
# Option: Remove .NET runtime
142+
143+
if [[ ${{ inputs.dotnet }} == 'true' ]]; then
144+
BEFORE=$(getAvailableSpace)
145+
146+
# https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
147+
sudo rm -rf /usr/share/dotnet || true
148+
149+
AFTER=$(getAvailableSpace)
150+
SAVED=$((AFTER-BEFORE))
151+
printSavedSpace $SAVED ".NET runtime"
152+
fi
153+
154+
# Option: Remove Haskell runtime
155+
156+
if [[ ${{ inputs.haskell }} == 'true' ]]; then
157+
BEFORE=$(getAvailableSpace)
158+
159+
sudo rm -rf /opt/ghc || true
160+
sudo rm -rf /usr/local/.ghcup || true
161+
162+
AFTER=$(getAvailableSpace)
163+
SAVED=$((AFTER-BEFORE))
164+
printSavedSpace $SAVED "Haskell runtime"
165+
fi
166+
167+
# Option: Remove large packages
168+
# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
169+
170+
if [[ ${{ inputs.large-packages }} == 'true' ]]; then
171+
BEFORE=$(getAvailableSpace)
172+
173+
sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..."
174+
sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..."
175+
sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..."
176+
sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..."
177+
sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..."
178+
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..."
179+
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..."
180+
sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..."
181+
sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..."
182+
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..."
183+
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."
184+
185+
AFTER=$(getAvailableSpace)
186+
SAVED=$((AFTER-BEFORE))
187+
printSavedSpace $SAVED "Large misc. packages"
188+
fi
189+
190+
# Option: Remove Docker images
191+
192+
if [[ ${{ inputs.docker-images }} == 'true' ]]; then
193+
BEFORE=$(getAvailableSpace)
194+
195+
sudo docker image prune --all --force || true
196+
197+
AFTER=$(getAvailableSpace)
198+
SAVED=$((AFTER-BEFORE))
199+
printSavedSpace $SAVED "Docker images"
200+
fi
201+
202+
# Option: Remove tool cache
203+
# REF: https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
204+
205+
if [[ ${{ inputs.tool-cache }} == 'true' ]]; then
206+
BEFORE=$(getAvailableSpace)
207+
208+
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
209+
210+
AFTER=$(getAvailableSpace)
211+
SAVED=$((AFTER-BEFORE))
212+
printSavedSpace $SAVED "Tool cache"
213+
fi
214+
215+
# Option: Remove Swap storage
216+
217+
if [[ ${{ inputs.swap-storage }} == 'true' ]]; then
218+
BEFORE=$(getAvailableSpace)
219+
220+
sudo swapoff -a || true
221+
sudo rm -f /mnt/swapfile || true
222+
free -h
223+
224+
AFTER=$(getAvailableSpace)
225+
SAVED=$((AFTER-BEFORE))
226+
printSavedSpace $SAVED "Swap storage"
227+
fi
228+
229+
230+
231+
# Output saved space statistic
232+
233+
AVAILABLE_END=$(getAvailableSpace)
234+
AVAILABLE_ROOT_END=$(getAvailableSpace '/')
235+
236+
echo ""
237+
printDH "AFTER CLEAN-UP:"
238+
239+
echo ""
240+
echo ""
241+
242+
echo "/dev/root:"
243+
printSavedSpace $((AVAILABLE_ROOT_END - AVAILABLE_ROOT_INITIAL))
244+
echo "overall:"
245+
printSavedSpace $((AVAILABLE_END - AVAILABLE_INITIAL))

Diff for: .github/workflows/Procedure_push_docker_images.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
description: 'wazuh-docker reference'
1313
default: 'v4.12.0'
1414
required: true
15-
PRODUCTS:
15+
products:
1616
description: 'Comma-separated list of the image names to build and push'
1717
default: 'wazuh-manager,wazuh-dashboard,wazuh-indexer'
1818
required: true
@@ -42,12 +42,12 @@ on:
4242
inputs:
4343
image_tag:
4444
description: 'Docker image tag'
45-
default: '4.10.0'
45+
default: '4.12.0'
4646
required: true
4747
type: string
4848
docker_reference:
4949
description: 'wazuh-docker reference'
50-
default: 'v4.10.0'
50+
default: 'v4.12.0'
5151
required: false
5252
type: string
5353
products:

Diff for: .github/workflows/push.yml

+10-15
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ jobs:
2929
docker save wazuh/wazuh-dashboard:${{env.WAZUH_IMAGE_VERSION}} -o /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-dashboard.tar
3030
3131
- name: Temporarily save Wazuh manager Docker image
32-
uses: actions/upload-artifact@v3
32+
uses: actions/upload-artifact@v4
3333
with:
3434
name: docker-artifact-manager
3535
path: /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-manager.tar
3636
retention-days: 1
3737

3838
- name: Temporarily save Wazuh indexer Docker image
39-
uses: actions/upload-artifact@v3
39+
uses: actions/upload-artifact@v4
4040
with:
4141
name: docker-artifact-indexer
4242
path: /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-indexer.tar
4343
retention-days: 1
4444

4545
- name: Temporarily save Wazuh dashboard Docker image
46-
uses: actions/upload-artifact@v3
46+
uses: actions/upload-artifact@v4
4747
with:
4848
name: docker-artifact-dashboard
4949
path: /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-dashboard.tar
@@ -77,17 +77,17 @@ jobs:
7777
run: cat .env > $GITHUB_ENV
7878

7979
- name: Retrieve saved Wazuh indexer Docker image
80-
uses: actions/download-artifact@v3
80+
uses: actions/download-artifact@v4
8181
with:
8282
name: docker-artifact-indexer
8383

8484
- name: Retrieve saved Wazuh manager Docker image
85-
uses: actions/download-artifact@v3
85+
uses: actions/download-artifact@v4
8686
with:
8787
name: docker-artifact-manager
8888

8989
- name: Retrieve saved Wazuh dashboard Docker image
90-
uses: actions/download-artifact@v3
90+
uses: actions/download-artifact@v4
9191
with:
9292
name: docker-artifact-dashboard
9393

@@ -205,25 +205,20 @@ jobs:
205205
run: cat .env > $GITHUB_ENV
206206

207207
- name: free disk space
208-
run: |
209-
sudo swapoff -a
210-
sudo rm -f /swapfile
211-
sudo apt clean
212-
docker rmi $(docker image ls -aq)
213-
df -h
208+
uses: ./.github/free-disk-space
214209

215210
- name: Retrieve saved Wazuh dashboard Docker image
216-
uses: actions/download-artifact@v3
211+
uses: actions/download-artifact@v4
217212
with:
218213
name: docker-artifact-dashboard
219214

220215
- name: Retrieve saved Wazuh manager Docker image
221-
uses: actions/download-artifact@v3
216+
uses: actions/download-artifact@v4
222217
with:
223218
name: docker-artifact-manager
224219

225220
- name: Retrieve saved Wazuh indexer Docker image
226-
uses: actions/download-artifact@v3
221+
uses: actions/download-artifact@v4
227222
with:
228223
name: docker-artifact-indexer
229224

Diff for: CHANGELOG.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55

66
### Added
77

8-
- none
8+
- None
99

1010
### Changed
1111

@@ -17,21 +17,19 @@ All notable changes to this project will be documented in this file.
1717

1818
### Deleted
1919

20-
- None
21-
22-
## [4.10.2]
20+
## [4.11.0]
2321

2422
### Added
2523

26-
- none
24+
- None
2725

2826
### Changed
2927

3028
- None
3129

3230
### Fixed
3331

34-
- None
32+
- Change the cleaning disk step ([#1663](https://github.com/wazuh/wazuh-docker/pull/1663))
3533

3634
### Deleted
3735

@@ -41,7 +39,7 @@ All notable changes to this project will be documented in this file.
4139

4240
### Added
4341

44-
- none
42+
- None
4543

4644
### Changed
4745

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ WAZUH_MONITORING_REPLICAS=0 ##
179179
| Wazuh version | ODFE | XPACK |
180180
|---------------|---------|--------|
181181
| v4.12.0 | | |
182-
| v4.10.2 | | |
182+
| v4.11.0 | | |
183183
| v4.10.1 | | |
184184
| v4.10.0 | | |
185185
| v4.9.2 | | |

0 commit comments

Comments
 (0)