Skip to content

Commit

Permalink
Merge pull request #163 from cybozu-go/no-record-audit-for-state
Browse files Browse the repository at this point in the history
[audit] No longer record state transition
  • Loading branch information
kfyharukz authored Jul 4, 2019
2 parents cadf78b + 86d57b9 commit 8ed916f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 17 additions & 0 deletions gql/resolver_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sort"
"time"

"github.com/cybozu-go/log"
"github.com/cybozu-go/sabakan/v2"
"github.com/vektah/gqlparser/gqlerror"
)
Expand Down Expand Up @@ -110,6 +111,11 @@ type mutationResolver struct{ *Resolver }
func (r *mutationResolver) SetMachineState(ctx context.Context, serial string, state sabakan.MachineState) (*sabakan.MachineStatus, error) {
now := time.Now()

log.Info("SetMachineState is called", map[string]interface{}{
"serial": serial,
"state": state,
})

err := r.Model.Machine.SetState(ctx, serial, state)
if err != nil {
switch err {
Expand Down Expand Up @@ -175,6 +181,11 @@ type queryResolver struct{ *Resolver }

func (r *queryResolver) Machine(ctx context.Context, serial string) (*sabakan.Machine, error) {
now := time.Now()

log.Info("Machine is called", map[string]interface{}{
"serial": serial,
})

machine, err := r.Model.Machine.Get(ctx, serial)
if err != nil {
return &sabakan.Machine{}, err
Expand All @@ -184,6 +195,12 @@ func (r *queryResolver) Machine(ctx context.Context, serial string) (*sabakan.Ma
}
func (r *queryResolver) SearchMachines(ctx context.Context, having, notHaving *MachineParams) ([]sabakan.Machine, error) {
now := time.Now()

log.Info("SearchMachines is called", map[string]interface{}{
"having": having,
"nothaving": notHaving,
})

machines, err := r.Model.Machine.Query(ctx, sabakan.Query{})
if err != nil {
return nil, err
Expand Down
2 changes: 0 additions & 2 deletions models/etcd/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ RETRY:
}
}

d.addLog(ctx, time.Now(), tresp.Header.Revision, sabakan.AuditMachines, serial,
"state", state.String())
return nil
}

Expand Down

0 comments on commit 8ed916f

Please sign in to comment.