Skip to content

Commit 703c5ae

Browse files
authored
Exclude ARM platforms in VM offers. (#322)
* exclude arm arch VMs. * block deployment if selecting ARM based VMs. * exclude ARM VM sizes. * increase pom * create a pipeline to check vm aRM size change * enable workflow_dispatch event. * fix repo path. * debug * debug * test * for test * add doc for checkARMVMSize.yml * update doc with token permission. * fix doc format. * fix job output. * change PR repo * exclude Standard_DS1_v2 to mitigate "System node pool must use VM sku with more than 2 cores and 4GB memory."
1 parent e1adb90 commit 703c5ae

File tree

9 files changed

+277
-17
lines changed

9 files changed

+277
-17
lines changed

.github/docs/check-arm-vm-size.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## GitHub Action: Check ARM VM Size Changes
2+
3+
### Overview
4+
This GitHub Action runs on a schedule to check for changes in Azure ARM VM sizes and creates a pull request to update configurations if changes are detected.
5+
6+
The action will compare the latest ARM VM sizes queried using AZ CLI with those listed in the variable azure.armBased.vmSize.list within oracle/weblogic-azure/resources/azure-common.properties. If changes are detected, it will initiate a pull request to the main branch of the current repository that runs the action.
7+
8+
### Schedule
9+
- **Frequency:** Every 14 days (2 weeks)
10+
- **Schedule Expression:** `0 0 */14 * *` (Runs at midnight (00:00) UTC)
11+
12+
The schedule event only happens in [azure-javaee/weblogic-azure](https://github.com/azure-javaee/weblogic-azure).
13+
14+
If you want to run the action in your repository, you have to trigger it from Web Browser.
15+
16+
### Environment Variables
17+
- **azureCredentials:** Secret for Azure credentials
18+
- **repoName:** Repository name set to "weblogic-azure"
19+
- **userEmail:** Secret for user Email of GitHub acount to access GitHub repository
20+
- **userName:** Secret for user name of GitHub account
21+
22+
### Jobs
23+
#### check-vm-sizes
24+
- **Runs on:** `ubuntu-latest`
25+
- **Steps:**
26+
1. **Checkout repository:** Checks out the repository using `actions/checkout@v2`.
27+
28+
2. **Azure Login:** Logs into Azure using `azure/login@v1`.
29+
30+
3. **Check for VM size changes:**
31+
- Reads from `resources/azure-common.properties`.
32+
- Extracts and compares current VM sizes with the latest available.
33+
- Determines if there are changes and prepares data for output.
34+
35+
4. **Create PR if changes detected:**
36+
- Conditionally creates a pull request if changes in ARM VM sizes are detected.
37+
- Updates the ARM VM sizes configuration in `resources/azure-common.properties`.
38+
- Commits changes to a new branch and pushes to origin.
39+
- Creates a pull request with a title and description based on detected changes.
40+
41+
### Run the action
42+
43+
You can use `.github/resource/azure-credential-setup-wls-vm.sh` to create GitHub Action Secret for the pipeline.
44+
45+
1. Fill in `.github/resource/credentials-params-wls-vm.yaml` with your values.
46+
47+
| Variable Name | Value |
48+
|----------------|----------------------|
49+
| OTN_USERID | Oracle single sign-on userid. If you don't have one, sign up from [Create Your Oracle Account](https://profile.oracle.com/myprofile/account/create-account.jspx?nexturl=https%3A%2F%2Fsupport.oracle.com&pid=mos) |
50+
| OTN_PASSWORD | Password for Oracle single sign-on userid. |
51+
| WLS_PSW | Password for WebLogic Server. |
52+
| USER_EMAIL | User Email of GitHub acount to access GitHub repository. |
53+
| USER_NAME | User name of GitHub account. |
54+
| GIT_TOKEN | GitHub token to access GitHub repository. <br /> Make sure the token have permissions: <br /> - Read and write of Pull requests. <br /> - Read and write of Contents. |
55+
56+
2. Set up secret
57+
58+
Run `azure-credential-setup-wls-vm.sh` to set up secret.
59+
60+
```shell
61+
bash .github/resource/azure-credential-setup-wls-vm.sh
62+
```
63+
64+
Follow the output to set up secrets.
65+
66+
3. Trigger the workflow
67+
68+
- Fork this repo from [oracle/weblogic-azure](https://github.com/azure-javaee/weblogic-azure).
69+
70+
- Enable workflow in the fork. Select **Actions**, then follow the instructions to enable workflow.
71+
72+
- Select **Actions** -> **Check ARM VM Size Changes** -> **Run workflow** to run the workflow.
73+

.github/workflows/checkARMVMSize.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Check ARM VM Size Changes
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 */14 * *' # Runs at midnight (00:00) UTC every 14 days (2 weeks)
7+
8+
env:
9+
azureCredentials: ${{ secrets.AZURE_CREDENTIALS }}
10+
repoName: "weblogic-azure"
11+
userEmail: ${{ secrets.USER_EMAIL }}
12+
userName: ${{ secrets.USER_NAME }}
13+
GH_TOKEN: ${{ secrets.GIT_TOKEN }}
14+
15+
jobs:
16+
check-vm-sizes:
17+
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'schedule' && github.repository_owner == 'azure-javaee')
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout oracle/weblogic-azure:main
21+
uses: actions/checkout@v2
22+
with:
23+
repository: oracle/${{ env.repoName }}
24+
ref: main
25+
path: ${{ env.repoName }}
26+
27+
- uses: azure/login@v1
28+
id: azure-login
29+
with:
30+
creds: ${{ env.azureCredentials }}
31+
32+
- name: Check for VM size changes
33+
id: check_vm_sizes
34+
run: |
35+
ls -l ${{ env.repoName }}
36+
# Path to the properties file
37+
property_file="${{ env.repoName }}/resources/azure-common.properties"
38+
39+
# Check if the properties file exists
40+
if [ ! -f "$property_file" ]; then
41+
echo "Properties file '$property_file' not found."
42+
exit 1
43+
fi
44+
45+
if ! grep -q '^azure\.armBased\.vmSize\.list=' "$property_file"; then
46+
echo "Line 'azure.armBased.vmSize.list' not found in $property_file."
47+
echo "vm_sizes_changed=false" >> "$GITHUB_OUTPUT"
48+
exit 0
49+
fi
50+
51+
# Using grep to find the line containing azure.armBased.vmSize.list
52+
vm_size_variable=$(grep '^azure\.armBased\.vmSize\.list=' "$property_file")
53+
vm_size_list=${vm_size_variable#*=}
54+
55+
# Print the extracted value
56+
echo "$vm_size_list"
57+
58+
latest_locations=$(az account list-locations --query '[].name' -o tsv)
59+
60+
new_sizes=""
61+
for location in $latest_locations; do
62+
latest_sizes=$(az vm list-sizes --location $location | jq '.[] | select(.name | contains("p")) | .name' | tr -d "\"")
63+
for size in $latest_sizes; do
64+
# if new_sizes does not contain size
65+
if [[ $(echo "[$new_sizes]" | jq '. | index("'${size}'")') == null ]]; then
66+
echo "Add size: ${size}"
67+
if [ -z "$new_sizes" ]; then
68+
new_sizes="\"$size\""
69+
else
70+
new_sizes="$new_sizes,\"$size\""
71+
fi
72+
fi
73+
done
74+
done
75+
76+
if [ ${#new_sizes} -ne ${#vm_size_list} ]; then
77+
echo "VM sizes changed"
78+
echo "vm_sizes_changed=true" >> "$GITHUB_OUTPUT"
79+
else
80+
echo "vm_sizes_changed=false" >> "$GITHUB_OUTPUT"
81+
fi
82+
83+
echo "Current sizes : $new_sizes"
84+
echo "latest_sizes=\"${new_sizes}\"" >> "$GITHUB_OUTPUT"
85+
86+
- name: Create PR if changes detected
87+
if: steps.check_vm_sizes.outputs.vm_sizes_changed == 'true'
88+
run: |
89+
# Logic to create a pull request to update the ARM VM sizes configuration file
90+
# Example: Use GitHub CLI or git commands to create a branch and push changes
91+
cd ${{ env.repoName }}
92+
branchName="update-vm-sizes-$(date +%s)"
93+
git config --global user.email "${userEmail}"
94+
git config --global user.name "${userName}"
95+
96+
git checkout -b ${branchName}
97+
# Use sed to delete the line starting with azure.armBased.vmSize.list=
98+
property_file="resources/azure-common.properties"
99+
sed -i '/^azure\.armBased\.vmSize\.list=/d' "$property_file"
100+
latest_sizes=$(echo ${{ steps.check_vm_sizes.outputs.latest_sizes }} | sed 's/,/","/g')
101+
echo "azure.armBased.vmSize.list=\"$latest_sizes\"" >> "$property_file"
102+
103+
git add $property_file
104+
git commit -m "Update ARM VM sizes"
105+
git push origin ${branchName}
106+
107+
# Create a pull request
108+
gh pr create --title "Update ARM VM sizes" \
109+
--body "Automatic update of ARM VM sizes based on latest changes" \
110+
--reviewer edburns,galiacheng \
111+
--base main \
112+
--head ${branchName}

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
<properties>
4141
<!-- versions start -->
4242
<!-- weblogic azure aks versions -->
43-
<version.wls-on-aks-azure-marketplace>1.0.80</version.wls-on-aks-azure-marketplace>
43+
<version.wls-on-aks-azure-marketplace>1.0.81</version.wls-on-aks-azure-marketplace>
4444
<!-- weblogic azure vm versions -->
45-
<version.arm-oraclelinux-wls>1.0.27</version.arm-oraclelinux-wls>
46-
<version.arm-oraclelinux-wls-admin>1.0.51</version.arm-oraclelinux-wls-admin>
47-
<version.arm-oraclelinux-wls-cluster>1.0.670000</version.arm-oraclelinux-wls-cluster>
48-
<version.arm-oraclelinux-wls-dynamic-cluster>1.0.50</version.arm-oraclelinux-wls-dynamic-cluster>
45+
<version.arm-oraclelinux-wls>1.0.28</version.arm-oraclelinux-wls>
46+
<version.arm-oraclelinux-wls-admin>1.0.52</version.arm-oraclelinux-wls-admin>
47+
<version.arm-oraclelinux-wls-cluster>1.0.680000</version.arm-oraclelinux-wls-cluster>
48+
<version.arm-oraclelinux-wls-dynamic-cluster>1.0.51</version.arm-oraclelinux-wls-dynamic-cluster>
4949
<!-- node versions -->
5050
<version.arm-oraclelinux-wls-dynamic-cluster-addnode>1.0.7</version.arm-oraclelinux-wls-dynamic-cluster-addnode>
5151
<version.arm-oraclelinux-wls-dynamic-cluster-addnode-coherence>1.0.3</version.arm-oraclelinux-wls-dynamic-cluster-addnode-coherence>

resources/azure-common.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ azure.apiVersionForMonitorAccount=2023-04-03
4949
azure.cli.version=2.53.0
5050
# AzurePowerShell version
5151
azure.powershell.version=11.5
52+
53+
azure.armBased.vmSize.list="Standard_D2plds_v5","Standard_D4plds_v5","Standard_D8plds_v5","Standard_D16plds_v5","Standard_D32plds_v5","Standard_D48plds_v5","Standard_D64plds_v5","Standard_D2pls_v5","Standard_D4pls_v5","Standard_D8pls_v5","Standard_D16pls_v5","Standard_D32pls_v5","Standard_D48pls_v5","Standard_D64pls_v5","Standard_D2pds_v5","Standard_D4pds_v5","Standard_D8pds_v5","Standard_D16pds_v5","Standard_D32pds_v5","Standard_D48pds_v5","Standard_D64pds_v5","Standard_D2ps_v5","Standard_D4ps_v5","Standard_D8ps_v5","Standard_D16ps_v5","Standard_D32ps_v5","Standard_D48ps_v5","Standard_D64ps_v5","Standard_E2pds_v5","Standard_E4pds_v5","Standard_E8pds_v5","Standard_E16pds_v5","Standard_E20pds_v5","Standard_E32pds_v5","Standard_E2ps_v5","Standard_E4ps_v5","Standard_E8ps_v5","Standard_E16ps_v5","Standard_E20ps_v5","Standard_E32ps_v5","Standard_B2pls_v2","Standard_B2ps_v2","Standard_B2pts_v2","Standard_B4pls_v2","Standard_B4ps_v2","Standard_B8pls_v2","Standard_B8ps_v2","Standard_B16pls_v2","Standard_B16ps_v2"

weblogic-azure-aks/src/main/arm/createUiDefinition.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
"Standard_A1_v2",
336336
"Standard_F1",
337337
"Standard_F1s",
338+
"Standard_DS1_v2",
338339
"Standard_B12ms",
339340
"Standard_B16als_v2",
340341
"Standard_B16as_v2",

weblogic-azure-vm/arm-oraclelinux-wls-admin/src/main/arm/createUiDefinition.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,23 @@
8282
"Standard_B1ls",
8383
"Standard_A0",
8484
"Basic_A0",
85-
"Standard_B1s"
85+
"Standard_B1s",
86+
${azure.armBased.vmSize.list}
8687
]
8788
},
8889
"osPlatform": "Linux",
8990
"count": "1",
9091
"visible": true
9192
},
93+
{
94+
"name": "invalidVMSizeInfo",
95+
"type": "Microsoft.Common.InfoBox",
96+
"visible": "[contains(basics('vmSizeSelect'),'p')]",
97+
"options": {
98+
"icon": "Error",
99+
"text": "The VM size you selected includes the feature letter 'p', indicating it uses ARM CPUs. ARM platform is not supported. Please select a different VM size. For more information, refer to the <a href='https://learn.microsoft.com/azure/virtual-machines/vm-naming-conventions' target='_blank'>Azure virtual machine sizes naming conventions</a>."
100+
}
101+
},
92102
{
93103
"name": "basicsRequired",
94104
"type": "Microsoft.Common.Section",
@@ -102,8 +112,16 @@
102112
"toolTip": "Use only letters and numbers",
103113
"constraints": {
104114
"required": true,
105-
"regex": "^[a-z0-9A-Z]{1,30}$",
106-
"validationMessage": "The value must be 1-30 characters long and must only contain letters and numbers."
115+
"validations": [
116+
{
117+
"regex": "^[a-z0-9A-Z]{1,30}$",
118+
"message": "The value must be 1-30 characters long and must only contain letters and numbers."
119+
},
120+
{
121+
"isValid": "[not(contains(basics('vmSizeSelect'),'p'))]",
122+
"message": "ARM platform is not supported. Please select a different VM size."
123+
}
124+
]
107125
},
108126
"visible": true
109127
},

weblogic-azure-vm/arm-oraclelinux-wls-cluster/arm-oraclelinux-wls-cluster/src/main/arm/createUiDefinition.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,23 @@
8282
"Standard_B1ls",
8383
"Standard_A0",
8484
"Basic_A0",
85-
"Standard_B1s"
85+
"Standard_B1s",
86+
${azure.armBased.vmSize.list}
8687
]
8788
},
8889
"osPlatform": "Linux",
8990
"count": "1",
9091
"visible": true
9192
},
93+
{
94+
"name": "invalidVMSizeInfo",
95+
"type": "Microsoft.Common.InfoBox",
96+
"visible": "[contains(basics('vmSizeSelect'),'p')]",
97+
"options": {
98+
"icon": "Error",
99+
"text": "The VM size you selected includes the feature letter 'p', indicating it uses ARM CPUs. ARM platform is not supported. Please select a different VM size. For more information, refer to the <a href='https://learn.microsoft.com/azure/virtual-machines/vm-naming-conventions' target='_blank'>Azure virtual machine sizes naming conventions</a>."
100+
}
101+
},
92102
{
93103
"name": "basicsRequired",
94104
"type": "Microsoft.Common.Section",
@@ -102,8 +112,16 @@
102112
"toolTip": "Use only letters and numbers",
103113
"constraints": {
104114
"required": true,
105-
"regex": "^[a-z0-9A-Z]{1,30}$",
106-
"validationMessage": "The value must be 1-30 characters long and must only contain letters and numbers."
115+
"validations": [
116+
{
117+
"regex": "^[a-z0-9A-Z]{1,30}$",
118+
"message": "The value must be 1-30 characters long and must only contain letters and numbers."
119+
},
120+
{
121+
"isValid": "[not(contains(basics('vmSizeSelect'),'p'))]",
122+
"message": "ARM platform is not supported. Please select a different VM size."
123+
}
124+
]
107125
},
108126
"visible": true
109127
},

