-
Notifications
You must be signed in to change notification settings - Fork 15
Implementing New Sequence Number Management and Fixing how we get the extension Sequence Number #83
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5e9dfd1
feat: Add new SequenceNumberManager interface and implementation
klugorosado 16f2eed
feat: Add enablePre function to handle sequence number processing
klugorosado bab2e49
Ran go mod tidy and go mod vendor.
klugorosado 8a1f5cc
Bump google.golang.org/protobuf from 1.27.1 to 1.33.0
dependabot[bot] b03100e
update modules.txt
klugorosado 4d59c2b
Merge branch 'master' into dev/klugorosado/fixProvisioning
klugorosado 8266818
Refactor SequenceNumberManager
klugorosado 85b404e
Add Mock SequenceNumberManager
klugorosado 7fb4970
changed Seqnum type from int to uint
klugorosado f82bc65
feat: Allowed current Sequence number and mrseq to be equal to allow …
klugorosado 17a5b83
refactored sequence number to use newly created gomock structs
klugorosado 99e183f
ran go mod tidy and go mod vendor
klugorosado File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,3 +28,4 @@ _testmain.go | |
| *.exe | ||
| *.test | ||
| *.prof | ||
| mrseq | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package seqno | ||
|
|
||
| import ( | ||
| "github.com/Azure/applicationhealth-extension-linux/pkg/logging" | ||
| "github.com/Azure/azure-extension-platform/pkg/extensionerrors" | ||
| "github.com/Azure/azure-extension-platform/pkg/seqno" | ||
| "github.com/go-kit/log" | ||
| ) | ||
|
|
||
| type SequenceNumberManager interface { | ||
| // GetCurrentSequenceNumber returns the current sequence number the extension is using | ||
| GetCurrentSequenceNumber(el log.Logger, name, version string) (uint, error) | ||
|
|
||
| // GetSequenceNumber retrieves the sequence number from the MRSEQ file | ||
| GetSequenceNumber(name, version string) (uint, error) | ||
|
|
||
| // SetSequenceNumber sets the sequence number to the MRSEQ file. | ||
| SetSequenceNumber(name, version string, seqNo uint) error | ||
|
|
||
| // FindSeqNum returns the requested the sequence number from either the environment variable or | ||
| // the most recently used file under the config folder. | ||
| // Note that this is different than just choosing the highest number, which may be incorrect | ||
| FindSeqNum(configFolder string) (uint, error) | ||
| } | ||
|
|
||
| type SeqNumManager struct { | ||
| } | ||
|
|
||
| func (s *SeqNumManager) GetSequenceNumber(name string, version string) (uint, error) { | ||
| retriever := &seqno.ProdSequenceNumberRetriever{} | ||
| return retriever.GetSequenceNumber(name, version) | ||
| } | ||
|
|
||
| // SetSequenceNumber sets the sequence number for the given extension name and version. | ||
| // It takes the extension name, extension version, and sequence number as parameters. | ||
| // The sequence number is an integer that represents the order in which the extension was installed. | ||
| // It returns an error if there was a problem setting the sequence number. | ||
| func (s *SeqNumManager) SetSequenceNumber(name, version string, seqNo uint) error { | ||
| return seqno.SetSequenceNumber(name, version, seqNo) | ||
| } | ||
|
|
||
| // FindSeqNum returns the requested the sequence number from either the environment variable or | ||
| // the most recently used file under the config folder. | ||
| // Note that this is different than just choosing the highest number, which may be incorrect | ||
| func (s *SeqNumManager) FindSeqNum(configFolder string) (uint, error) { | ||
| return seqno.FindSeqNum(logging.NewNopLogger(), configFolder) | ||
| } | ||
|
|
||
| // GetCurrentSequenceNumber returns the current sequence number the extension is using | ||
| func (s *SeqNumManager) GetCurrentSequenceNumber(lg log.Logger, name, version string) (sn uint, _ error) { | ||
| sequenceNumber, err := s.GetSequenceNumber(name, version) | ||
| if err == extensionerrors.ErrNotFound || err == extensionerrors.ErrNoMrseqFile { | ||
| // If we can't find the sequence number, then it's possible that the extension | ||
| // hasn't been installed yet. Go back to 0. | ||
| lg.Log("event", "Couldn't find current sequence number, likely first execution of the extension, returning sequence number 0") | ||
| return 0, nil | ||
| } | ||
|
|
||
| return sequenceNumber, err | ||
| } | ||
|
|
||
| func New() SequenceNumberManager { | ||
| return &SeqNumManager{} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.