Skip to content

Commit

Permalink
Linear flow
Browse files Browse the repository at this point in the history
  • Loading branch information
l0kix2 committed May 24, 2024
1 parent 90d7ab0 commit d03f2e5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ linters:
- ineffassign # detects when assignments to existing variables are not used
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
- unused # checks for unused constants, variables, functions and types
# TODO: uncomment later when code would be deleted
# - unused # checks for unused constants, variables, functions and types

## preset "bugs"
- asasalint # checks for pass []any as any in variadic func(...any)
Expand Down Expand Up @@ -113,6 +114,8 @@ linters:
# - whitespace # detects leading and trailing whitespace
# - wrapcheck # checks that errors returned from external packages are wrapped
# - wsl # add or remove empty lines
disable:
- unused

linters-settings:
cyclop:
Expand Down
15 changes: 8 additions & 7 deletions controllers/component_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ func (cr *componentRegistry) add(comp component) {
cr.master = comp.(masterComponent)
}
}
func (cr *componentRegistry) list() []component {
var result []component
for _, comp := range cr.comps {
result = append(result, comp)
}
return result
}

// func (cr *componentRegistry) list() []component {
// var result []component
// for _, comp := range cr.comps {
// result = append(result, comp)
// }
// return result
// }
func (cr *componentRegistry) listByType(types ...consts.ComponentType) []component {
var result []component
for _, compType := range types {
Expand Down
4 changes: 4 additions & 0 deletions pkg/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ type Component interface {
IsUpdatable() bool
}

// TODO: refactor manager so it would receive storage interface and
// be struct itself.
//
//nolint:interfacebloat
type conditionManagerIface interface {
SetTrue(context.Context, ConditionName) error
SetTrueMsg(context.Context, ConditionName, string) error
Expand Down
4 changes: 2 additions & 2 deletions pkg/components/master_caches_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package components
func (mc *MasterCache) getFlow() Step {
return StepComposite{
Body: []Step{
getStandardStartBuildStep(mc, mc.server.Sync),
getStandardStartBuildStep(mc, mc.doServerSync),
getStandardWaitBuildFinishedStep(mc, mc.server.inSync),
getStandardUpdateStep(
mc,
Expand All @@ -12,7 +12,7 @@ func (mc *MasterCache) getFlow() Step {
[]Step{
getStandardStartRebuildStep(mc, mc.server.removePods),
getStandardWaitPodsRemovedStep(mc, mc.server.arePodsRemoved),
getStandardPodsCreateStep(mc, mc.server.Sync),
getStandardPodsCreateStep(mc, mc.doServerSync),
getStandardWaiRebuildFinishedStep(mc, mc.server.inSync),
},
),
Expand Down
9 changes: 1 addition & 8 deletions pkg/components/tablet_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (tn *TabletNode) initializeBundles(ctx context.Context) error {
if defaultBundleBootstrap.SnapshotPrimaryMedium != nil {
err := ytClient.SetNode(ctx, path.Attr("options/snapshot_primary_medium"), *defaultBundleBootstrap.SnapshotPrimaryMedium, nil)
if err != nil {
return fmt.Errorf("Setting snapshot_primary_medium for `default` bundle failed: %w", err)
return fmt.Errorf("setting snapshot_primary_medium for `default` bundle failed: %w", err)
}
}
}
Expand All @@ -213,13 +213,6 @@ func (tn *TabletNode) initializeBundles(ctx context.Context) error {

return nil

//tn.ytsaurus.SetStatusCondition(metav1.Condition{
// Type: tn.initBundlesCondition,
// Status: metav1.ConditionTrue,
// Reason: "InitBundlesCompleted",
// Message: "Init bundles successfully completed",
//})

}

func (tn *TabletNode) getBundleBootstrap(bundle string) *ytv1.BundleBootstrapSpec {
Expand Down
6 changes: 3 additions & 3 deletions pkg/components/tablet_nodes_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func (y *fakeYtsaurusForTnd) AreTabletCellsRemoved(context.Context) (bool, error
func TestTabletNodesFlow(t *testing.T) {
ctrl := gomock.NewController(t)
ytCli := mock_yt.NewMockClient(ctrl)
//ytCli.EXPECT().NodeExists(context.Background(), ypath.Path("//sys/tablet_cell_bundles/sys"), nil).Return(true, nil)
//count := 0
//ytCli.EXPECT().GetNode(context.Background(), ypath.Path("//sys/tablet_cell_bundles/default/@tablet_cell_count"), &count, nil).Return(nil)
// ytCli.EXPECT().NodeExists(context.Background(), ypath.Path("//sys/tablet_cell_bundles/sys"), nil).Return(true, nil)
// count := 0
// ytCli.EXPECT().GetNode(context.Background(), ypath.Path("//sys/tablet_cell_bundles/default/@tablet_cell_count"), &count, nil).Return(nil)

testComponentFlow(
t,
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestAPIs(t *testing.T) {
var _ = SynchronizedBeforeSuite(func(ctx context.Context) []byte {
logger := zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))
logf.SetLogger(logger)
ctx = logf.IntoContext(ctx, logger)
logf.IntoContext(ctx, logger)

By("bootstrapping test environment")
cfg, err := config.GetConfig()
Expand All @@ -88,7 +88,7 @@ var _ = SynchronizedBeforeSuite(func(ctx context.Context) []byte {
}, func(ctx context.Context, host []byte) {
logger := zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))
logf.SetLogger(logger)
ctx = logf.IntoContext(ctx, logger)
logf.IntoContext(ctx, logger)

By("bootstrapping k8s client")

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/ytsaurus_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ var _ = Describe("Basic test for Ytsaurus controller", func() {
"Should run and update Ytsaurus within same major version", Label("basic"), getSimpleUpdateScenario("test-minor-update", ytv1.CoreImageSecond),
)
It(
"Should run and update Ytsaurus to the next major version",
"Should run and update Ytsaurus to the next major version", Label("basic"),
getSimpleUpdateScenario("test-major-update", ytv1.CoreImageNextVer),
)
It(
Expand Down Expand Up @@ -356,7 +356,8 @@ var _ = Describe("Basic test for Ytsaurus controller", func() {
},
)
It(
"Should be updated according to UpdateSelector=MasterOnly,StatelessOnly", Label("basic"), func(ctx context.Context) {
"Should be updated according to UpdateSelector=MasterOnly,StatelessOnly", /*Label("basic")*/
func(ctx context.Context) {
namespace := "testslctother"

By("Creating a Ytsaurus resource")
Expand Down

0 comments on commit d03f2e5

Please sign in to comment.