From d9d0616314e230457342cdfdf0e294b7fb892cce Mon Sep 17 00:00:00 2001 From: "xu.zhu" Date: Mon, 27 Mar 2023 12:05:18 +0800 Subject: [PATCH 1/5] feat: remove s3 dependency 1. do not delete pipeline run pod when event is received 1. get pipeline run log and object from k8s directly Signed-off-by: xu.zhu --- config.yaml | 1 + core/controller/cloudevent/controller.go | 14 ---- core/controller/cluster/controller_status.go | 38 +-------- core/controller/pipelinerun/controller.go | 27 ++----- pkg/cluster/tekton/collector/collector.go | 16 +++- .../tekton/collector/collector_no_storage.go | 77 +++++++++++++++++++ pkg/cluster/tekton/collector/collector_s3.go | 73 +++++++++++++++++- .../tekton/collector/collector_s3_test.go | 13 +++- pkg/cluster/tekton/factory/factory.go | 33 ++++---- pkg/config/tekton/tekton.go | 1 + 10 files changed, 202 insertions(+), 91 deletions(-) create mode 100644 pkg/cluster/tekton/collector/collector_no_storage.go diff --git a/config.yaml b/config.yaml index 6a31f606..1507f78e 100644 --- a/config.yaml +++ b/config.yaml @@ -51,6 +51,7 @@ tektonMapper: # if you are running it on mac, the path may be looked like '/Users/xxx/.kube/config' kubeconfig: "/Users/xxx/.kube/config" s3: + enabled: false accessKey: "" secretKey: "" region: "" diff --git a/core/controller/cloudevent/controller.go b/core/controller/cloudevent/controller.go index 7944461f..d293a959 100644 --- a/core/controller/cloudevent/controller.go +++ b/core/controller/cloudevent/controller.go @@ -92,20 +92,6 @@ func (c *controller) CloudEvent(ctx context.Context, wpr *WrappedPipelineRun) (e return err } - tekton, err := c.tektonFty.GetTekton(environment) - if err != nil { - return err - } - - // 3. delete pipelinerun in k8s - if err := tekton.DeletePipelineRun(ctx, wpr.PipelineRun); err != nil { - if _, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok { - log.Warningf(ctx, "received pipelineRun: %v is not found when delete", wpr.PipelineRun.Name) - return nil - } - return err - } - // format Pipeline results pipelineResult := metrics.FormatPipelineResults(wpr.PipelineRun) diff --git a/core/controller/cluster/controller_status.go b/core/controller/cluster/controller_status.go index e6830f04..55ee3542 100644 --- a/core/controller/cluster/controller_status.go +++ b/core/controller/cluster/controller_status.go @@ -253,41 +253,11 @@ func (c *controller) getLatestPipelinerunByClusterID(ctx context.Context, func (c *controller) getLatestPipelineRunObject(ctx context.Context, cluster *clustermodels.Cluster, pipelinerun *prmodels.Pipelinerun) (*v1beta1.PipelineRun, error) { - var latestPr *v1beta1.PipelineRun - getPipelineRunFromCollector := func() (*v1beta1.PipelineRun, error) { - tektonCollector, err := c.tektonFty.GetTektonCollector(cluster.EnvironmentName) - if err != nil { - return nil, err - } - obj, err := tektonCollector.GetPipelineRunObject(ctx, pipelinerun.PrObject) - if err != nil { - return nil, err - } - return obj.PipelineRun, nil - } - var ( - err error - tektonClient tekton.Interface - ) - if pipelinerun.PrObject == "" { - tektonClient, err = c.tektonFty.GetTekton(cluster.EnvironmentName) - if err != nil { - return nil, err - } - latestPr, err = tektonClient.GetPipelineRunByID(ctx, pipelinerun.CIEventID) - if err != nil { - if _, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok { - return nil, nil - } - return nil, err - } - } else { - latestPr, err = getPipelineRunFromCollector() - if err != nil { - return nil, err - } + tektonCollector, err := c.tektonFty.GetTektonCollector(cluster.EnvironmentName) + if err != nil { + return nil, err } - return latestPr, nil + return tektonCollector.GetPipelineRun(ctx, pipelinerun) } // getRunningTask Get the latest currently executing Task of the pipeline Run. diff --git a/core/controller/pipelinerun/controller.go b/core/controller/pipelinerun/controller.go index c22fb726..241d03b1 100644 --- a/core/controller/pipelinerun/controller.go +++ b/core/controller/pipelinerun/controller.go @@ -113,34 +113,19 @@ func (c *controller) getPipelinerunLog(ctx context.Context, pr *prmodels.Pipelin const op = "pipeline controller: get pipelinerun log" defer wlog.Start(ctx, op).StopPrint() - // if pr.PrObject is empty, get pipelinerun log in k8s - if pr.PrObject == "" { - tektonClient, err := c.tektonFty.GetTekton(environment) - if err != nil { - return nil, perror.WithMessagef(err, "faild to get tekton for %s", environment) - } - - logCh, errCh, err := tektonClient.GetPipelineRunLogByID(ctx, pr.CIEventID) - if err != nil { - return nil, err - } - return &Log{ - LogChannel: logCh, - ErrChannel: errCh, - }, nil - } - - // else, get log from s3 tektonCollector, err := c.tektonFty.GetTektonCollector(environment) if err != nil { return nil, perror.WithMessagef(err, "faild to get tekton collector for %s", environment) } - logBytes, err := tektonCollector.GetPipelineRunLog(ctx, pr.LogObject) + + prLog, err := tektonCollector.GetPipelineRunLog(ctx, pr) if err != nil { - return nil, perror.WithMessagef(err, "faild to get tekton collector for %s", environment) + return nil, err } return &Log{ - LogBytes: logBytes, + LogChannel: prLog.LogChannel, + ErrChannel: prLog.ErrChannel, + LogBytes: prLog.LogBytes, }, nil } diff --git a/pkg/cluster/tekton/collector/collector.go b/pkg/cluster/tekton/collector/collector.go index 6795a7a8..341defa8 100644 --- a/pkg/cluster/tekton/collector/collector.go +++ b/pkg/cluster/tekton/collector/collector.go @@ -4,6 +4,8 @@ import ( "context" "strconv" + "github.com/horizoncd/horizon/pkg/cluster/tekton/log" + prmodels "github.com/horizoncd/horizon/pkg/pipelinerun/models" "github.com/horizoncd/horizon/pkg/server/global" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -44,6 +46,13 @@ type ( } ) +type Log struct { + LogChannel <-chan log.Log + ErrChannel <-chan error + + LogBytes []byte +} + func NewObjectMeta(horizonMetaData *global.HorizonMetaData, pr *v1beta1.PipelineRun) *ObjectMeta { wrappedPr := &metrics.WrappedPipelineRun{ PipelineRun: pr, @@ -79,11 +88,14 @@ type Interface interface { // Collect log & object for pipelinerun Collect(ctx context.Context, pr *v1beta1.PipelineRun, horizonMetaData *global.HorizonMetaData) (*CollectResult, error) - // GetPipelineRunLog get pipelinerun log from collector - GetPipelineRunLog(ctx context.Context, logObject string) (_ []byte, err error) + // GetPipelineRunLog gets pipelinerun log from collector + GetPipelineRunLog(ctx context.Context, pr *prmodels.Pipelinerun) (*Log, error) // GetPipelineRunObject get pipelinerun object from collector GetPipelineRunObject(ctx context.Context, object string) (*Object, error) + + // GetPipelineRun gets tekton pipelinerun + GetPipelineRun(ctx context.Context, pr *prmodels.Pipelinerun) (*v1beta1.PipelineRun, error) } var _ Interface = (*S3Collector)(nil) diff --git a/pkg/cluster/tekton/collector/collector_no_storage.go b/pkg/cluster/tekton/collector/collector_no_storage.go new file mode 100644 index 00000000..b929831e --- /dev/null +++ b/pkg/cluster/tekton/collector/collector_no_storage.go @@ -0,0 +1,77 @@ +package collector + +import ( + "context" + + herrors "github.com/horizoncd/horizon/core/errors" + "github.com/horizoncd/horizon/pkg/cluster/tekton" + perror "github.com/horizoncd/horizon/pkg/errors" + prmodels "github.com/horizoncd/horizon/pkg/pipelinerun/models" + "github.com/horizoncd/horizon/pkg/server/global" + logutil "github.com/horizoncd/horizon/pkg/util/log" + "github.com/horizoncd/horizon/pkg/util/wlog" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" +) + +type NoStorageCollector struct { + tekton tekton.Interface +} + +func NewNoStorageCollector(tekton tekton.Interface) *NoStorageCollector { + return &NoStorageCollector{ + tekton: tekton, + } +} + +func (c *NoStorageCollector) Collect(ctx context.Context, pr *v1beta1.PipelineRun, horizonMetaData *global.HorizonMetaData) ( + *CollectResult, error) { + const op = "NoStorageCollector: collect" + defer wlog.Start(ctx, op).StopPrint() + + // only collect pipelineRun result and Start and end time + metadata := resolveObjMetadata(pr, horizonMetaData) + collectResult := &CollectResult{ + Result: metadata.PipelineRun.Result, + StartTime: metadata.PipelineRun.StartTime, + CompletionTime: metadata.PipelineRun.CompletionTime, + } + logutil.Infof(ctx, "collected pipelineRun log: name: %v, %+v", + metadata.PipelineRun.Name, collectResult) + return collectResult, nil +} + +func (c *NoStorageCollector) GetPipelineRunLog(ctx context.Context, pr *prmodels.Pipelinerun) (*Log, error) { + const op = "NoStorageCollector: getPipelineRunLog" + defer wlog.Start(ctx, op).StopPrint() + + // get logs from k8s directly + logCh, errCh, err := c.tekton.GetPipelineRunLogByID(ctx, pr.CIEventID) + if err != nil { + return nil, perror.WithMessagef(err, "failed to get pipelineRun log from k8s") + } + return &Log{ + LogChannel: logCh, + ErrChannel: errCh, + }, nil +} + +func (c *NoStorageCollector) GetPipelineRunObject(ctx context.Context, + object string) (*Object, error) { + // no storage to collect pipelineRun object + return nil, nil +} + +func (c *NoStorageCollector) GetPipelineRun(ctx context.Context, pr *prmodels.Pipelinerun) (*v1beta1.PipelineRun, error) { + const op = "NoStorageCollector: getPipelineRun" + defer wlog.Start(ctx, op).StopPrint() + + // get pipelineRun from k8s directly + tektonPipelineRun, err := c.tekton.GetPipelineRunByID(ctx, pr.CIEventID) + if err != nil { + if _, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok { + return nil, nil + } + return nil, err + } + return tektonPipelineRun, nil +} diff --git a/pkg/cluster/tekton/collector/collector_s3.go b/pkg/cluster/tekton/collector/collector_s3.go index 0df7390b..7d4b833b 100644 --- a/pkg/cluster/tekton/collector/collector_s3.go +++ b/pkg/cluster/tekton/collector/collector_s3.go @@ -15,6 +15,7 @@ import ( herrors "github.com/horizoncd/horizon/core/errors" perror "github.com/horizoncd/horizon/pkg/errors" + prmodels "github.com/horizoncd/horizon/pkg/pipelinerun/models" "github.com/horizoncd/horizon/pkg/server/global" "github.com/aws/aws-sdk-go/aws/awserr" @@ -51,7 +52,7 @@ type S3Collector struct { logger *log.Logger } -func NewS3Collector(s3 s3.Interface, tekton tekton.Interface) *S3Collector { +func NewS3Collector(s3 s3.Interface, tekton tekton.Interface) Interface { dir := getEnvOrDefault(_envKeyPipelineRunLogDIR, _defaultPipelineRunLogDir) filename := getEnvOrDefault(_envKeyPipelineRunLogFile, _defaultPipelineRunLogFile) output := lumberjack.Logger{ @@ -118,6 +119,8 @@ func (c *S3Collector) Collect(ctx context.Context, pr *v1beta1.PipelineRun, hori *CollectResult, error) { const op = "s3Collector: collect" defer wlog.Start(ctx, op).StopPrint() + + // collect pipelineRun log into s3 metadata := resolveObjMetadata(pr, horizonMetaData) collectLogResult, err := c.collectLog(ctx, pr, metadata) if err != nil { @@ -137,20 +140,57 @@ func (c *S3Collector) Collect(ctx context.Context, pr *v1beta1.PipelineRun, hori } b = cutByteInMiddle(b, _limitSize, _mb, len(b)-_mb) c.logger.Println(string(b)) - return &CollectResult{ + + collectResult := &CollectResult{ Bucket: c.s3.GetBucket(ctx), LogObject: collectLogResult.LogObject, PrObject: collectObjectResult.PrObject, Result: metadata.PipelineRun.Result, StartTime: metadata.PipelineRun.StartTime, CompletionTime: metadata.PipelineRun.CompletionTime, - }, nil + } + + // delete pipelinerun in k8s + if err := c.tekton.DeletePipelineRun(ctx, pr); err != nil { + if _, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok { + logutil.Warningf(ctx, "received pipelineRun: %v is not found when deleted", pr.Name) + return collectResult, nil + } + return nil, err + } + return collectResult, nil } -func (c *S3Collector) GetPipelineRunLog(ctx context.Context, logObject string) (_ []byte, err error) { +func (c *S3Collector) GetPipelineRunLog(ctx context.Context, pr *prmodels.Pipelinerun) (*Log, error) { const op = "s3Collector: getPipelineRunLog" defer wlog.Start(ctx, op).StopPrint() + // if pr.PrObject is not empty, get logs from s3 + if pr.PrObject != "" { + logBytes, err := c.getPipelineRunLog(ctx, pr.LogObject) + if err != nil { + return nil, perror.WithMessagef(err, "failed to get pipelineRun log from s3") + } + return &Log{ + LogBytes: logBytes, + }, nil + } + + // else, get logs from k8s directly + logCh, errCh, err := c.tekton.GetPipelineRunLogByID(ctx, pr.CIEventID) + if err != nil { + return nil, perror.WithMessagef(err, "failed to get pipelineRun log from k8s") + } + return &Log{ + LogChannel: logCh, + ErrChannel: errCh, + }, nil +} + +func (c *S3Collector) getPipelineRunLog(ctx context.Context, logObject string) (_ []byte, err error) { + const op = "s3Collector: getPipelineRunLog from s3" + defer wlog.Start(ctx, op).StopPrint() + b, err := c.s3.GetObject(ctx, logObject) if err != nil { if e, ok := err.(awserr.Error); ok { @@ -183,6 +223,31 @@ func (c *S3Collector) GetPipelineRunObject(ctx context.Context, object string) ( return obj, nil } +func (c *S3Collector) GetPipelineRun(ctx context.Context, + pr *prmodels.Pipelinerun) (*v1beta1.PipelineRun, error) { + const op = "s3Collector: getPipelineRun" + defer wlog.Start(ctx, op).StopPrint() + + // if pr.PrObject is not empty, get pipelineRun object from s3 + if pr.PrObject != "" { + obj, err := c.GetPipelineRunObject(ctx, pr.PrObject) + if err != nil { + return nil, err + } + return obj.PipelineRun, nil + } + + // else, get pipelineRun object from k8s directly + tektonPipelineRun, err := c.tekton.GetPipelineRunByID(ctx, pr.CIEventID) + if err != nil { + if _, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok { + return nil, nil + } + return nil, err + } + return tektonPipelineRun, nil +} + type CollectObjectResult struct { PrObject string PrURL string diff --git a/pkg/cluster/tekton/collector/collector_s3_test.go b/pkg/cluster/tekton/collector/collector_s3_test.go index c7f67fe9..4f71d580 100644 --- a/pkg/cluster/tekton/collector/collector_s3_test.go +++ b/pkg/cluster/tekton/collector/collector_s3_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/golang/mock/gomock" + prmodels "github.com/horizoncd/horizon/pkg/pipelinerun/models" "github.com/horizoncd/horizon/pkg/server/global" "github.com/johannesboyne/gofakes3" "github.com/johannesboyne/gofakes3/backend/s3mem" @@ -178,6 +179,7 @@ func TestS3Collector_Collect(t *testing.T) { ctl := gomock.NewController(t) tek := tektonmock.NewMockInterface(ctl) tek.EXPECT().GetPipelineRunLog(ctx, pr).Return(getPipelineRunLog(pr)) + tek.EXPECT().DeletePipelineRun(ctx, pr).Return(nil) backend := s3mem.New() _ = backend.CreateBucket("bucket") @@ -214,9 +216,10 @@ func TestS3Collector_Collect(t *testing.T) { t.Logf("%v", string(b)) // 1. getLatestPipelineRunLog - b, err = c.GetPipelineRunLog(ctx, collectResult.LogObject) + prModel := &prmodels.Pipelinerun{LogObject: collectResult.LogObject} + _, err = c.GetPipelineRunLog(ctx, prModel) assert.Nil(t, err) - t.Logf(string(b)) + // 2. getLatestPipelineRunObject obj, err := c.GetPipelineRunObject(ctx, collectResult.PrObject) assert.Nil(t, err) @@ -225,4 +228,10 @@ func TestS3Collector_Collect(t *testing.T) { if !reflect.DeepEqual(objectMeta, obj.Metadata) { t.Fatalf("pipelineRun objectMeta: expected %v, got %v", objectMeta, obj.Metadata) } + + // 3. getLatestPipelineRun + tektonPR, err := c.GetPipelineRun(ctx, prModel) + if !reflect.DeepEqual(tektonPR, pr) { + t.Fatalf("pipelineRun objectMeta: expected %v, got %v", objectMeta, obj.Metadata) + } } diff --git a/pkg/cluster/tekton/factory/factory.go b/pkg/cluster/tekton/factory/factory.go index cc1f582b..43203ffe 100644 --- a/pkg/cluster/tekton/factory/factory.go +++ b/pkg/cluster/tekton/factory/factory.go @@ -36,20 +36,25 @@ func NewFactory(tektonMapper tektonconfig.Mapper) (Factory, error) { if err != nil { return nil, errors.E(op, err) } - s3Driver, err := s3.NewDriver(s3.Params{ - AccessKey: tektonConfig.S3.AccessKey, - SecretKey: tektonConfig.S3.SecretKey, - Region: tektonConfig.S3.Region, - Endpoint: tektonConfig.S3.Endpoint, - Bucket: tektonConfig.S3.Bucket, - DisableSSL: tektonConfig.S3.DisableSSL, - SkipVerify: tektonConfig.S3.SkipVerify, - S3ForcePathStyle: tektonConfig.S3.S3ForcePathStyle, - ContentType: "text/plain", - }) - c := collector.NewS3Collector(s3Driver, t) - if err != nil { - return nil, errors.E(op, err) + var c collector.Interface + if tektonConfig.S3.Enabled { + s3Driver, err := s3.NewDriver(s3.Params{ + AccessKey: tektonConfig.S3.AccessKey, + SecretKey: tektonConfig.S3.SecretKey, + Region: tektonConfig.S3.Region, + Endpoint: tektonConfig.S3.Endpoint, + Bucket: tektonConfig.S3.Bucket, + DisableSSL: tektonConfig.S3.DisableSSL, + SkipVerify: tektonConfig.S3.SkipVerify, + S3ForcePathStyle: tektonConfig.S3.S3ForcePathStyle, + ContentType: "text/plain", + }) + if err != nil { + return nil, errors.E(op, err) + } + c = collector.NewS3Collector(s3Driver, t) + } else { + c = collector.NewNoStorageCollector(t) } cache.Store(env, &tektonCache{ tekton: t, diff --git a/pkg/config/tekton/tekton.go b/pkg/config/tekton/tekton.go index 507d38b2..f1637f3c 100644 --- a/pkg/config/tekton/tekton.go +++ b/pkg/config/tekton/tekton.go @@ -10,6 +10,7 @@ type Tekton struct { } type S3 struct { + Enabled bool `yaml:"enabled"` AccessKey string `yaml:"accessKey"` SecretKey string `yaml:"secretKey"` Region string `yaml:"region"` From e3cccdd04e46b821e2f53be093fd8ea6b140335f Mon Sep 17 00:00:00 2001 From: "xu.zhu" Date: Mon, 27 Mar 2023 15:01:16 +0800 Subject: [PATCH 2/5] fix: lint and ut Signed-off-by: xu.zhu --- core/controller/cloudevent/controller_test.go | 2 -- core/controller/cluster/controller_test.go | 5 ++++ .../controller/pipelinerun/controller_test.go | 16 ++++++++---- .../cluster/gitrepo/gitrepo_cluster_mock.go | 8 +++--- .../tekton/collector/collector_mock.go | 26 +++++++++++++++---- .../tekton/collector/collector_no_storage.go | 7 ++--- .../tekton/collector/collector_s3_test.go | 7 ++++- 7 files changed, 51 insertions(+), 20 deletions(-) diff --git a/core/controller/cloudevent/controller_test.go b/core/controller/cloudevent/controller_test.go index ae243a4e..c65dc015 100644 --- a/core/controller/cloudevent/controller_test.go +++ b/core/controller/cloudevent/controller_test.go @@ -233,8 +233,6 @@ func Test(t *testing.T) { }(), }, nil) - tekton.EXPECT().DeletePipelineRun(ctx, gomock.Any()).Return(nil) - templateReleaseMgr := trmock.NewMockManager(mockCtl) templateReleaseMgr.EXPECT().GetByTemplateNameAndRelease(gomock.Any(), gomock.Any(), gomock.Any()). Return(&trmodels.TemplateRelease{}, nil) diff --git a/core/controller/cluster/controller_test.go b/core/controller/cluster/controller_test.go index bc188082..9b926a22 100644 --- a/core/controller/cluster/controller_test.go +++ b/core/controller/cluster/controller_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + tektoncollectormock "github.com/horizoncd/horizon/mock/pkg/cluster/tekton/collector" v1 "k8s.io/api/core/v1" "github.com/horizoncd/horizon/core/common" @@ -802,6 +803,10 @@ func test(t *testing.T) { tektonFty.EXPECT().GetTekton(gomock.Any()).Return(tekton, nil).AnyTimes() tekton.EXPECT().CreatePipelineRun(ctx, gomock.Any()).Return("abc", nil) tekton.EXPECT().GetPipelineRunByID(ctx, gomock.Any()).Return(pr, nil).AnyTimes() + tektonCollector := tektoncollectormock.NewMockInterface(mockCtl) + + tektonFty.EXPECT().GetTektonCollector(gomock.Any()).Return(tektonCollector, nil).AnyTimes() + tektonCollector.EXPECT().GetPipelineRun(ctx, gomock.Any()).Return(pr, nil).AnyTimes() commitGetter.EXPECT().GetCommit(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Return(&git.Commit{ ID: "code-commit-id", diff --git a/core/controller/pipelinerun/controller_test.go b/core/controller/pipelinerun/controller_test.go index 3c31cbcc..ee637356 100644 --- a/core/controller/pipelinerun/controller_test.go +++ b/core/controller/pipelinerun/controller_test.go @@ -24,6 +24,7 @@ import ( userauth "github.com/horizoncd/horizon/pkg/authentication/user" codemodels "github.com/horizoncd/horizon/pkg/cluster/code" clustermodel "github.com/horizoncd/horizon/pkg/cluster/models" + "github.com/horizoncd/horizon/pkg/cluster/tekton/collector" "github.com/horizoncd/horizon/pkg/cluster/tekton/log" envmodels "github.com/horizoncd/horizon/pkg/environmentregion/models" "github.com/horizoncd/horizon/pkg/git" @@ -270,11 +271,8 @@ func Test(t *testing.T) { } logBytes := []byte("this is a log") - tektonCollector.EXPECT().GetPipelineRunLog(ctx, gomock.Any()).Return(logBytes, nil).AnyTimes() - - logCh := make(chan log.Log) - errCh := make(chan error) - tekton.EXPECT().GetPipelineRunLogByID(ctx, gomock.Any()).Return(logCh, errCh, nil) + tektonCollector.EXPECT().GetPipelineRunLog(ctx, gomock.Any()). + Return(&collector.Log{LogBytes: logBytes}, nil).Times(1) l, err := c.GetPipelinerunLog(ctx, pipelinerun.ID) assert.Nil(t, err) @@ -295,6 +293,14 @@ func Test(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, pipelinerun) + logCh := make(chan log.Log) + errCh := make(chan error) + tektonCollector.EXPECT().GetPipelineRunLog(ctx, gomock.Any()). + Return(&collector.Log{ + LogChannel: logCh, + ErrChannel: errCh, + }, nil).Times(1) + go func() { defer close(logCh) defer close(errCh) diff --git a/mock/pkg/cluster/gitrepo/gitrepo_cluster_mock.go b/mock/pkg/cluster/gitrepo/gitrepo_cluster_mock.go index 591c1261..6631bde7 100644 --- a/mock/pkg/cluster/gitrepo/gitrepo_cluster_mock.go +++ b/mock/pkg/cluster/gitrepo/gitrepo_cluster_mock.go @@ -243,18 +243,18 @@ func (mr *MockClusterGitRepoMockRecorder) HardDeleteCluster(ctx, application, cl } // MergeBranch mocks base method. -func (m *MockClusterGitRepo) MergeBranch(ctx context.Context, application, cluster, sourceBranch, targetBranch string, prID *uint) (string, error) { +func (m *MockClusterGitRepo) MergeBranch(ctx context.Context, application, cluster, sourceBranch, targetBranch string, pipelineRunID *uint) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MergeBranch", ctx, application, cluster, sourceBranch, targetBranch, prID) + ret := m.ctrl.Call(m, "MergeBranch", ctx, application, cluster, sourceBranch, targetBranch, pipelineRunID) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // MergeBranch indicates an expected call of MergeBranch. -func (mr *MockClusterGitRepoMockRecorder) MergeBranch(ctx, application, cluster, sourceBranch, targetBranch, prID interface{}) *gomock.Call { +func (mr *MockClusterGitRepoMockRecorder) MergeBranch(ctx, application, cluster, sourceBranch, targetBranch, pipelineRunID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MergeBranch", reflect.TypeOf((*MockClusterGitRepo)(nil).MergeBranch), ctx, application, cluster, sourceBranch, targetBranch, prID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MergeBranch", reflect.TypeOf((*MockClusterGitRepo)(nil).MergeBranch), ctx, application, cluster, sourceBranch, targetBranch, pipelineRunID) } // Rollback mocks base method. diff --git a/mock/pkg/cluster/tekton/collector/collector_mock.go b/mock/pkg/cluster/tekton/collector/collector_mock.go index dc1bfa54..4e1ac643 100644 --- a/mock/pkg/cluster/tekton/collector/collector_mock.go +++ b/mock/pkg/cluster/tekton/collector/collector_mock.go @@ -10,6 +10,7 @@ import ( gomock "github.com/golang/mock/gomock" collector "github.com/horizoncd/horizon/pkg/cluster/tekton/collector" + models "github.com/horizoncd/horizon/pkg/pipelinerun/models" global "github.com/horizoncd/horizon/pkg/server/global" v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) @@ -52,19 +53,34 @@ func (mr *MockInterfaceMockRecorder) Collect(ctx, pr, horizonMetaData interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Collect", reflect.TypeOf((*MockInterface)(nil).Collect), ctx, pr, horizonMetaData) } +// GetPipelineRun mocks base method. +func (m *MockInterface) GetPipelineRun(ctx context.Context, pr *models.Pipelinerun) (*v1beta1.PipelineRun, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPipelineRun", ctx, pr) + ret0, _ := ret[0].(*v1beta1.PipelineRun) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPipelineRun indicates an expected call of GetPipelineRun. +func (mr *MockInterfaceMockRecorder) GetPipelineRun(ctx, pr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPipelineRun", reflect.TypeOf((*MockInterface)(nil).GetPipelineRun), ctx, pr) +} + // GetPipelineRunLog mocks base method. -func (m *MockInterface) GetPipelineRunLog(ctx context.Context, logObject string) ([]byte, error) { +func (m *MockInterface) GetPipelineRunLog(ctx context.Context, pr *models.Pipelinerun) (*collector.Log, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPipelineRunLog", ctx, logObject) - ret0, _ := ret[0].([]byte) + ret := m.ctrl.Call(m, "GetPipelineRunLog", ctx, pr) + ret0, _ := ret[0].(*collector.Log) ret1, _ := ret[1].(error) return ret0, ret1 } // GetPipelineRunLog indicates an expected call of GetPipelineRunLog. -func (mr *MockInterfaceMockRecorder) GetPipelineRunLog(ctx, logObject interface{}) *gomock.Call { +func (mr *MockInterfaceMockRecorder) GetPipelineRunLog(ctx, pr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPipelineRunLog", reflect.TypeOf((*MockInterface)(nil).GetPipelineRunLog), ctx, logObject) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPipelineRunLog", reflect.TypeOf((*MockInterface)(nil).GetPipelineRunLog), ctx, pr) } // GetPipelineRunObject mocks base method. diff --git a/pkg/cluster/tekton/collector/collector_no_storage.go b/pkg/cluster/tekton/collector/collector_no_storage.go index b929831e..83262c04 100644 --- a/pkg/cluster/tekton/collector/collector_no_storage.go +++ b/pkg/cluster/tekton/collector/collector_no_storage.go @@ -23,8 +23,8 @@ func NewNoStorageCollector(tekton tekton.Interface) *NoStorageCollector { } } -func (c *NoStorageCollector) Collect(ctx context.Context, pr *v1beta1.PipelineRun, horizonMetaData *global.HorizonMetaData) ( - *CollectResult, error) { +func (c *NoStorageCollector) Collect(ctx context.Context, pr *v1beta1.PipelineRun, + horizonMetaData *global.HorizonMetaData) (*CollectResult, error) { const op = "NoStorageCollector: collect" defer wlog.Start(ctx, op).StopPrint() @@ -61,7 +61,8 @@ func (c *NoStorageCollector) GetPipelineRunObject(ctx context.Context, return nil, nil } -func (c *NoStorageCollector) GetPipelineRun(ctx context.Context, pr *prmodels.Pipelinerun) (*v1beta1.PipelineRun, error) { +func (c *NoStorageCollector) GetPipelineRun(ctx context.Context, + pr *prmodels.Pipelinerun) (*v1beta1.PipelineRun, error) { const op = "NoStorageCollector: getPipelineRun" defer wlog.Start(ctx, op).StopPrint() diff --git a/pkg/cluster/tekton/collector/collector_s3_test.go b/pkg/cluster/tekton/collector/collector_s3_test.go index 4f71d580..90be6688 100644 --- a/pkg/cluster/tekton/collector/collector_s3_test.go +++ b/pkg/cluster/tekton/collector/collector_s3_test.go @@ -216,7 +216,11 @@ func TestS3Collector_Collect(t *testing.T) { t.Logf("%v", string(b)) // 1. getLatestPipelineRunLog - prModel := &prmodels.Pipelinerun{LogObject: collectResult.LogObject} + prModel := &prmodels.Pipelinerun{ + LogObject: collectResult.LogObject, + PrObject: collectResult.PrObject, + S3Bucket: collectResult.Bucket, + } _, err = c.GetPipelineRunLog(ctx, prModel) assert.Nil(t, err) @@ -231,6 +235,7 @@ func TestS3Collector_Collect(t *testing.T) { // 3. getLatestPipelineRun tektonPR, err := c.GetPipelineRun(ctx, prModel) + assert.Nil(t, err) if !reflect.DeepEqual(tektonPR, pr) { t.Fatalf("pipelineRun objectMeta: expected %v, got %v", objectMeta, obj.Metadata) } From d39ef2d0cbf53f8b4bb584eef6c3da4cc941dbc0 Mon Sep 17 00:00:00 2001 From: "xu.zhu" Date: Mon, 27 Mar 2023 20:50:31 +0800 Subject: [PATCH 3/5] fix: review Signed-off-by: xu.zhu --- config.yaml | 7 +++-- core/controller/pipelinerun/controller.go | 29 +++++-------------- core/http/api/v1/pipelinerun/apis.go | 5 ++-- core/http/api/v1/pipelinerun/routers.go | 16 +++++----- core/http/api/v2/pipelinerun/apis.go | 5 ++-- ...ector_no_storage.go => collector_dummy.go} | 21 +++++++------- pkg/cluster/tekton/factory/factory.go | 25 +++++++++------- pkg/config/tekton/tekton.go | 12 ++++---- 8 files changed, 56 insertions(+), 64 deletions(-) rename pkg/cluster/tekton/collector/{collector_no_storage.go => collector_dummy.go} (72%) diff --git a/config.yaml b/config.yaml index 1507f78e..e5b3ba2f 100644 --- a/config.yaml +++ b/config.yaml @@ -50,8 +50,11 @@ tektonMapper: # if you run horizon on local machine, you need to set this to the absolute path of your kubeconfig # if you are running it on mac, the path may be looked like '/Users/xxx/.kube/config' kubeconfig: "/Users/xxx/.kube/config" - s3: - enabled: false + logStorage: + # the following types of log storage are supported: + # s3: default minio is used, and you can also configure your own s3 storage + # dummy: a dummy log storage, build logs are not stored and get them directly from k8s + type: dummy accessKey: "" secretKey: "" region: "" diff --git a/core/controller/pipelinerun/controller.go b/core/controller/pipelinerun/controller.go index 241d03b1..6e398b3d 100644 --- a/core/controller/pipelinerun/controller.go +++ b/core/controller/pipelinerun/controller.go @@ -11,8 +11,8 @@ import ( codemodels "github.com/horizoncd/horizon/pkg/cluster/code" "github.com/horizoncd/horizon/pkg/cluster/gitrepo" clustermanager "github.com/horizoncd/horizon/pkg/cluster/manager" + "github.com/horizoncd/horizon/pkg/cluster/tekton/collector" "github.com/horizoncd/horizon/pkg/cluster/tekton/factory" - "github.com/horizoncd/horizon/pkg/cluster/tekton/log" envmanager "github.com/horizoncd/horizon/pkg/environment/manager" perror "github.com/horizoncd/horizon/pkg/errors" "github.com/horizoncd/horizon/pkg/param" @@ -25,8 +25,8 @@ import ( ) type Controller interface { - GetPipelinerunLog(ctx context.Context, pipelinerunID uint) (*Log, error) - GetClusterLatestLog(ctx context.Context, clusterID uint) (*Log, error) + GetPipelinerunLog(ctx context.Context, pipelinerunID uint) (*collector.Log, error) + GetClusterLatestLog(ctx context.Context, clusterID uint) (*collector.Log, error) GetDiff(ctx context.Context, pipelinerunID uint) (*GetDiffResponse, error) Get(ctx context.Context, pipelinerunID uint) (*PipelineBasic, error) List(ctx context.Context, clusterID uint, canRollback bool, query q.Query) (int, []*PipelineBasic, error) @@ -60,14 +60,7 @@ func NewController(param *param.Param) Controller { } } -type Log struct { - LogChannel <-chan log.Log - ErrChannel <-chan error - - LogBytes []byte -} - -func (c *controller) GetPipelinerunLog(ctx context.Context, pipelinerunID uint) (_ *Log, err error) { +func (c *controller) GetPipelinerunLog(ctx context.Context, pipelinerunID uint) (_ *collector.Log, err error) { const op = "pipelinerun controller: get pipelinerun log" defer wlog.Start(ctx, op).StopPrint() @@ -89,7 +82,7 @@ func (c *controller) GetPipelinerunLog(ctx context.Context, pipelinerunID uint) return c.getPipelinerunLog(ctx, pr, cluster.EnvironmentName) } -func (c *controller) GetClusterLatestLog(ctx context.Context, clusterID uint) (_ *Log, err error) { +func (c *controller) GetClusterLatestLog(ctx context.Context, clusterID uint) (_ *collector.Log, err error) { const op = "pipelinerun controller: get cluster latest log" defer wlog.Start(ctx, op).StopPrint() @@ -109,7 +102,7 @@ func (c *controller) GetClusterLatestLog(ctx context.Context, clusterID uint) (_ } func (c *controller) getPipelinerunLog(ctx context.Context, pr *prmodels.Pipelinerun, - environment string) (_ *Log, err error) { + environment string) (_ *collector.Log, err error) { const op = "pipeline controller: get pipelinerun log" defer wlog.Start(ctx, op).StopPrint() @@ -118,15 +111,7 @@ func (c *controller) getPipelinerunLog(ctx context.Context, pr *prmodels.Pipelin return nil, perror.WithMessagef(err, "faild to get tekton collector for %s", environment) } - prLog, err := tektonCollector.GetPipelineRunLog(ctx, pr) - if err != nil { - return nil, err - } - return &Log{ - LogChannel: prLog.LogChannel, - ErrChannel: prLog.ErrChannel, - LogBytes: prLog.LogBytes, - }, nil + return tektonCollector.GetPipelineRunLog(ctx, pr) } func (c *controller) GetDiff(ctx context.Context, pipelinerunID uint) (_ *GetDiffResponse, err error) { diff --git a/core/http/api/v1/pipelinerun/apis.go b/core/http/api/v1/pipelinerun/apis.go index 8bca0a8c..4bcd3460 100644 --- a/core/http/api/v1/pipelinerun/apis.go +++ b/core/http/api/v1/pipelinerun/apis.go @@ -7,6 +7,7 @@ import ( "github.com/horizoncd/horizon/core/common" prctl "github.com/horizoncd/horizon/core/controller/pipelinerun" "github.com/horizoncd/horizon/lib/q" + "github.com/horizoncd/horizon/pkg/cluster/tekton/collector" "github.com/horizoncd/horizon/pkg/server/request" "github.com/horizoncd/horizon/pkg/server/response" "github.com/horizoncd/horizon/pkg/util/errors" @@ -40,7 +41,7 @@ func (a *API) Log(c *gin.Context) { } l, err := a.prCtl.GetPipelinerunLog(c, uint(prID)) if err != nil { - l := &prctl.Log{ + l := &collector.Log{ LogBytes: []byte(errors.Message(err)), } a.writeLog(c, l) @@ -64,7 +65,7 @@ func (a *API) LatestLogForCluster(c *gin.Context) { a.writeLog(c, l) } -func (a *API) writeLog(c *gin.Context, l *prctl.Log) { +func (a *API) writeLog(c *gin.Context, l *collector.Log) { c.Header("Content-Type", "text/plain") if l.LogBytes != nil { _, _ = c.Writer.Write(l.LogBytes) diff --git a/core/http/api/v1/pipelinerun/routers.go b/core/http/api/v1/pipelinerun/routers.go index 45ca5cdf..431fd898 100644 --- a/core/http/api/v1/pipelinerun/routers.go +++ b/core/http/api/v1/pipelinerun/routers.go @@ -10,30 +10,30 @@ import ( ) // RegisterRoutes register routes -func (api *API) RegisterRoute(engine *gin.Engine) { +func (a *API) RegisterRoute(engine *gin.Engine) { apiGroup := engine.Group("/apis/core/v1") var routes = route.Routes{ { Method: http.MethodGet, Pattern: fmt.Sprintf("/pipelineruns/:%v/log", _pipelinerunIDParam), - HandlerFunc: api.Log, + HandlerFunc: a.Log, }, { Method: http.MethodPost, Pattern: fmt.Sprintf("/pipelineruns/:%v/stop", _pipelinerunIDParam), - HandlerFunc: api.Stop, + HandlerFunc: a.Stop, }, { Method: http.MethodGet, Pattern: fmt.Sprintf("/pipelineruns/:%v/diffs", _pipelinerunIDParam), - HandlerFunc: api.GetDiff, + HandlerFunc: a.GetDiff, }, { Method: http.MethodGet, Pattern: fmt.Sprintf("/pipelineruns/:%v", _pipelinerunIDParam), - HandlerFunc: api.Get, + HandlerFunc: a.Get, }, { Method: http.MethodGet, Pattern: fmt.Sprintf("/clusters/:%v/pipelineruns", _clusterIDParam), - HandlerFunc: api.List, + HandlerFunc: a.List, }, } @@ -45,11 +45,11 @@ func (api *API) RegisterRoute(engine *gin.Engine) { { Method: http.MethodGet, Pattern: fmt.Sprintf("/clusters/:%v/log", _clusterParam), - HandlerFunc: api.LatestLogForCluster, + HandlerFunc: a.LatestLogForCluster, }, { Method: http.MethodPost, Pattern: fmt.Sprintf("/clusters/:%v/stop", _clusterParam), - HandlerFunc: api.StopPipelinerunForCluster, + HandlerFunc: a.StopPipelinerunForCluster, }, } diff --git a/core/http/api/v2/pipelinerun/apis.go b/core/http/api/v2/pipelinerun/apis.go index ef6c2d53..89978f9a 100644 --- a/core/http/api/v2/pipelinerun/apis.go +++ b/core/http/api/v2/pipelinerun/apis.go @@ -7,6 +7,7 @@ import ( "github.com/horizoncd/horizon/core/common" prctl "github.com/horizoncd/horizon/core/controller/pipelinerun" "github.com/horizoncd/horizon/lib/q" + "github.com/horizoncd/horizon/pkg/cluster/tekton/collector" "github.com/horizoncd/horizon/pkg/server/request" "github.com/horizoncd/horizon/pkg/server/response" "github.com/horizoncd/horizon/pkg/util/errors" @@ -39,7 +40,7 @@ func (a *API) Log(c *gin.Context) { } l, err := a.prCtl.GetPipelinerunLog(c, uint(prID)) if err != nil { - l := &prctl.Log{ + l := &collector.Log{ LogBytes: []byte(errors.Message(err)), } a.writeLog(c, l) @@ -48,7 +49,7 @@ func (a *API) Log(c *gin.Context) { a.writeLog(c, l) } -func (a *API) writeLog(c *gin.Context, l *prctl.Log) { +func (a *API) writeLog(c *gin.Context, l *collector.Log) { c.Header("Content-Type", "text/plain") if l.LogBytes != nil { _, _ = c.Writer.Write(l.LogBytes) diff --git a/pkg/cluster/tekton/collector/collector_no_storage.go b/pkg/cluster/tekton/collector/collector_dummy.go similarity index 72% rename from pkg/cluster/tekton/collector/collector_no_storage.go rename to pkg/cluster/tekton/collector/collector_dummy.go index 83262c04..26401403 100644 --- a/pkg/cluster/tekton/collector/collector_no_storage.go +++ b/pkg/cluster/tekton/collector/collector_dummy.go @@ -13,22 +13,21 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) -type NoStorageCollector struct { +type DummyCollector struct { tekton tekton.Interface } -func NewNoStorageCollector(tekton tekton.Interface) *NoStorageCollector { - return &NoStorageCollector{ +func NewDummyCollector(tekton tekton.Interface) Interface { + return &DummyCollector{ tekton: tekton, } } -func (c *NoStorageCollector) Collect(ctx context.Context, pr *v1beta1.PipelineRun, +func (c *DummyCollector) Collect(ctx context.Context, pr *v1beta1.PipelineRun, horizonMetaData *global.HorizonMetaData) (*CollectResult, error) { - const op = "NoStorageCollector: collect" + const op = "DummyCollector: collect" defer wlog.Start(ctx, op).StopPrint() - // only collect pipelineRun result and Start and end time metadata := resolveObjMetadata(pr, horizonMetaData) collectResult := &CollectResult{ Result: metadata.PipelineRun.Result, @@ -40,8 +39,8 @@ func (c *NoStorageCollector) Collect(ctx context.Context, pr *v1beta1.PipelineRu return collectResult, nil } -func (c *NoStorageCollector) GetPipelineRunLog(ctx context.Context, pr *prmodels.Pipelinerun) (*Log, error) { - const op = "NoStorageCollector: getPipelineRunLog" +func (c *DummyCollector) GetPipelineRunLog(ctx context.Context, pr *prmodels.Pipelinerun) (*Log, error) { + const op = "DummyCollector: getPipelineRunLog" defer wlog.Start(ctx, op).StopPrint() // get logs from k8s directly @@ -55,15 +54,15 @@ func (c *NoStorageCollector) GetPipelineRunLog(ctx context.Context, pr *prmodels }, nil } -func (c *NoStorageCollector) GetPipelineRunObject(ctx context.Context, +func (c *DummyCollector) GetPipelineRunObject(ctx context.Context, object string) (*Object, error) { // no storage to collect pipelineRun object return nil, nil } -func (c *NoStorageCollector) GetPipelineRun(ctx context.Context, +func (c *DummyCollector) GetPipelineRun(ctx context.Context, pr *prmodels.Pipelinerun) (*v1beta1.PipelineRun, error) { - const op = "NoStorageCollector: getPipelineRun" + const op = "DummyCollector: getPipelineRun" defer wlog.Start(ctx, op).StopPrint() // get pipelineRun from k8s directly diff --git a/pkg/cluster/tekton/factory/factory.go b/pkg/cluster/tekton/factory/factory.go index 43203ffe..9c083eae 100644 --- a/pkg/cluster/tekton/factory/factory.go +++ b/pkg/cluster/tekton/factory/factory.go @@ -11,7 +11,10 @@ import ( "github.com/horizoncd/horizon/pkg/util/errors" ) -const _default = "default" +const ( + _default = "default" + _s3Storage = "s3" +) type Factory interface { GetTekton(environment string) (tekton.Interface, error) @@ -37,16 +40,16 @@ func NewFactory(tektonMapper tektonconfig.Mapper) (Factory, error) { return nil, errors.E(op, err) } var c collector.Interface - if tektonConfig.S3.Enabled { + if tektonConfig.LogStorage.Type == _s3Storage { s3Driver, err := s3.NewDriver(s3.Params{ - AccessKey: tektonConfig.S3.AccessKey, - SecretKey: tektonConfig.S3.SecretKey, - Region: tektonConfig.S3.Region, - Endpoint: tektonConfig.S3.Endpoint, - Bucket: tektonConfig.S3.Bucket, - DisableSSL: tektonConfig.S3.DisableSSL, - SkipVerify: tektonConfig.S3.SkipVerify, - S3ForcePathStyle: tektonConfig.S3.S3ForcePathStyle, + AccessKey: tektonConfig.LogStorage.AccessKey, + SecretKey: tektonConfig.LogStorage.SecretKey, + Region: tektonConfig.LogStorage.Region, + Endpoint: tektonConfig.LogStorage.Endpoint, + Bucket: tektonConfig.LogStorage.Bucket, + DisableSSL: tektonConfig.LogStorage.DisableSSL, + SkipVerify: tektonConfig.LogStorage.SkipVerify, + S3ForcePathStyle: tektonConfig.LogStorage.S3ForcePathStyle, ContentType: "text/plain", }) if err != nil { @@ -54,7 +57,7 @@ func NewFactory(tektonMapper tektonconfig.Mapper) (Factory, error) { } c = collector.NewS3Collector(s3Driver, t) } else { - c = collector.NewNoStorageCollector(t) + c = collector.NewDummyCollector(t) } cache.Store(env, &tektonCache{ tekton: t, diff --git a/pkg/config/tekton/tekton.go b/pkg/config/tekton/tekton.go index f1637f3c..f6cbdd2a 100644 --- a/pkg/config/tekton/tekton.go +++ b/pkg/config/tekton/tekton.go @@ -3,14 +3,14 @@ package tekton type Mapper map[string]*Tekton type Tekton struct { - Server string `yaml:"server"` - Namespace string `yaml:"namespace"` - Kubeconfig string `yaml:"kubeconfig"` - S3 *S3 `yaml:"s3"` + Server string `yaml:"server"` + Namespace string `yaml:"namespace"` + Kubeconfig string `yaml:"kubeconfig"` + LogStorage *LogStorage `yaml:"logStorage"` } -type S3 struct { - Enabled bool `yaml:"enabled"` +type LogStorage struct { + Type string `yaml:"type"` AccessKey string `yaml:"accessKey"` SecretKey string `yaml:"secretKey"` Region string `yaml:"region"` From 2c9cf8e95fd65c1ffbe3ebfc673e44ee6ccd4678 Mon Sep 17 00:00:00 2001 From: "xu.zhu" Date: Tue, 28 Mar 2023 19:41:01 +0800 Subject: [PATCH 4/5] fix: upgrade github actions runner image Signed-off-by: xu.zhu --- .github/workflows/image.yml | 2 +- .github/workflows/ut.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index bb5b1916..23a248ad 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: components: [core, swagger] - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 with: diff --git a/.github/workflows/ut.yml b/.github/workflows/ut.yml index e273294b..344462ed 100644 --- a/.github/workflows/ut.yml +++ b/.github/workflows/ut.yml @@ -18,7 +18,7 @@ permissions: jobs: lint: name: golangci-lint - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/setup-go@v3 with: @@ -35,7 +35,7 @@ jobs: go: [1.15] name: unit-test needs: [lint] - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/setup-go@v3 with: From 51dc7046bbdd14fbe9f9b6273daf0985916dcfa5 Mon Sep 17 00:00:00 2001 From: "xu.zhu" Date: Tue, 28 Mar 2023 20:29:20 +0800 Subject: [PATCH 5/5] fix: review Signed-off-by: xu.zhu --- config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index e5b3ba2f..da0d39a3 100644 --- a/config.yaml +++ b/config.yaml @@ -52,8 +52,8 @@ tektonMapper: kubeconfig: "/Users/xxx/.kube/config" logStorage: # the following types of log storage are supported: - # s3: default minio is used, and you can also configure your own s3 storage - # dummy: a dummy log storage, build logs are not stored and get them directly from k8s + # s3: Minio is used by default, and you can also specify your own s3 storage. + # dummy: A dummy log storage. Building logs are not stored and Horizon gets them directly from k8s. type: dummy accessKey: "" secretKey: ""