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

Add role assignment cleanup and workaround for the exit code 100 error. #2049

Merged
merged 25 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4863a0c
Add role assignment cleanup
harneetvirk Jan 30, 2023
aad9bb8
Update error message
harneetvirk Jan 30, 2023
bc8b254
Change the task
harneetvirk Jan 30, 2023
8c6c9f7
Update the call to bash
harneetvirk Jan 30, 2023
cb3f478
Update the error logging
harneetvirk Jan 30, 2023
2e65768
Fix environment variables
harneetvirk Jan 30, 2023
68e7ad6
Fix the call to bash
harneetvirk Jan 30, 2023
872f9ba
Fix the path
harneetvirk Jan 30, 2023
4a4a5e6
Remove setup call
harneetvirk Jan 30, 2023
b23bfea
Merge remote-tracking branch 'origin/main' into users/harnvir/updatec…
harneetvirk Jan 31, 2023
9352d00
Update PS call
harneetvirk Jan 31, 2023
8302c0f
Merge remote-tracking branch 'origin/main' into users/harnvir/updatec…
harneetvirk Jan 31, 2023
3af6184
Fix the path
harneetvirk Jan 31, 2023
3aebd48
Update the path
harneetvirk Jan 31, 2023
6146df0
Update the azpssession
harneetvirk Jan 31, 2023
bac975a
Add verbose logging for troubleshooting the exit code 100 issue
harneetvirk Feb 22, 2023
6c73a19
Merge remote-tracking branch 'origin/main' into users/harnvir/updatec…
harneetvirk Feb 22, 2023
a7af563
Update grub-efi
harneetvirk Feb 23, 2023
61fe1fa
Update grub-efi with reinstallation
harneetvirk Feb 23, 2023
11fa158
Update grub-efi with reinstallation
harneetvirk Feb 23, 2023
f3b39ea
Remove an update grub-efi with reinstallation
harneetvirk Feb 23, 2023
bb349cb
Add grub-efi-amd64-bin
harneetvirk Feb 23, 2023
66fcef3
bypass the error for grub-efi-amd64-signed
harneetvirk Feb 23, 2023
34d5678
Adding the redirections back
harneetvirk Feb 23, 2023
38cc6cc
Merge remote-tracking branch 'origin/main' into users/harnvir/updatec…
harneetvirk Feb 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/automated-cleanup-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
uses: azure/login@v1
with:
creds: ${{secrets.AZUREML_CREDENTIALS}}
enable-AzPSSession: true
continue-on-error: true
- name: "Install Az Modules"
shell: pwsh
run: |
Install-Module Az -Force; Import-Module Az -Force;
- name: setup-cli
run: |
source "${{ github.workspace }}/infra/sdk_helpers.sh";
Expand All @@ -41,3 +46,8 @@ jobs:
bash cleanup.sh
working-directory: infra
continue-on-error: true
- name: Perform additional Cleanup
run: |
source "${{ github.workspace }}/infra/sdk_helpers.sh";
source "${{ github.workspace }}/infra/init_environment.sh";
pwsh -File '${{ github.workspace }}/infra/scripts/call_all_scripts.ps1'
5 changes: 5 additions & 0 deletions infra/scripts/call_all_scripts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
####################################################################################################
# All the post cleanup scripts are called from this file #
####################################################################################################

&"$PSScriptroot\remove_role_assignments.ps1" -ResourceGroupName "$env:RESOURCE_GROUP_NAME"
38 changes: 38 additions & 0 deletions infra/scripts/remove_role_assignments.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
####################################################################################################
# This script allows you to remove stale role assignments listed as 'Identity not found' #
####################################################################################################
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName
)
function Get-RoleAssignmentCount {
$OBJTYPE = "Unknown"
Write-Output "Determing unknown Role Assignment count in the ResourceGroup:$ResourceGroupName..."
$stale = Get-AzRoleAssignment -ResourceGroupName "$ResourceGroupName" | Where-Object { $_.ObjectType -eq $OBJTYPE}
$unknownRoleAssignmentCount = $stale.Count
Write-Output "Total Unknown Role Assignment Count: $unknownRoleAssignmentCount in the ResourceGroup:$ResourceGroupName..."

return $unknownRoleAssignmentCount
}

try
{
$OBJTYPE = "Unknown"
Write-Output "Pre-checking the RoleAssignment count..."
Get-RoleAssignmentCount
# Remove only limited RoleDefinitions
$staleRoleAssignments = Get-AzRoleAssignment -ResourceGroupName "$ResourceGroupName" | Where-Object {($_.ObjectType -eq $OBJTYPE) -and ($_.RoleDefinitionName -match "Storage Blob Data Reader|AzureML Metrics Writer (preview)|AcrPull")}
$unknownRoleAssignmentCount = $staleRoleAssignments.Count
Write-Output "Initiating the cleanup of unknownRole in the ResourceGroup:$ResourceGroupName having count as $unknownRoleAssignmentCount..."
$staleRoleAssignments | Remove-AzRoleAssignment
Write-Output "Check the Role Assignment count after cleanup"
Get-RoleAssignmentCount
Write-Output "Role Assignment clean-up complete."
}
catch
{
Write-Error "There was an issue in cleaning-up the Role Assignment. See details: $($_.Exception.Message)"
Exit 1
}
11 changes: 8 additions & 3 deletions infra/sdk_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,14 @@ function install_packages() {
echo_info ">>> Updating packages index"
echo_info "------------------------------------------------"

sudo apt-get update > /dev/null 2>&1
sudo apt-get upgrade -y > /dev/null 2>&1
sudo apt-get dist-upgrade -y > /dev/null 2>&1
echo_info ">>> Executing: apt-get update"
# https://github.com/orgs/community/discussions/47863
sudo apt-mark hold grub-efi-amd64-signed
sudo apt-get update --fix-missing
echo_info ">>> Executing: apt-get upgrade"
sudo apt-get upgrade -y
echo_info ">>> Executing: apt-get dist-upgrade"
sudo apt-get dist-upgrade -y

echo_info ">>> Installing packages"

Expand Down