-
Notifications
You must be signed in to change notification settings - Fork 79
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
Backport PR #2702 to release/v1.7 for feat: Implement delete expired index job #2722
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# | ||
# Copyright (C) 2019-2024 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. | ||
# | ||
|
||
# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go | ||
|
||
name: 'Build docker image: index-deletion' | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/v*.* | ||
- '!release/v*.*.*' | ||
tags: | ||
- '*.*.*' | ||
- v*.*.* | ||
- '*.*.*-*' | ||
- v*.*.*-* | ||
pull_request: | ||
paths: | ||
- hack/docker/gen/main.go | ||
- dockers/index/job/deletion/Dockerfile | ||
- hack/actions/gen/main.go | ||
- .github/workflows/dockers-index-deletion-image.yaml | ||
- .github/actions/docker-build/action.yaml | ||
- .github/workflows/_docker-image.yaml | ||
- cmd/index/job/deletion/** | ||
- pkg/index/job/deletion/** | ||
- apis/grpc/** | ||
- apis/proto/** | ||
- go.mod | ||
- go.sum | ||
- versions/GO_VERSION | ||
- internal/** | ||
- '!internal/**/*_test.go' | ||
- '!internal/**/*_mock.go' | ||
- '!internal/db/**' | ||
- '!internal/k8s/**' | ||
- Makefile | ||
- Makefile.d/** | ||
pull_request_target: | ||
paths: | ||
- hack/docker/gen/main.go | ||
- dockers/index/job/deletion/Dockerfile | ||
- hack/actions/gen/main.go | ||
- .github/workflows/dockers-index-deletion-image.yaml | ||
- .github/actions/docker-build/action.yaml | ||
- .github/workflows/_docker-image.yaml | ||
- cmd/index/job/deletion/** | ||
- pkg/index/job/deletion/** | ||
- apis/grpc/** | ||
- apis/proto/** | ||
- go.mod | ||
- go.sum | ||
- versions/GO_VERSION | ||
- internal/** | ||
- '!internal/**/*_test.go' | ||
- '!internal/**/*_mock.go' | ||
- '!internal/db/**' | ||
- '!internal/k8s/**' | ||
- Makefile | ||
- Makefile.d/** | ||
jobs: | ||
build: | ||
uses: ./.github/workflows/_docker-image.yaml | ||
with: | ||
target: index-deletion | ||
secrets: inherit |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# | ||
# Copyright (C) 2019-2024 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. | ||
# | ||
|
||
# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go | ||
|
||
name: "Build docker image: index-deletion" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/v*.* | ||
- "!release/v*.*.*" | ||
tags: | ||
- "*.*.*" | ||
- v*.*.* | ||
- "*.*.*-*" | ||
- v*.*.*-* | ||
pull_request: | ||
paths: | ||
- hack/docker/gen/main.go | ||
- dockers/index/job/deletion/Dockerfile | ||
- hack/actions/gen/main.go | ||
- .github/workflows/dockers-index-deletion-image.yaml | ||
- .github/actions/docker-build/action.yaml | ||
- .github/workflows/_docker-image.yaml | ||
- cmd/index/job/deletion/** | ||
- pkg/index/job/deletion/** | ||
- apis/grpc/** | ||
- apis/proto/** | ||
- go.mod | ||
- go.sum | ||
- versions/GO_VERSION | ||
- internal/** | ||
- "!internal/**/*_test.go" | ||
- "!internal/**/*_mock.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- Makefile | ||
- Makefile.d/** | ||
pull_request_target: | ||
paths: | ||
- hack/docker/gen/main.go | ||
- dockers/index/job/deletion/Dockerfile | ||
- hack/actions/gen/main.go | ||
- .github/workflows/dockers-index-deletion-image.yaml | ||
- .github/actions/docker-build/action.yaml | ||
- .github/workflows/_docker-image.yaml | ||
- cmd/index/job/deletion/** | ||
- pkg/index/job/deletion/** | ||
- apis/grpc/** | ||
- apis/proto/** | ||
- go.mod | ||
- go.sum | ||
- versions/GO_VERSION | ||
- internal/** | ||
- "!internal/**/*_test.go" | ||
- "!internal/**/*_mock.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- Makefile | ||
- Makefile.d/** | ||
Comment on lines
+32
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider optimizing path filters for better maintainability. The current path filters are quite broad and might trigger unnecessary builds. Consider:
Example optimization: pull_request:
paths:
- hack/docker/gen/main.go
- dockers/index/job/deletion/Dockerfile
- hack/actions/gen/main.go
- .github/workflows/dockers-index-deletion-image.yaml
- .github/actions/docker-build/action.yaml
- .github/workflows/_docker-image.yaml
- cmd/index/job/deletion/**
- pkg/index/job/deletion/**
- - apis/grpc/**
- - apis/proto/**
+ - apis/grpc/v*/agent/**
+ - apis/proto/v*/agent/**
- - go.mod
- - go.sum
+ # Only trigger on dependency changes affecting deletion packages
+ - 'go.{mod,sum} if:@@ pkg/index/job/deletion'
- - internal/**
- - "!internal/**/*_test.go"
- - "!internal/**/*_mock.go"
- - "!internal/db/**"
- - "!internal/k8s/**"
+ - internal/core/algorithm/**
+ - internal/core/alogrithm/ngt/**
- Makefile
- Makefile.d/**
Comment on lines
+53
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security: Restrict pull_request_target usage. The current configuration using
Example implementation: pull_request_target:
+ # Only run on trusted PRs
+ if: |
+ github.event.pull_request.user.login == 'dependabot[bot]' ||
+ contains(github.event.pull_request.labels.*.name, 'safe-to-test')
paths:
# ... existing paths ...
jobs:
build:
uses: ./.github/workflows/_docker-image.yaml
+ # Define environment with protection rules
+ environment: docker-build
with:
target: index-deletion
- secrets: inherit
+ secrets:
+ # Explicitly list required secrets
+ DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
+ DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/_docker-image.yaml | ||
with: | ||
target: index-deletion | ||
secrets: inherit |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||||||||||||
// Copyright (C) 2019-2024 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/deletion/config" | ||||||||||||||||
"github.com/vdaas/vald/pkg/index/job/deletion/usecase" | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
const ( | ||||||||||||||||
maxVersion = "v0.0.10" | ||||||||||||||||
minVersion = "v0.0.0" | ||||||||||||||||
name = "index deletion job" | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
func main() { | ||||||||||||||||
if err := safety.RecoverFunc(func() error { | ||||||||||||||||
return runner.Do( | ||||||||||||||||
context.Background(), | ||||||||||||||||
runner.WithName(name), | ||||||||||||||||
Comment on lines
+37
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding a context timeout. Using - return runner.Do(
- context.Background(),
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
+ defer cancel()
+ return runner.Do(
+ ctx, 📝 Committable suggestion
Suggested change
|
||||||||||||||||
runner.WithVersion(info.Version, maxVersion, minVersion), | ||||||||||||||||
runner.WithConfigLoader(func(path string) (any, *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 any) (runner.Runner, error) { | ||||||||||||||||
c, ok := cfg.(*config.Data) | ||||||||||||||||
if !ok { | ||||||||||||||||
return nil, errors.ErrInvalidConfig | ||||||||||||||||
} | ||||||||||||||||
return usecase.New(c) | ||||||||||||||||
}), | ||||||||||||||||
) | ||||||||||||||||
})(); err != nil { | ||||||||||||||||
log.Fatal(err, info.Get()) | ||||||||||||||||
return | ||||||||||||||||
} | ||||||||||||||||
} |
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.
💡 Codebase verification
The image tag mapping needs corresponding Helm chart configuration
The verification reveals that while the Docker image and K8s manifests for the index deletion feature exist, there's no corresponding Helm chart configuration to support the image tag mapping. This needs to be addressed for the feature to work properly with Helm deployments.
charts/vald/templates/index/job/deletion/
charts/vald/values.yaml
for the index deletion job🔗 Analysis chain
LGTM! Verify related workflow configurations.
The new entry for the index deletion image follows the established pattern and naming conventions.
Let's verify that this image is properly referenced in related workflow files:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 366
Script:
Length of output: 8292
Script:
Length of output: 22222