Scheduled tasks failing to execute in vCenter Server environments, specifically snapshots, often return the error "NotAuthenticated for the task operation." This issue arises due to stale OAuth2 persistent tokens stored in the vCenter Database (VCDB) following certificate rotations or version upgrades, preventing successful task authentication.
/var/log/vmware/vpxd/vpxd.log display:[######] error vpxd[####] [Originator@#### sub=MoScheduledTask][AcquireToken] Failed to get token. Error: --> Error:--> com.vmware.oauth2.errors.invalid_grant/var/log/vmware/sso/tokenservice.log display:ERROR tokenservice... Exchange failed due to invalid grant: com.vmware.vcenter.tokenservice.exceptions.InvalidGrant: JWT token failed signature verification.vpx_sched_persistent_user_token table in the VCDB become stale or invalid after certificate or version updates. These tokens fail signature verification, causing the Token Service to reject the task execution request.VMware by Broadcom Engineering is aware of the issue and is working on a permanent fix.
Workaround:
For affected user accounts, run the attached script to clear the stale token(s).
Note: Running this script clears the tokens for the specified users, requiring their scheduled tasks to be deleted and recreated.
remove_persistable_tokens.sh script to the vCenter Server /tmp directory.chmod +x /tmp/remove_persistable_tokens.sh./remove_persistable_tokens.sh 'DOMAIN\User' ( Note: The DOMAIN\User name is case sensitive. It must match the exact syntax used in the scheduled task)For environments managing large numbers of tasks, ensure that the vCenter Server is at the latest patch level to maintain optimal Token Service performance. If the issue persists after these steps, contact technical support to investigate potential database inconsistencies.
Troubleshooting Script Execution Errors:
If the script fails with the following errors, it is likely due to hidden DOS carriage returns (\r) added to the script if it was downloaded or edited using a Windows-based text editor:
root@VC-XXX [ /tmp ]# ./remove_persistable_tokens.sh 'task-initiator1' : No such file or directory.sh: line 1: /etc/profile.d/vmware-vpostgres-config.sh
./remove_persistable_tokens.sh: line 3: $'\r': command not found
./remove_persistable_tokens.sh: line 10: syntax error near unexpected token `$'\r''To resolve this, clean the script by running the sed command before executing it again:sed -i -e 's/\r$//' /tmp/remove_persistable_tokens.sh
If the error persists after running the sed command, move the script to a different directory (e.g., /var/core), execute it from there, and ensure to delete the script after it runs successfully.