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

Client-side management endpoints to register and deregister a client. #151

Closed
RobWin opened this issue Feb 3, 2016 · 6 comments
Closed

Comments

@RobWin
Copy link
Contributor

RobWin commented Feb 3, 2016

Hi @joshiste

currently a Spring Boot application auto-registers when the applicationContext is started and ready. It would be nice to have a property called autoRegistration similar to autoDeregistration which enables/disables this behavior.

Furthermore it would be nice that have Client-Side Spring Actuator management endpoints which can be triggered to register and deregister the client. The registerendpoint either activates the ScheduledTaskRegistrar or sets the AdminClientProperties.ready property to true.

For example:
http://localhost:8080/admin/register
http://localhost:8080/admin/deregister

Background:
We use a blue/green deployment process where different versions of the same application can be started on different ports and run in parallel. But only one version is active, that means HTTP requests are routed to this version via a proxy. Currently each application registers itself automatically, but we would like to see only the active instances in the Spring Boot UI.

We would like to be able to trigger the registration only when a version is activated and deregister the deactivated version. We can't do this in a generic way (script) via the Admin REST API directly, because each Spring Boot application could have different management endpoint paths and ports.

I would also contribute this to Spring Boot Admin.

@joshiste
Copy link
Collaborator

joshiste commented Feb 3, 2016

Hi @RobWin,

I think doing a auto-registration-property (default: true) is a reasonable thing and should be done. But I think we shouldn't add the endpoints, I think this requirement is very special. But it shouldn't be no problem to add a custom scheduled task wich can be startet/paused and uses the ApplicationRegistrator to de-/register.

@RobWin
Copy link
Contributor Author

RobWin commented Feb 3, 2016

And what about a separate endpoints module which can be plugged-in via a conditional bean? Similar to the admin-client-starter module? Just a management extension which can be added as a dependency by people who need it?

@joshiste
Copy link
Collaborator

joshiste commented Feb 4, 2016

I still hesitate to add the endpoints (even as a module).
I think deployment strategies are very different and I think this is a very special solution and won't be adopted broadly....

@RobWin
Copy link
Contributor Author

RobWin commented Feb 4, 2016

Ok

joshiste added a commit that referenced this issue Mar 2, 2016
This commit contains multiple changes:
 - Start the registration task after the ApplicationReady event. This makes
   AdminClientProperties.isReady() unnecessary.
 - The RegistarApplicationListener has two new public methods to start/stop the
   periodic registration task.
 - Add spring.boot.admin.auto-registration property (default: true). When this
   property is set the registration task is automatically scheduled after the
   ApplicationReadyEvent.

closes #151
@joshiste
Copy link
Collaborator

joshiste commented Mar 2, 2016

So I found (imho) a good solution: First of all I've added the auto-registration property.
Second there is an easy solution regarding the desired endpoint:
If you are using spring-cloud-context and leverage the extended environment-endpoint you can add this piece of code to your @Configuration:

    @Autowired
    private RegistrationApplicationListener listener;

    @Autowired
    private Environment env;

    @EventListener
    public void onContextRefresh(EnvironmentChangeEvent event) {
        Boolean runRegistration = env.getProperty("runRegistration", Boolean.class, true);
        LOGGER.info("Environment changed! runRegistration = {}", runRegistration);
        if (runRegistration) {
            listener.startRegisterTask();
        } else {
            listener.stopRegisterTask();
        }
    }

Now when you do a POST request to /env?runRegistration=false the registration task will be stopped...

@itsPoo
Copy link

itsPoo commented Feb 19, 2019

Hi @joshiste, @RobWin,

I have implemented Spring boot Admin client & server in my project and its successfully registering-an-application on the Spring boot Admin UI.

We are using PCF env for production/QA. Whenever application is deployed from PCF blue region to PCF green region it does not show the updates on the Spring boot Admin UI and we end up restaging all our applications on the production during deployment time. We would not want to do this activity. I understand Spring Boot application auto-registers when the applicationContext is started and ready and this does not happen for PCF Blue to PCF Green deployments.

I read this thread where its discussed above approach. Based on the change of the environment it will be register task again. Will this work for my problem?

Thanks for helping.
Poonam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants