diff --git a/.golangci.yaml b/.golangci.yaml index e701c219..a6919309 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -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) @@ -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: diff --git a/controllers/component_registry.go b/controllers/component_registry.go index 88ef58ee..8df4e3d2 100644 --- a/controllers/component_registry.go +++ b/controllers/component_registry.go @@ -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 { diff --git a/pkg/components/component.go b/pkg/components/component.go index 9ff5521c..336f181e 100644 --- a/pkg/components/component.go +++ b/pkg/components/component.go @@ -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 diff --git a/pkg/components/master_caches_flow.go b/pkg/components/master_caches_flow.go index 88fbe437..7a4529d1 100644 --- a/pkg/components/master_caches_flow.go +++ b/pkg/components/master_caches_flow.go @@ -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, @@ -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), }, ), diff --git a/pkg/components/tablet_node.go b/pkg/components/tablet_node.go index 2afa4718..f1e62c61 100644 --- a/pkg/components/tablet_node.go +++ b/pkg/components/tablet_node.go @@ -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) } } } @@ -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 { diff --git a/pkg/components/tablet_nodes_local_test.go b/pkg/components/tablet_nodes_local_test.go index 4f1583b7..6b62281b 100644 --- a/pkg/components/tablet_nodes_local_test.go +++ b/pkg/components/tablet_nodes_local_test.go @@ -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, diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index ada0ebf9..6cdef8dd 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -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() @@ -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") diff --git a/test/e2e/ytsaurus_controller_test.go b/test/e2e/ytsaurus_controller_test.go index f6b30abe..24082f70 100644 --- a/test/e2e/ytsaurus_controller_test.go +++ b/test/e2e/ytsaurus_controller_test.go @@ -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( @@ -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")