-
Notifications
You must be signed in to change notification settings - Fork 6
/
actor_freeze.go
43 lines (38 loc) · 1.14 KB
/
actor_freeze.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
38
39
40
41
42
43
package object
import (
"context"
"time"
"github.com/opensvc/om3/core/actioncontext"
"github.com/opensvc/om3/core/freeze"
"github.com/opensvc/om3/core/statusbus"
)
// Frozen returns the unix timestamp of the last freeze.
func (t *actor) Frozen() time.Time {
return freeze.Frozen(t.path.FrozenFile())
}
// Freeze creates a persistant flag file that prevents orchestration
// of the object instance.
func (t *actor) Freeze(ctx context.Context) error {
ctx, stop := statusbus.WithContext(ctx, t.path)
defer stop()
ctx = actioncontext.WithProps(ctx, actioncontext.Freeze)
defer t.postActionStatusEval(ctx)
if err := freeze.Freeze(t.path.FrozenFile()); err != nil {
return err
}
t.log.Infof("now frozen")
return nil
}
// Unfreeze removes the persistant flag file that prevents orchestration
// of the object instance.
func (t *actor) Unfreeze(ctx context.Context) error {
ctx, stop := statusbus.WithContext(ctx, t.path)
defer stop()
ctx = actioncontext.WithProps(ctx, actioncontext.Unfreeze)
defer t.postActionStatusEval(ctx)
if err := freeze.Unfreeze(t.path.FrozenFile()); err != nil {
return err
}
t.log.Infof("now unfrozen")
return nil
}