-
Notifications
You must be signed in to change notification settings - Fork 78
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
[WIP] Feature/index/correction job #2152
Closed
Closed
Changes from 63 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
a1ee9d8
implement the initail framework
ykadowak 8a1221d
add corrector configuration
ykadowak fa1eb75
add corrector logic
ykadowak 39e7d71
add build make command for index correction binary
ykadowak 2bd41e9
add Dockerfile for index correction
ykadowak 6ef29e3
add Docker image for index job correction
ykadowak c7e1ff2
add timer
ykadowak 22dcaaa
fix tag align
ykadowak d51e26b
tmp
ykadowak 6aa8fde
fix log
ykadowak 41faffd
temporally implement two versions of correct function
ykadowak 8f5bcf0
set eg limit from config
ykadowak 065e9e2
add stream list concurrency config
ykadowak 8562a99
implement index id caching
ykadowak 81345f3
add config to use cache or not
ykadowak 77c33f0
style: Format code with prettier and gofumpt
deepsource-autofix[bot] 72c3956
refactor availableAddrs
ykadowak 5ffd9b3
add kvs range duration
ykadowak 5d3c6c7
add leftAgentAddrs for performance
ykadowak 3b3710b
Revert "add kvs range duration"
ykadowak 6b3934e
refactor
ykadowak bc591ae
fix without cache bug
ykadowak 5209a72
enable observability
ykadowak a0cb7aa
refactor
ykadowak b453e61
SIGTERM after complete
ykadowak db6868d
add metrics server
ykadowak 7a630b3
add pcache
ykadowak ca84f56
remove comment
ykadowak feda428
[TEMP] use pcache
ykadowak c229a87
[TMP] use pcache
ykadowak fa0b68b
fix empty shard returns error
ykadowak 06b312b
fix to use local map
ykadowak 490345f
[TMP] add prestop for pcache
ykadowak 05838c3
[TEMP] add pcache config
ykadowak 9805e7e
style: Format code with prettier and gofumpt
deepsource-autofix[bot] a0d698e
[TEMP] add pcache log
ykadowak 9e5f2ae
fix map alloc size
ykadowak 3728276
[TMP] Add bbolt cache
ykadowak 1678ff7
update bbolt
ykadowak 4f87601
fix bbolt bug
ykadowak 01225aa
add bbolt test
ykadowak 428ee35
[TEMP] use bbolt as persistent cache
ykadowak 81b800e
style: Format code with prettier and gofumpt
deepsource-autofix[bot] bfc73c4
add SetBatch to bbolt
ykadowak d4f3695
use batch to write map to disk
ykadowak 9975237
style: Format code with prettier and gofumpt
deepsource-autofix[bot] 2b00e05
delete the map elements on finalize
ykadowak a611e88
manually call GC after the map shrink
ykadowak e21441c
add limit to SetBatch goroutine number
ykadowak 66bc79c
stop unnecesarry GC
ykadowak 3a85405
increase eg limit to the MaxBatchSize
ykadowak 16d2986
use ch to set batch bbolt
ykadowak 919c9f9
fix servers shutdown properly
ykadowak 9bd57c0
use internal/kvs/bbolt
ykadowak 55c6586
refactor
ykadowak bc92686
always use bbolt cache for correction
ykadowak 319ec8b
update sample.yaml for correction
ykadowak eb5cdb0
style: format code with Prettier and Gofumpt
deepsource-autofix[bot] d3616e5
use go std slices pkg
ykadowak 89e2339
refactor
ykadowak e2eeabc
add comment
ykadowak 9a9e622
remove valdsync
ykadowak 4c22bcc
use vald errgroup
ykadowak e0ef7a8
Merge branch 'main' into feature/index/correction-job
ykadowak 4dc4801
refactor
ykadowak 9cbf664
style: format code with Prettier and Gofumpt
deepsource-autofix[bot] 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 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,188 @@ | ||
# | ||
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
name: "Build docker image: index-job-correction" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "*.*.*" | ||
- "v*.*.*" | ||
- "*.*.*-*" | ||
- "v*.*.*-*" | ||
paths: | ||
- ".github/actions/docker-build/actions.yaml" | ||
- ".github/workflows/dockers-index-job-correction.yml" | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/index/job/correction/**" | ||
- "cmd/index/job/correction/**" | ||
- "dockers/index/job/correction/Dockerfile" | ||
- "versions/GO_VERSION" | ||
pull_request: | ||
paths: | ||
- ".github/actions/docker-build/actions.yaml" | ||
- ".github/workflows/dockers-index-job-correction.yml" | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/index/job/correction/**" | ||
- "cmd/index/job/correction/**" | ||
- "dockers/index/job/correction/Dockerfile" | ||
- "versions/GO_VERSION" | ||
pull_request_target: | ||
paths: | ||
- ".github/actions/docker-build/actions.yaml" | ||
- ".github/workflows/dockers-index-job-correction.yml" | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/index/job/correction/**" | ||
- "cmd/index/job/correction/**" | ||
- "dockers/index/job/correction/Dockerfile" | ||
- "versions/GO_VERSION" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref != 'refs/heads/main' && github.ref || github.sha }}-${{ github.event_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
dump_contexts_to_log: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dump GitHub context | ||
id: github_context_step | ||
run: echo $JSON | ||
env: | ||
JSON: ${{ toJSON(github) }} | ||
- name: Dump job context | ||
run: echo $JSON | ||
env: | ||
JSON: ${{ toJSON(job) }} | ||
- name: Dump steps context | ||
run: echo $JSON | ||
env: | ||
JSON: ${{ toJSON(steps) }} | ||
- name: Dump runner context | ||
run: echo $JSON | ||
env: | ||
JSON: ${{ toJSON(runner) }} | ||
- name: Dump strategy context | ||
run: echo $JSON | ||
env: | ||
JSON: ${{ toJSON(strategy) }} | ||
- name: Dump matrix context | ||
run: echo $JSON | ||
env: | ||
JSON: ${{ toJSON(matrix) }} | ||
build: | ||
strategy: | ||
max-parallel: 4 | ||
runs-on: ubuntu-latest | ||
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) || (github.event.pull_request.head.repo.fork == true && github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'ci/approved')) || (github.event_name == 'push' && github.ref == 'refs/heads/main') || startsWith( github.ref, 'refs/tags/') }} | ||
steps: | ||
- name: Get ref | ||
id: ref | ||
run: | | ||
if [ ${{ github.event.pull_request.head.sha }} != "" ]; then | ||
echo ref=${{ github.event.pull_request.head.sha }} >> $GITHUB_OUTPUT | ||
else | ||
echo ref=${{ github.sha }} >> $GITHUB_OUTPUT | ||
fi | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ steps.ref.outputs.ref }} | ||
- name: set git config | ||
run: | | ||
git config --global --add safe.directory ${GITHUB_WORKSPACE} | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
with: | ||
platforms: all | ||
- name: Setup Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
buildkitd-flags: "--debug" | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.PACKAGE_USER }} | ||
password: ${{ secrets.PACKAGE_TOKEN }} | ||
- name: Build and Publish | ||
id: build_and_publish | ||
uses: ./.github/actions/docker-build | ||
with: | ||
target: index-job-correction | ||
builder: ${{ steps.buildx.outputs.name }} | ||
- name: Initialize CodeQL | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: github/codeql-action/init@v2 | ||
- name: Run vulnerability scanner (table) | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: "${{ steps.build_and_publish.outputs.IMAGE_NAME }}:${{ steps.build_and_publish.outputs.PRIMARY_TAG }}" | ||
format: "table" | ||
- name: Run vulnerability scanner (sarif) | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: "${{ steps.build_and_publish.outputs.IMAGE_NAME }}:${{ steps.build_and_publish.outputs.PRIMARY_TAG }}" | ||
format: "template" | ||
template: "@/contrib/sarif.tpl" | ||
output: "trivy-results.sarif" | ||
- name: Upload Trivy scan results to Security tab | ||
if: startsWith( github.ref, 'refs/tags/') | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: "trivy-results.sarif" | ||
slack: | ||
name: Slack notification | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' || startsWith( github.ref, 'refs/tags/') | ||
steps: | ||
- uses: technote-space/workflow-conclusion-action@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: 8398a7/action-slack@v3 | ||
with: | ||
author_name: index-job-correction image build | ||
status: ${{ env.WORKFLOW_CONCLUSION }} | ||
only_mention_fail: channel | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_WEBHOOK_URL }} |
This file contains 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 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 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 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 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,55 @@ | ||
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/vdaas/vald/internal/errors" | ||
"github.com/vdaas/vald/internal/info" | ||
"github.com/vdaas/vald/internal/log" | ||
"github.com/vdaas/vald/internal/runner" | ||
"github.com/vdaas/vald/internal/safety" | ||
"github.com/vdaas/vald/pkg/index/job/correction/config" | ||
"github.com/vdaas/vald/pkg/index/job/correction/usecase" | ||
) | ||
|
||
const ( | ||
maxVersion = "v0.0.10" | ||
minVersion = "v0.0.0" | ||
name = "index correction job" | ||
) | ||
|
||
func main() { | ||
if err := safety.RecoverFunc(func() error { | ||
return runner.Do( | ||
context.Background(), | ||
runner.WithName(name), | ||
runner.WithVersion(info.Version, maxVersion, minVersion), | ||
runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { | ||
cfg, err := config.NewConfig(path) | ||
if err != nil { | ||
return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") | ||
} | ||
return cfg, &cfg.GlobalConfig, nil | ||
}), | ||
runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { | ||
return usecase.New(cfg.(*config.Data)) | ||
}), | ||
) | ||
})(); err != nil { | ||
log.Fatal(err, info.Get()) | ||
return | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
type assertion must be checked (forcetypeassert)