weblogic-azure-vm/arm-oraclelinux-wls-dynamic-cluster/arm-oraclelinux-wls-dynamic-cluster/src/main/arm/createUiDefinition.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,23 @@
8282
"Standard_B1ls",
8383
"Standard_A0",
8484
"Basic_A0",
85-
"Standard_B1s"
85+
"Standard_B1s",
86+
${azure.armBased.vmSize.list}
8687
]
8788
},
8889
"osPlatform": "Linux",
8990
"count": "1",
9091
"visible": true
9192
},
93+
{
94+
"name": "invalidVMSizeInfo",
95+
"type": "Microsoft.Common.InfoBox",
96+
"visible": "[contains(basics('vmSizeSelect'),'p')]",
97+
"options": {
98+
"icon": "Error",
99+
"text": "The VM size you selected includes the feature letter 'p', indicating it uses ARM CPUs. ARM platform is not supported. Please select a different VM size. For more information, refer to the <a href='https://learn.microsoft.com/azure/virtual-machines/vm-naming-conventions' target='_blank'>Azure virtual machine sizes naming conventions</a>."
100+
}
101+
},
92102
{
93103
"name": "basicsRequired",
94104
"type": "Microsoft.Common.Section",
@@ -102,8 +112,16 @@
102112
"toolTip": "Use only letters and numbers",
103113
"constraints": {
104114
"required": true,
105-
"regex": "^[a-z0-9A-Z]{1,30}$",
106-
"validationMessage": "The value must be 1-30 characters long and must only contain letters and numbers."
115+
"validations": [
116+
{
117+
"regex": "^[a-z0-9A-Z]{1,30}$",
118+
"message": "The value must be 1-30 characters long and must only contain letters and numbers."
119+
},
120+
{
121+
"isValid": "[not(contains(basics('vmSizeSelect'),'p'))]",
122+
"message": "ARM platform is not supported. Please select a different VM size."
123+
}
124+
]
107125
},
108126
"visible": true
109127
},

