summaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/FailureRedeployer.java
blob: c8831bd6a56fe12dd220b31d58928b8c0d70d43b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.maintenance;

import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.application.ApplicationList;

import java.time.Duration;
import java.util.List;

/**
 * Attempts redeployment of failed jobs and deployments.
 * 
 * @author bratseth
 * @author mpolden
 */
public class FailureRedeployer extends Maintainer {

    private final static Duration jobTimeout = Duration.ofHours(12);
    
    public FailureRedeployer(Controller controller, Duration interval, JobControl jobControl) {
        super(controller, interval, jobControl);
    }

    @Override
    public void maintain() {
        List<Application> applications = ApplicationList.from(controller().applications().asList())
                .notPullRequest()
                .asList();
        applications.forEach(application -> triggerFailing(application, jobTimeout));
    }

    private void triggerFailing(Application application, Duration timeout) {
        controller().applications().deploymentTrigger().triggerFailing(application.id(), timeout);
    }

}