-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
37 lines (35 loc) · 1.07 KB
/
main.go
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
package main
import (
"fmt"
"encoding/json"
"log"
"os"
"time"
tcclient "github.com/taskcluster/taskcluster-client-go"
"github.com/taskcluster/taskcluster-client-go/tcqueue"
)
func main() {
provisionerId := os.Args[1]
workerType := os.Args[2]
workerGroup := os.Args[3]
workerId := os.Args[4]
duration, err := time.ParseDuration(os.Args[5])
if err != nil {
log.Fatalf("Could not interpret duration '%v': %v", os.Args[5], err)
}
queue := tcqueue.NewFromEnv()
quarantineDeadline := time.Now().Add(duration)
qwr := &tcqueue.QuarantineWorkerRequest{
QuarantineUntil: tcclient.Time(quarantineDeadline),
}
response, err := queue.QuarantineWorker(provisionerId, workerType, workerGroup, workerId, qwr)
if err != nil {
log.Fatalf("Could not quarantine worker due to: %v", err)
}
bytes, err := json.MarshalIndent(response, "", " ")
if err != nil {
log.Fatalf("Could not quarantine worker due to: %v", err)
}
fmt.Printf("Response: %s\n", bytes)
fmt.Printf("Successfully updated quarantine for worker %v/%v/%v/%v\n", provisionerId, workerType, workerGroup, workerId)
}