weblogic-azure-vm/arm-oraclelinux-wls/src/main/arm/createUiDefinition.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,23 @@
8282
"Standard_B1ls",
8383
"Standard_A0",
8484
"Basic_A0",
85-
"Standard_B1s"
85+
"Standard_B1s",
86+
${azure.armBased.vmSize.list}
8687
]
8788
},
8889
"osPlatform": "Linux",
8990
"count": "1",
9091
"visible": true
9192
},
93+
{
94+
"name": "invalidVMSizeInfo",
95+
"type": "Microsoft.Common.InfoBox",
96+
"visible": "[contains(basics('vmSizeSelect'),'p')]",
97+
"options": {
98+
"icon": "Error",
99+
"text": "The VM size you selected includes the feature letter 'p', indicating it uses ARM CPUs. ARM platform is not supported. Please select a different VM size. For more information, refer to the <a href='https://learn.microsoft.com/azure/virtual-machines/vm-naming-conventions' target='_blank'>Azure virtual machine sizes naming conventions</a>."
100+
}
101+
},
92102
{
93103
"name": "basicsRequired",
94104
"type": "Microsoft.Common.Section",
@@ -102,8 +112,16 @@
102112
"toolTip": "Use only letters and numbers",
103113
"constraints": {
104114
"required": true,
105-
"regex": "^[a-z0-9A-Z]{1,30}$",
106-
"validationMessage": "The value must be 1-30 characters long and must only contain letters and numbers."
115+
"validations": [
116+
{
117+
"regex": "^[a-z0-9A-Z]{1,30}$",
118+
"message": "The value must be 1-30 characters long and must only contain letters and numbers."
119+
},
120+
{
121+
"isValid": "[not(contains(basics('vmSizeSelect'),'p'))]",
122+
"message": "ARM platform is not supported. Please select a different VM size."
123+
}
124+
]
107125
},
108126
"visible": true
109127
},

0 commit comments

Comments
 (0)