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

Bug Fix #18

Merged
merged 5 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ packages:
github.com/metal-toolbox/ctrl:
config:
fileName: "mock_{{.InterfaceName | firstLower}}.go"
dir: "."
inpackage: True
interfaces:
TaskHandler:
Expand Down
18 changes: 9 additions & 9 deletions controller_nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,28 +409,28 @@ func (n *NatsController) stateFinalized(
eventAcknowleger.inProgress()
spanEvent(span, cond, n.ID(), "ackInProgress")

return false
return true

case complete:
le.Info("condition is complete")
eventAcknowleger.complete()
spanEvent(span, cond, n.ID(), "ackComplete")

return false
return true

case orphaned:
le.Info("restarting this condition")
eventAcknowleger.inProgress()
spanEvent(span, cond, n.ID(), "restarting condition")

return true
return false

case notStarted:
le.Info("starting new condition")
eventAcknowleger.inProgress()
spanEvent(span, cond, n.ID(), "start new condition")

return true
return false

// break out here, this is a new event
case indeterminate:
Expand All @@ -439,14 +439,14 @@ func (n *NatsController) stateFinalized(
eventAcknowleger.nak()
spanEvent(span, cond, n.ID(), "sent nack, indeterminate state")

return false
return true

default:
le.Warn("unexpected state")
eventAcknowleger.complete()
spanEvent(span, cond, n.ID(), "ackComplete")

return false
return true
}
}

Expand Down Expand Up @@ -545,8 +545,8 @@ func (n *NatsController) runTaskHandlerWithMonitor(ctx context.Context, task *co
defer span.End()

// local publish helper method
publish := func(state condition.State, status string, tsUpdate bool) {
if !tsUpdate {
publish := func(state condition.State, status string, tsUpdateOnly bool) {
if !tsUpdateOnly {
// append to existing status record, unless it was overwritten by the controller somehow
task.Status.Append(status)
task.State = state
Expand All @@ -555,7 +555,7 @@ func (n *NatsController) runTaskHandlerWithMonitor(ctx context.Context, task *co
if errPublish := publisher.Publish(
ctx,
task,
tsUpdate,
tsUpdateOnly,
); errPublish != nil {
n.logger.WithError(errPublish).Error("failed to publish update")
}
Expand Down
12 changes: 6 additions & 6 deletions controller_nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,42 +110,42 @@ func TestStateFinalized(t *testing.T) {
conditionID: uuid.New(),
state: inProgress,
expectMethod: "inProgress",
expectBool: false,
expectBool: true,
},
{
name: "Condition complete",
conditionID: uuid.New(),
state: complete,
expectMethod: "complete",
expectBool: false,
expectBool: true,
},
{
name: "Condition orphaned",
conditionID: uuid.New(),
state: orphaned,
expectMethod: "inProgress",
expectBool: true,
expectBool: false,
},
{
name: "Condition not started",
conditionID: uuid.New(),
state: notStarted,
expectMethod: "inProgress",
expectBool: true,
expectBool: false,
},
{
name: "Condition state indeterminate",
conditionID: uuid.New(),
state: indeterminate,
expectMethod: "nak",
expectBool: false,
expectBool: true,
},
{
name: "Condition state unexpected",
conditionID: uuid.New(),
state: 99, // unexpected lifecycle state
expectMethod: "complete",
expectBool: false,
expectBool: true,
},
}

Expand Down
65 changes: 23 additions & 42 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,53 @@ module github.com/metal-toolbox/ctrl
go 1.22

require (
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/google/uuid v1.6.0
github.com/metal-toolbox/conditionorc v1.1.1-0.20240731122812-e231e6525381
github.com/metal-toolbox/conditionorc v1.1.1-0.20240805163108-b1c018c91b87
github.com/metal-toolbox/rivets v1.2.0
github.com/nats-io/nats-server/v2 v2.10.12
github.com/nats-io/nats.go v1.36.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/otel v1.27.0
go.opentelemetry.io/otel/trace v1.27.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
go.uber.org/goleak v1.3.0
golang.org/x/oauth2 v0.22.0
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/banzaicloud/logrus-runtime-formatter v0.0.0-20190729070250-5ae5475bae5e // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmc-toolbox/common v0.0.0-20240510143200-3db7cecbb5a6 // indirect
github.com/bytedance/sonic v1.11.9 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/bmc-toolbox/common v0.0.0-20240723142833-87832458b53b // indirect
github.com/bytedance/sonic v1.12.0 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/cockroachdb/cockroach-go/v2 v2.3.8 // indirect
github.com/coreos/go-oidc v2.2.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/equinix-labs/otel-init-go v0.0.9 // indirect
github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/friendsofgo/errors v0.9.2 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.10.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gosimple/slug v1.14.0 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
Expand All @@ -72,16 +66,14 @@ require (
github.com/jackc/pgtype v1.14.3 // indirect
github.com/jackc/pgx/v4 v4.18.3 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/metal-toolbox/fleetdb v1.19.1 // indirect
github.com/metal-toolbox/fleetdb v1.19.3 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -98,7 +90,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/slack-go/slack v0.13.0 // indirect
github.com/slack-go/slack v0.13.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -107,9 +99,6 @@ require (
github.com/spf13/viper v1.19.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/files v1.0.1 // indirect
github.com/swaggo/gin-swagger v1.6.0 // indirect
github.com/swaggo/swag v1.16.3 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/volatiletech/inflect v0.0.1 // indirect
Expand All @@ -121,29 +110,21 @@ require (
github.com/volatiletech/strmangle v0.0.6 // indirect
go.hollow.sh/toolbox v0.6.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
gocloud.dev v0.37.0 // indirect
gocloud.dev v0.38.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.22.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.186.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/grpc v1.64.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
google.golang.org/api v0.189.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
Expand Down
Loading
Loading