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

[RCM-432] fix(remote-config): Clean remote state on error & use fixed fork of go-tuf #13517

Merged
merged 3 commits into from
Sep 15, 2022
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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ replace (
github.com/lxn/walk => github.com/lxn/walk v0.0.0-20180521183810-02935bac0ab8
github.com/mholt/archiver => github.com/mholt/archiver v2.0.1-0.20171012052341-26cf5bb32d07+incompatible
github.com/spf13/cast => github.com/DataDog/cast v1.3.1-0.20190301154711-1ee8c8bd14a3
github.com/theupdateframework/go-tuf => github.com/DataDog/go-tuf v0.3.0--fix-localmeta
github.com/ugorji/go => github.com/ugorji/go v1.1.7
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions pkg/config/remote/uptane/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewClient(cacheDB *bbolt.DB, cacheKey string, orgID int64) (*Client, error)
return c, nil
}

// Update updates the uptane client
// Update updates the uptane client and rollbacks in case of error
func (c *Client) Update(response *pbgo.LatestConfigsResponse) error {
c.Lock()
defer c.Unlock()
Expand All @@ -79,20 +79,28 @@ func (c *Client) Update(response *pbgo.LatestConfigsResponse) error {
// the defer is present to be sure a transaction is never left behind.
defer c.transactionalStore.rollback()

err := c.updateRepos(response)
err := c.update(response)
if err != nil {
c.configRemoteStore = newRemoteStoreConfig(c.targetStore)
c.directorRemoteStore = newRemoteStoreDirector(c.targetStore)
c.configTUFClient = client.NewClient(c.configLocalStore, c.configRemoteStore)
c.directorTUFClient = client.NewClient(c.directorLocalStore, c.directorRemoteStore)
return err
}
err = c.pruneTargetFiles()
return c.transactionalStore.commit()
}

// update updates the uptane client
func (c *Client) update(response *pbgo.LatestConfigsResponse) error {
err := c.updateRepos(response)
if err != nil {
return err
}
err = c.verify()
err = c.pruneTargetFiles()
if err != nil {
return err
}

return c.transactionalStore.commit()
return c.verify()
}

// TargetsCustom returns the current targets custom of this uptane client
Expand Down