Skip to content

Commit

Permalink
Remove saved objects code (#110)
Browse files Browse the repository at this point in the history
* Remove saved objects code

* Make check happy
  • Loading branch information
aleksmaus authored Mar 1, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent f96943f commit 656cffb
Showing 17 changed files with 80 additions and 1,494 deletions.
136 changes: 68 additions & 68 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1755,37 +1755,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/mitchellh/mapstructure
Version: v1.3.3
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/mitchellh/mapstructure@v1.3.3/LICENSE:

The MIT License (MIT)

Copyright (c) 2013 Mitchell Hashimoto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/rs/xid
Version: v1.2.1
@@ -2061,43 +2030,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


--------------------------------------------------------------------------------
Dependency : golang.org/x/crypto
Version: v0.0.0-20200622213623-75b288015ac9
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/golang.org/x/crypto@v0.0.0-20200622213623-75b288015ac9/LICENSE:

Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : golang.org/x/sync
Version: v0.0.0-20200625203802-6e8e738ad208
@@ -27443,6 +27375,37 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/mitchellh/mapstructure
Version: v1.1.2
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/mitchellh/mapstructure@v1.1.2/LICENSE:

The MIT License (MIT)

Copyright (c) 2013 Mitchell Hashimoto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/modern-go/concurrent
Version: v0.0.0-20180306012644-bacd9c7ef1dd
@@ -35190,6 +35153,43 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


--------------------------------------------------------------------------------
Dependency : golang.org/x/crypto
Version: v0.0.0-20200622213623-75b288015ac9
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/golang.org/x/crypto@v0.0.0-20200622213623-75b288015ac9/LICENSE:

Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : golang.org/x/exp
Version: v0.0.0-20191227195350-da58074b4299
15 changes: 8 additions & 7 deletions cmd/fleet/bulkCheckin.go
Original file line number Diff line number Diff line change
@@ -12,15 +12,16 @@ import (

"github.com/elastic/fleet-server/v7/internal/pkg/bulk"
"github.com/elastic/fleet-server/v7/internal/pkg/dl"
"github.com/elastic/fleet-server/v7/internal/pkg/saved"

"github.com/rs/zerolog/log"
)

type Fields map[string]interface{}

const kBulkCheckinFlushInterval = 10 * time.Second

type PendingData struct {
fields saved.Fields
fields Fields
seqNo int64
}

@@ -37,10 +38,10 @@ func NewBulkCheckin(bulker bulk.Bulk) *BulkCheckin {
}
}

func (bc *BulkCheckin) CheckIn(id string, fields saved.Fields, seqno int64) error {
func (bc *BulkCheckin) CheckIn(id string, fields Fields, seqno int64) error {

if fields == nil {
fields = make(saved.Fields)
fields = make(Fields)
}

timeNow := time.Now().UTC().Format(time.RFC3339)
@@ -52,7 +53,7 @@ func (bc *BulkCheckin) CheckIn(id string, fields saved.Fields, seqno int64) erro
return nil
}

func (bc *BulkCheckin) Run(ctx context.Context, sv saved.CRUD) error {
func (bc *BulkCheckin) Run(ctx context.Context) error {

tick := time.NewTicker(kBulkCheckinFlushInterval)

@@ -61,7 +62,7 @@ LOOP:
for {
select {
case <-tick.C:
if err = bc.flush(ctx, sv); err != nil {
if err = bc.flush(ctx); err != nil {
log.Error().Err(err).Msg("Eat bulk checkin error; Keep on truckin'")
err = nil
}
@@ -75,7 +76,7 @@ LOOP:
return err
}

func (bc *BulkCheckin) flush(ctx context.Context, sv saved.CRUD) error {
func (bc *BulkCheckin) flush(ctx context.Context) error {
start := time.Now()

bc.mut.Lock()
36 changes: 0 additions & 36 deletions cmd/fleet/dsl.go

This file was deleted.

7 changes: 3 additions & 4 deletions cmd/fleet/handleCheckin.go
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ import (
"github.com/elastic/fleet-server/v7/internal/pkg/model"
"github.com/elastic/fleet-server/v7/internal/pkg/monitor"
"github.com/elastic/fleet-server/v7/internal/pkg/policy"
"github.com/elastic/fleet-server/v7/internal/pkg/saved"

"github.com/julienschmidt/httprouter"
"github.com/rs/zerolog/log"
@@ -347,16 +346,16 @@ func findAgentByApiKeyId(ctx context.Context, bulker bulk.Bulk, id string) (*mod

// parseMeta compares the agent and the request local_metadata content
// and returns fields to update the agent record or nil
func parseMeta(agent *model.Agent, req *CheckinRequest) (fields saved.Fields, err error) {
func parseMeta(agent *model.Agent, req *CheckinRequest) (fields Fields, err error) {
// Quick comparison first
if bytes.Equal(req.LocalMeta, agent.LocalMetadata) {
log.Trace().Msg("Quick comparing local metadata is equal")
return nil, nil
}

// Compare local_metadata content and update if different
var reqLocalMeta saved.Fields
var agentLocalMeta saved.Fields
var reqLocalMeta Fields
var agentLocalMeta Fields
err = json.Unmarshal(req.LocalMeta, &reqLocalMeta)
if err != nil {
return nil, err
6 changes: 1 addition & 5 deletions cmd/fleet/main.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ import (
"github.com/elastic/fleet-server/v7/internal/pkg/policy"
"github.com/elastic/fleet-server/v7/internal/pkg/profile"
"github.com/elastic/fleet-server/v7/internal/pkg/reload"
"github.com/elastic/fleet-server/v7/internal/pkg/saved"
"github.com/elastic/fleet-server/v7/internal/pkg/signal"
"github.com/elastic/fleet-server/v7/internal/pkg/status"

@@ -469,7 +468,6 @@ func (f *FleetServer) runServer(ctx context.Context, cfg *config.Config) (err er
if err != nil {
return err
}
sv := saved.NewMgr(bulker, savedObjectKey())

// Replacing to errgroup context
g, ctx := errgroup.WithContext(ctx)
@@ -512,9 +510,7 @@ func (f *FleetServer) runServer(ctx context.Context, cfg *config.Config) (err er
}

bc := NewBulkCheckin(bulker)
g.Go(loggedRunFunc(ctx, "Bulk checkin", func(ctx context.Context) error {
return bc.Run(ctx, sv)
}))
g.Go(loggedRunFunc(ctx, "Bulk checkin", bc.Run))

ct := NewCheckinT(f.cfg, f.cache, bc, pm, am, ad, tr, bulker)
et, err := NewEnrollerT(&f.cfg.Inputs[0].Server, bulker, f.cache)
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -14,12 +14,10 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/golang-lru v0.5.2-0.20190520140433-59383c442f7d
github.com/julienschmidt/httprouter v1.3.0
github.com/mitchellh/mapstructure v1.3.3
github.com/rs/xid v1.2.1
github.com/rs/zerolog v1.19.0
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -360,8 +360,6 @@ github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18
github.com/mitchellh/hashstructure v0.0.0-20170116052023-ab25296c0f51/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
Loading

0 comments on commit 656cffb

Please sign in to comment.