ansible-ThoTeam / nexus3-oss

Ansible role to install and provision sonatype nexus3-oss
GNU General Public License v3.0
288 stars 206 forks source link

Ansible role is failing during update from Nexus 3.71.1-06 to 3.72.0-04 #431

Open uwehdaub opened 3 weeks ago

uwehdaub commented 3 weeks ago

During the update from Nexus 3.71.1 to 3.72.0 the role (v2.5.1) fails with the following error message:

TASK [ansible-thoteam.nexus3-oss : Create/Check blobstores] ********************************************************************************************************************
included: /home/uwe/.ansible/roles/ansible-thoteam.nexus3-oss/tasks/call_script.yml for dxnexustest0.ciserver.dxnexus.test1.peng.be-gcw1.metroscales.io

TASK [ansible-thoteam.nexus3-oss : Calling Groovy script create_blobstores_from_list] ******************************************************************************************
fatal: [dxnexustest0.ciserver.dxnexus.test1.peng.be-gcw1.metroscales.io]: FAILED! => {"changed": false, "connection": "close", "content_length": "278", "content_type": "application/json", "date": "Mon, 07 Oct 2024 10:58:08 GMT", "elapsed": 0, "failed_when_result": true, "json": {"name": "create_blobstores_from_list", "result": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "server": "Nexus/3.72.0-04 (OSS)", "status": 400, "url": "http://localhost:8081/service/rest/v1/script/create_blobstores_from_list/run", "x_content_type_options": "nosniff"}

TASK [ansible-thoteam.nexus3-oss : Debug script result for global fail] ********************************************************************************************************
skipping: [dxnexustest0.ciserver.dxnexus.test1.peng.be-gcw1.metroscales.io]

TASK [ansible-thoteam.nexus3-oss : Global script failure at nexus level] *******************************************************************************************************
skipping: [dxnexustest0.ciserver.dxnexus.test1.peng.be-gcw1.metroscales.io]

TASK [ansible-thoteam.nexus3-oss : Debug script result for failed script actions] **********************************************************************************************
ok: [dxnexustest0.ciserver.dxnexus.test1.peng.be-gcw1.metroscales.io] => {
    "msg": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"
}

TASK [ansible-thoteam.nexus3-oss : Script action failure] **********************************************************************************************************************
fatal: [dxnexustest0.ciserver.dxnexus.test1.peng.be-gcw1.metroscales.io]: FAILED! => {"changed": false, "msg": "The script create_blobstores_from_list returned at least one of its actions has failed. See the degug message above for details"}

PLAY RECAP *********************************************************************************************************************************************************************
dxnexustest0.ciserver.dxnexus.test1.peng.be-gcw1.metroscales.io : ok=87   changed=1    unreachable=0    failed=1    skipped=56   rescued=1    ignored=0   

The playbook was running on Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1060-gcp x86_64).

Ansible role v2.5.2 fails with the same error message.

ismoilovdevml commented 2 weeks ago

I have the same problem

TASK [ansible-ThoTeam.nexus3-oss : Calling Groovy script create_blobstores_from_list] ********************************************************************************************************
fatal: [ubuntu]: FAILED! => {"changed": false, "connection": "close", "content_length": "278", "content_type": "application/json", "date": "Mon, 07 Oct 2024 21:02:25 GMT", "elapsed": 0, "failed_when_result": true, "json": {"name": "create_blobstores_from_list", "result": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "server": "Nexus/3.72.0-04 (OSS)", "status": 400, "url": "http://localhost:8081/service/rest/v1/script/create_blobstores_from_list/run", "x_content_type_options": "nosniff"}
fatal: [debian]: FAILED! => {"changed": false, "connection": "close", "content_length": "278", "content_type": "application/json", "date": "Mon, 07 Oct 2024 21:02:26 GMT", "elapsed": 1, "failed_when_result": true, "json": {"name": "create_blobstores_from_list", "result": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "server": "Nexus/3.72.0-04 (OSS)", "status": 400, "url": "http://localhost:8081/service/rest/v1/script/create_blobstores_from_list/run", "x_content_type_options": "nosniff"}
fatal: [rockylinux]: FAILED! => {"changed": false, "connection": "close", "content_length": "278", "content_type": "application/json", "date": "Mon, 07 Oct 2024 21:02:26 GMT", "elapsed": 1, "failed_when_result": true, "json": {"name": "create_blobstores_from_list", "result": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "server": "Nexus/3.72.0-04 (OSS)", "status": 400, "url": "http://localhost:8081/service/rest/v1/script/create_blobstores_from_list/run", "x_content_type_options": "nosniff"}

TASK [ansible-ThoTeam.nexus3-oss : Debug script result for global fail] **********************************************************************************************************************
skipping: [debian]
skipping: [rockylinux]
skipping: [ubuntu]

TASK [ansible-ThoTeam.nexus3-oss : Global script failure at nexus level] *********************************************************************************************************************
skipping: [debian]
skipping: [ubuntu]
skipping: [rockylinux]

TASK [ansible-ThoTeam.nexus3-oss : Debug script result for failed script actions] ************************************************************************************************************
ok: [debian] => {
    "msg": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"
}
ok: [ubuntu] => {
    "msg": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"
}
ok: [rockylinux] => {
    "msg": "javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.sonatype.nexus.internal.provisioning.BlobStoreApiImpl.getBlobStoreManager() is applicable for argument types: () values: []"
}

TASK [ansible-ThoTeam.nexus3-oss : Script action failure] ************************************************************************************************************************************
fatal: [debian]: FAILED! => {"changed": false, "msg": "The script create_blobstores_from_list returned at least one of its actions has failed. See the debug message above for details"}
fatal: [ubuntu]: FAILED! => {"changed": false, "msg": "The script create_blobstores_from_list returned at least one of its actions has failed. See the debug message above for details"}
fatal: [rockylinux]: FAILED! => {"changed": false, "msg": "The script create_blobstores_from_list returned at least one of its actions has failed. See the debug message above for details"}

PLAY RECAP ***********************************************************************************************************************************************************************************
debian                     : ok=56   changed=1    unreachable=0    failed=1    skipped=44   rescued=1    ignored=0   
rockylinux                 : ok=58   changed=1    unreachable=0    failed=1    skipped=42   rescued=1    ignored=0   
ubuntu                     : ok=55   changed=1    unreachable=0    failed=1    skipped=44   rescued=1    ignored=0 
brianveltman commented 2 weeks ago

I will provide a fix for this tomorrow. Thanks for reporting! Bumping into the same issue tho.

uwehdaub commented 2 weeks ago

See https://github.com/sonatype/nexus-public/issues/485

Koeppchen commented 2 weeks ago

I could not find a good way to access the blobStoreManager and we do not use the actual Codebase. What worked for us, but what is really hacky is the folowing:

`
import org.sonatype.nexus.blobstore.api.BlobStoreManager
import java.lang.reflect.Field

// Hack to access BlobStore Manager, access was removed in Nexus 3.72 because Groovy implemetation was replaced by Java and the field was made private
Field  privateField = blobStore.class.getDeclaredField("blobStoreManager")
privateField.setAccessible(true)
BlobStoreManager blobStoreManager = (BlobStoreManager)privateField.get(blobStore)
//... other Code
existingBlobStore = blobStoreManager.get("BlobStoreName")

`

brianveltman commented 2 weeks ago

See #432 for a better fix, since Sonatype officially does not support Groovy scripts anymore. Will add more automated molecules tests for this change later this week, but this should get you guys up & running with the latest version of Nexus Repository Manager.