Skip to content

Refactor SOCI Init logic#1504

Merged
Kern-- merged 1 commit into
awslabs:mainfrom
Kern--:init-soci-context
Apr 10, 2025
Merged

Refactor SOCI Init logic#1504
Kern-- merged 1 commit into
awslabs:mainfrom
Kern--:init-soci-context

Conversation

@Kern--
Copy link
Copy Markdown

@Kern-- Kern-- commented Apr 4, 2025

Issue #, if available:

Description of changes:

This change moves most of the SOCI init logic out of SociContext.Init into fs.fetchSociIndex. This is to reduce the number of args we need to sent to SociContext.Init.

There are 3 logic changes here:

  1. Remove the cached error lock on SociContext. sync.Once guarantees that no call to Do will return until exactly 1 executes the function. Therefore, there was never any concurrent access as the write to the cached error will always happen before any read.
  2. The SOCI index digest is parsed rather than casted to a digest.Digest.
  3. FetchSociArtifacts now uses the Mount context instead of fs.ctx. fs.ctx is tied to the lifetime of the fs object which is the fs object which is the lifetime of the snapshotter. The mount ctx is tied to the lifetime of the snapshot.Prepare call. already merged in Always use namespace from request context #1509

Testing performed:
make test && make integration

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Kern-- Kern-- requested a review from a team as a code owner April 4, 2025 22:02
@github-actions github-actions Bot added the go Pull requests that update Go code label Apr 4, 2025
@Kern-- Kern-- closed this Apr 4, 2025
@Kern-- Kern-- reopened this Apr 4, 2025
@Kern-- Kern-- closed this Apr 4, 2025
@Kern-- Kern-- reopened this Apr 4, 2025
Comment thread fs/fs.go Outdated
This change moves most of the SOCI init logic out of `SociContext.Init`
into `fs.fetchSociIndex`. This is to reduce the number of args we need
to sent to `SociContext.Init`.

There are 2 logic changes here:

1. Remove the cached error lock on `SociContext`. `sync.Once` guarantees
   that no call to `Do` will return until exactly 1 executes the
   function. Therefore, there was never any concurrent access as the
   write to the cached error will always happen before any read.
2. The SOCI index digest is parsed rather than casted to a
   digest.Digest.

Signed-off-by: Kern Walster <walster@amazon.com>
@Kern-- Kern-- force-pushed the init-soci-context branch from 1ea1671 to 0d8d0de Compare April 8, 2025 19:56
@austinvazquez
Copy link
Copy Markdown
Contributor

LGTM, TIL you could wrap multiple errors in the same error format. :)

@Shubhranshu153
Copy link
Copy Markdown
Contributor

LGTM

@Kern-- Kern-- merged commit 15370c6 into awslabs:main Apr 10, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants