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

chore(minio): use common miniox #692

Merged
merged 1 commit into from
Sep 24, 2024
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
10 changes: 6 additions & 4 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ import (
"github.com/instill-ai/model-backend/pkg/external"
"github.com/instill-ai/model-backend/pkg/handler"
"github.com/instill-ai/model-backend/pkg/middleware"
"github.com/instill-ai/model-backend/pkg/minio"
"github.com/instill-ai/model-backend/pkg/ray"
"github.com/instill-ai/model-backend/pkg/repository"
"github.com/instill-ai/model-backend/pkg/service"
"github.com/instill-ai/model-backend/pkg/usage"
"github.com/instill-ai/model-backend/pkg/utils"
"github.com/instill-ai/x/temporal"
"github.com/instill-ai/x/zapadapter"

database "github.com/instill-ai/model-backend/pkg/db"
customlogger "github.com/instill-ai/model-backend/pkg/logger"
customotel "github.com/instill-ai/model-backend/pkg/logger/otel"

"github.com/instill-ai/x/temporal"
"github.com/instill-ai/x/zapadapter"

mgmtpb "github.com/instill-ai/protogen-go/core/mgmt/v1beta"
modelpb "github.com/instill-ai/protogen-go/model/model/v1alpha"
miniox "github.com/instill-ai/x/minio"
)

var propagator = b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader))
Expand Down Expand Up @@ -230,7 +232,7 @@ func main() {
repo := repository.NewRepository(db, redisClient)

// Initialize Minio client
minioClient, err := minio.NewMinioClientAndInitBucket(ctx, &config.Config.Minio)
minioClient, err := miniox.NewMinioClientAndInitBucket(ctx, &config.Config.Minio, logger)
if err != nil {
logger.Fatal("failed to create minio client", zap.Error(err))
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ import (

temporalclient "go.temporal.io/sdk/client"

"github.com/instill-ai/x/temporal"
"github.com/instill-ai/x/zapadapter"

"github.com/instill-ai/model-backend/config"
"github.com/instill-ai/model-backend/pkg/datamodel"
"github.com/instill-ai/model-backend/pkg/minio"
"github.com/instill-ai/model-backend/pkg/ray"
"github.com/instill-ai/model-backend/pkg/repository"

database "github.com/instill-ai/model-backend/pkg/db"
customlogger "github.com/instill-ai/model-backend/pkg/logger"
customotel "github.com/instill-ai/model-backend/pkg/logger/otel"
modelWorker "github.com/instill-ai/model-backend/pkg/worker"

"github.com/instill-ai/x/temporal"
"github.com/instill-ai/x/zapadapter"

miniox "github.com/instill-ai/x/minio"
)

func initTemporalNamespace(ctx context.Context, client temporalclient.Client) {
Expand Down Expand Up @@ -160,7 +161,7 @@ func main() {
}

// Initialize Minio client
minioClient, err := minio.NewMinioClientAndInitBucket(ctx, &config.Config.Minio)
minioClient, err := miniox.NewMinioClientAndInitBucket(ctx, &config.Config.Minio, logger)
if err != nil {
logger.Fatal("failed to create minio client", zap.Error(err))
}
Expand Down
4 changes: 3 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/knadh/koanf/providers/env"
"github.com/knadh/koanf/providers/file"
"github.com/redis/go-redis/v9"

miniox "github.com/instill-ai/x/minio"
)

// ServerConfig defines HTTP server configurations
Expand Down Expand Up @@ -160,7 +162,7 @@ type AppConfig struct {
Registry RegistryConfig `koanf:"registry"`
InitModel InitModelConfig `koanf:"initmodel"`
Log LogConfig `koanf:"log"`
Minio MinioConfig `koanf:"minio"`
Minio miniox.Config `koanf:"minio"`
}

// Config - Global variable to export
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ require (
github.com/gabriel-vasile/mimetype v1.4.5
github.com/gofrs/uuid v4.4.0+incompatible
github.com/gogo/status v1.1.1
github.com/gojuno/minimock/v3 v3.3.13
github.com/gojuno/minimock/v3 v3.4.0
github.com/golang-migrate/migrate/v4 v4.17.1
github.com/golang/mock v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0
github.com/iancoleman/strcase v0.3.0
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240902051229-d15d37e2778e
github.com/instill-ai/usage-client v0.3.0-alpha
github.com/instill-ai/x v0.4.0-alpha
github.com/instill-ai/x v0.4.0-alpha.0.20240923052503-fd243919e005
github.com/jackc/pgx/v5 v5.6.0
github.com/knadh/koanf v1.5.0
github.com/lestrrat-go/jspointer v0.0.0-20181205001929-82fadba7561c
Expand All @@ -26,7 +26,7 @@ require (
github.com/lestrrat-go/pdebug v0.0.0-20210111095411-35b07dbf089b
github.com/lestrrat-go/structinfo v0.0.0-20210312050401-7f8bd69d6acb
github.com/mennanov/fieldmask-utils v1.1.2
github.com/minio/minio-go/v7 v7.0.74
github.com/minio/minio-go/v7 v7.0.76
github.com/openfga/api/proto v0.0.0-20240807201305-c96ec773cae9
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.6.1
Expand Down Expand Up @@ -76,7 +76,7 @@ require (
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/nexus-rpc/sdk-go v0.0.9 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/sync v0.8.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/gogo/status v1.1.1 h1:DuHXlSFHNKqTQ+/ACf5Vs6r4X/dH2EgIzR9Vr+H65kg=
github.com/gogo/status v1.1.1/go.mod h1:jpG3dM5QPcqu19Hg8lkUhBFBa3TcLs1DG7+2Jqci7oU=
github.com/gojuno/minimock/v3 v3.3.13 h1:sXFO7RbB4JnZiKhgMO4BU4RLYcfhcOSepfiv4wPgGNY=
github.com/gojuno/minimock/v3 v3.3.13/go.mod h1:WtJbR+15lbzpUHoOFtT7Sv1rR885bFxoyHrzoMOmK/k=
github.com/gojuno/minimock/v3 v3.4.0 h1:htPGQuFvmCaTygTnARPp5tSWZUZxOnu8A2RDVyl/LA8=
github.com/gojuno/minimock/v3 v3.4.0/go.mod h1:0PdkFMCugnywaAqwrdWMZMzHhSH3ZoXlMVHiRVdIrLk=
github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4=
github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
Expand Down Expand Up @@ -233,8 +233,8 @@ github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240902051229-d15d37e2778e h1:
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240902051229-d15d37e2778e/go.mod h1:2blmpUwiTwxIDnrjIqT6FhR5ewshZZF554wzjXFvKpQ=
github.com/instill-ai/usage-client v0.3.0-alpha h1:yY5eNn5zINqy8wpOogiNmrVYzJKnd1KMnMxlYBpr7Tk=
github.com/instill-ai/usage-client v0.3.0-alpha/go.mod h1:8lvtZulkhQ7t8alttb2KkLKYoCp5u4oatzDbfFlEld0=
github.com/instill-ai/x v0.4.0-alpha h1:zQV2VLbSHjMv6gyBN/2mwwrvWk0/mJM6ZKS12AzjfQg=
github.com/instill-ai/x v0.4.0-alpha/go.mod h1:L6jmDPrUou6XskaLXZuK/gDeitdoPa9yE8ONKt1ZwCw=
github.com/instill-ai/x v0.4.0-alpha.0.20240923052503-fd243919e005 h1:6iUpJs545Ivvv2joJCQoawRPr2YRPjux22k7t+gWg6s=
github.com/instill-ai/x v0.4.0-alpha.0.20240923052503-fd243919e005/go.mod h1:jkVtaq9T2zAFA5N46tlV4K5EEVE7FcOVNbqY4wFWYz8=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
Expand Down Expand Up @@ -309,8 +309,8 @@ github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKju
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.74 h1:fTo/XlPBTSpo3BAMshlwKL5RspXRv9us5UeHEGYCFe0=
github.com/minio/minio-go/v7 v7.0.74/go.mod h1:qydcVzV8Hqtj1VtEocfxbmVFa2siu6HGa+LDEPogjD8=
github.com/minio/minio-go/v7 v7.0.76 h1:9nxHH2XDai61cT/EFhyIw/wW4vJfpPNvl7lSFpRt+Ng=
github.com/minio/minio-go/v7 v7.0.76/go.mod h1:AVM3IUN6WwKzmwBxVdjzhH8xq+f57JSbbvzqvUzR6eg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
Expand Down Expand Up @@ -390,8 +390,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
Expand Down
1 change: 0 additions & 1 deletion pkg/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const HeaderUserUIDKey = "Instill-User-Uid"
const HeaderVisitorUIDKey = "Instill-Visitor-Uid"
const HeaderAuthTypeKey = "Instill-Auth-Type"
const HeaderRequesterUIDKey = "Instill-Requester-Uid"
const HeaderUserAgent = "Instill-User-Agent"

// Ray proto path
const RayProtoPath string = "assets/ray/proto"
Expand Down
6 changes: 4 additions & 2 deletions pkg/handler/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/known/structpb"

"github.com/instill-ai/x/sterr"

"github.com/instill-ai/model-backend/config"
"github.com/instill-ai/model-backend/pkg/constant"
"github.com/instill-ai/model-backend/pkg/datamodel"
"github.com/instill-ai/model-backend/pkg/repository"
"github.com/instill-ai/model-backend/pkg/resource"
"github.com/instill-ai/model-backend/pkg/service"
"github.com/instill-ai/model-backend/pkg/utils"
"github.com/instill-ai/x/sterr"

commonpb "github.com/instill-ai/protogen-go/common/task/v1alpha"
mgmtpb "github.com/instill-ai/protogen-go/core/mgmt/v1beta"
modelpb "github.com/instill-ai/protogen-go/model/model/v1alpha"
resourcex "github.com/instill-ai/x/resource"

custom_logger "github.com/instill-ai/model-backend/pkg/logger"
custom_otel "github.com/instill-ai/model-backend/pkg/logger/otel"
Expand Down Expand Up @@ -456,7 +458,7 @@ func (h *PublicHandler) triggerAsyncNamespaceModel(ctx context.Context, req Trig
}
}

requesterUID, userUID := utils.GetRequesterUIDAndUserUID(ctx)
requesterUID, userUID := resourcex.GetRequesterUIDAndUserUID(ctx)
usageData := &utils.UsageMetricData{
OwnerUID: ns.NsUID.String(),
OwnerType: mgmtpb.OwnerType_OWNER_TYPE_USER,
Expand Down
Loading
Loading