Open elconas opened 6 years ago
I also tested with a private docker repo. Same issue here. It happens with nexus 3.6.0 and 3.6.1. It also happens with Nexus 3.3.0.
One more not. If I change the "update()" to a noop, everything works. So the problem seems to be in the "update()" call
if (existingRepository != null) {
existingRepository.stop()
//configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
//existingRepository.update(configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
re-setting the existing configuration does also work
if (existingRepository != null) {
existingRepository.stop()
//configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
existingRepository.update(existingRepository.configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
modifying the existing config in place and setting it again does also work
if (existingRepository != null) {
existingRepository.stop()
//configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
existingRepository.configuration.attributes['docker']['v1Enabled']=false
existingRepository.update(existingRepository.configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
+1 Thanks for the tip. I actually tested and the problem is the same with maven repositories (did not test other types but I guess we will have the same problem).
Yes, this seems a comming problem now.
I also reported this in https://github.com/savoirfairelinux/ansible-nexus3-oss/issues/37
There's an ticket NEXUS-14948 for this and a discussion on the users group, here.
Be aware that also any changes you make using the intergation api (groovy scripts) will be reverted when Nexus restarts.
I also see this with Nexus 3.3.0 (using docker version)
@dannyk81 Regarding the statement:
Be aware that also any changes you make using the intergation api (groovy scripts) will be reverted when Nexus restarts.
Is this only to for the writePolicy setting or all settings ?
From my tests with Nexus 3.6.0 and 3.6.1, any parameter change in repository settings gets reverted.
The ticket mentioned the write policy specifically, but I've seen that it affects all settings.
I made a first test tonight and was actually able to fix the fact that the repo is not saveable/deleteable from gui after a second playbook run by changing the groovy script (i.e. get the current config and only update values which your are allowed to effectively change). Meanwhile, I did not try to change any values from my vars in playbook. I made the test against docker proxy repo only for now. I'm going to check if the values get reverted. Coming back.
Yes, it seems modifying in place seems to work:
existingRepository.stop()
conig = existingRepository.configuration
.. now modify config ...
existingRepository.update(config)
existingRepository.start()
working/testing a fix to change only allowed parameters. I'll keep you updated and submit a merge request if successful.
Actually I am (generally) a little concerned that groovy scripts in nexus can make the server unusabe. It should not be possible for users to get Nexus in an inconsistent state.
We agree on that point !
Meanwhile, since I'm not a nexus dev and only a late user of this ansible role, I'm trying to find a way to not screw-up my production.
My latest tests:
Looking at the nexus javadoc to see if I can find something interesting there.
Hi guys. I did not take the time to start a PR since the issue is not resolved (the settings are still reverted back to previous when nexus restart). But this is how I managed to keep the repos usable in the gui (example for docker hosted):
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration
parsed_args = new JsonSlurper().parseText(args)
def existingRepository = repository.getRepositoryManager().get(parsed_args.name)
if (existingRepository != null) {
def newConfig = existingRepository.configuration.copy()
// We only update values we are allowed to change (cf. greyed out options in gui)
newConfig.attributes['docker']['forceBasicAuth'] = parsed_args.force_basic_auth
newConfig.attributes['docker']['v1Enabled'] = parsed_args.v1_enabled
newConfig.attributes['storage']['writePolicy'] = parsed_args.write_policy.toUpperCase()
newConfig.attributes['storage']['strictContentTypeValidation'] = Boolean.valueOf(parsed_args.strict_content_validation)
if (parsed_args.http_port) {
newConfig.attributes['docker']['httpPort'] = parsed_args.http_port
} else {
newConfig.attributes['docker']['httpPort'] = ""
}
existingRepository.stop()
existingRepository.update(newConfig)
existingRepository.start()
} else {
configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'docker-hosted',
online: true,
attributes: [
docker: [
forceBasicAuth: parsed_args.force_basic_auth,
v1Enabled : parsed_args.v1_enabled
],
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)
if (parsed_args.http_port) {
configuration.attributes['docker']['httpPort'] = parsed_args.http_port
}
repository.getRepositoryManager().create(configuration)
}
Thanks @zeitounator! this is indeed a way forward.
I suggest we apply these changes to all repo scripts, however please note that @samherve is no longer maintaing this project, so any PR we submit would simply not be merged.
As he suggests, perhaps we should fork this project and start pushing the PRs that are pending here.
In any case, I'm hoping Sonatype will provide root cause for both issues we've been experiencing (vote for the ticket here), as suggested above - it's unresanable that an incorrect usage by a groovy script would render a system inoperable and the reverted settings after restart is still a mistery and in our case a source for a lot of headache...
Hi @dannyk81. I missed the information about @samherve stopping maintenance. Thanks for sharing. This is sad. I just added a comment in #36 and I think we should wait some more days (like end of next week ?) for a clear answer from @support-savoirfairelinux before we take a decision. Meanwhile, if we should come to this, I think we should hard fork in an organization somewhere and not keep the new reference repository under a single user name. What's your opinion about it ?
I agree, let's wait for some time for feedback.
Worst case, we'll hard fork this as you suggest.
Problem fixed after sonatype response on the ticket. We were making an incorrect use of the groovy available interfaces (even though it should be locked up better and better documented as well.....). Once again, the working solution with docker proxy repo as example
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration
parsed_args = new JsonSlurper().parseText(args)
repositoryManager = repository.repositoryManager
existingRepository = repositoryManager.get(parsed_args.name)
if (existingRepository != null) {
newConfig = existingRepository.configuration.copy()
// We only update values we are allowed to change (cf. greyed out options in gui)
newConfig.attributes['docker']['forceBasicAuth'] = parsed_args.force_basic_auth
newConfig.attributes['docker']['v1Enabled'] = parsed_args.v1_enabled
newConfig.attributes['storage']['writePolicy'] = parsed_args.write_policy.toUpperCase()
newConfig.attributes['storage']['strictContentTypeValidation'] = Boolean.valueOf(parsed_args.strict_content_validation)
if (parsed_args.http_port) {
newConfig.attributes['docker']['httpPort'] = parsed_args.http_port
} else {
newConfig.attributes['docker']['httpPort'] = ""
}
repositoryManager.update(newConfig)
} else {
configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'docker-hosted',
online: true,
attributes: [
docker: [
forceBasicAuth: parsed_args.force_basic_auth,
v1Enabled : parsed_args.v1_enabled
],
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)
if (parsed_args.http_port) {
configuration.attributes['docker']['httpPort'] = parsed_args.http_port
}
repositoryManager.create(configuration)
}
Wow! great news 😃 @zeitounator
I'll have to update my scripts per above! shame there's still no response from @support-savoirfairelinux... we need to preserve and maintain this work somehow.
Hi guys. Seems like @support-savoirfairelinux is not willing to respond. I would still like to give them a chance to do so until the end of the week.
Meanwhile, as a beginning, I have started to merge the pull requests found in this repo that I already use for production on my own github repo. You can find the result there on the master branch (ongoing work): https://github.com/zeitounator/ansible-nexus3-oss. I have some more additions to share which are not shown there (I use an other gitlab repo for work which is not public)
I am planning to merge all the remaining PRs from here (the ones i did not pick yet on my prod), the necessary changes to groovy scripts for persistence of changes discussed in this issue and the work I have done on my own and not yet shared.
If there is no answer from @support-savoirfairelinux by then, I suggest to hard fork in a central location under a team name. If someone has an existing one to suggest, I'll be happy to join and/or collaborate. If not, I was about to create one under my own self-employed company name (ThoTeam) and invite the good willing people who have some time to spend on maintaining this. Let me know what you think.
Regards
Hi @zeitounator!
+1 on your propsal and thanks for initiative, it seems that if we want to keep this work alive and relevant it should be a good idea.
I would be more than happy to contribute/assist.
I went ahead and hard forked the repo since I didn't get a response from the current owners and no proposition for an existing organization to host it. I'm trying to integrate as fast as possible all the leftover pull requests. I will put a comment in each of them once it is done. The new hard forked repository is here: https://github.com/ansible-ThoTeam/nexus3-oss
Here is my solution:
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration
parsed_args = new JsonSlurper().parseText(args)
configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'docker-hosted',
online: true,
attributes: [
docker: [
httpPort: parsed_args.http_port,
v1Enabled : parsed_args.v1_enabled
],
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)
def existingRepository = repository.getRepositoryManager().get(parsed_args.name)
if (existingRepository != null) {
existingRepository.stop()
config = existingRepository.configuration;
blobStoreName = config.attributes['storage']['blobStoreName'];
config.attributes = configuration.attributes
config.attributes['storage']['blobStoreName'] = blobStoreName
existingRepository.update(config)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
Hi @tycoonm, As you may not have seen, this repo is totally silent since end of maintenance was announced almost 2 years ago. This issue has been fixed very long ago in the following hard fork repo which also contains tons of other new features: https://github.com/ansible-ThoTeam/nexus3-oss. You're welcome to come by and visit if you are interested. Cheers.
Hello, when running the create_repo_docker_proxy_each role multiple times, the Nexus GUI returns "Warning Missing entity-metadata" when Itry to make manual changes to the repo created by Nexus. I can see the following:
Config for the Repo: