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

feat: upload and download logs/artifact from blob storage configured in external cluster #4138

Merged
merged 30 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
72d3c3e
blob storage cm secret inducing internally and removed AWS creds set …
prakash100198 Oct 18, 2023
7db0738
some refactoring and UseExternalClusterBlob flag introduced in cicdco…
prakash100198 Oct 18, 2023
a23d3e8
added support fr fetching logs and artifacts from external cluster bl…
prakash100198 Oct 20, 2023
70cf43a
wire
prakash100198 Oct 20, 2023
45a614f
main sync
prakash100198 Oct 20, 2023
06ccbd1
minor fix
prakash100198 Oct 20, 2023
0915bd2
import fix
prakash100198 Oct 20, 2023
92557ad
code refactoring
prakash100198 Oct 20, 2023
bc249fd
info comment
prakash100198 Oct 24, 2023
cb174cb
fix
prakash100198 Oct 24, 2023
1da47a8
comments added
prakash100198 Oct 24, 2023
74165a8
comments fix
prakash100198 Oct 24, 2023
8ef0a28
decodeSecretKey
prakash100198 Oct 24, 2023
24152a1
code review oncorporation l1
prakash100198 Oct 25, 2023
c4dc66e
code review incorporation l2
prakash100198 Oct 25, 2023
d8ccf8b
Merge branch 'main' into ext-cluster-blob-issue
prakash100198 Oct 26, 2023
430c93f
code review incorporation l3
prakash100198 Oct 26, 2023
5f68d00
code review incorporation l4
prakash100198 Oct 26, 2023
23f2bbb
code review incorporation l5
prakash100198 Oct 26, 2023
734cc55
code review incorporation l6
prakash100198 Oct 26, 2023
e89a556
main branch sync
prakash100198 Oct 26, 2023
bd3e83d
minor fix for job tyoe
prakash100198 Oct 27, 2023
c616e88
minor fix
prakash100198 Oct 27, 2023
e25d2fc
code review incorporation
prakash100198 Oct 27, 2023
67cdff2
code review incorporation
prakash100198 Oct 27, 2023
7f82b16
code review incorporation
prakash100198 Oct 27, 2023
9ea6b38
Merge branch 'main' into ext-cluster-blob-issue
prakash100198 Oct 30, 2023
2bf4838
minor fix after debugging error
prakash100198 Oct 30, 2023
69f550e
main code sync
prakash100198 Oct 31, 2023
b5c05e4
common lib version upgrade from 0.0.3 to 0.0.4
prakash100198 Oct 31, 2023
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
2 changes: 1 addition & 1 deletion pkg/generateManifest/DeployementTemplateService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
client2 "github.com/devtron-labs/authenticator/client"
"github.com/devtron-labs/common-lib/utils/k8s"
"github.com/devtron-labs/devtron/api/bean"
client "github.com/devtron-labs/devtron/api/helm-app"
mocks4 "github.com/devtron-labs/devtron/api/helm-app/mocks"
Expand All @@ -16,7 +17,6 @@ import (
"github.com/devtron-labs/devtron/pkg/chart/mocks"
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
mocks5 "github.com/devtron-labs/devtron/pkg/chartRepo/repository/mocks"
"github.com/devtron-labs/devtron/util/k8s"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"testing"
Expand Down
218 changes: 214 additions & 4 deletions pkg/pipeline/CdHandler.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/pipeline/CiCdConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ type CiCdConfig struct {
BaseLogLocationPath string `env:"BASE_LOG_LOCATION_PATH" envDefault:"/home/devtron/"`
InAppLoggingEnabled bool `env:"IN_APP_LOGGING_ENABLED" envDefault:"false"`
BuildxProvenanceMode string `env:"BUILDX_PROVENANCE_MODE" envDefault:""` //provenance is set to false if this flag is not set
ExtBlobStorageCmName string `env:"EXTERNAL_BLOB_STORAGE_CM_NAME" envDefault:"blob-storage-cm"`
ExtBlobStorageSecretName string `env:"EXTERNAL_BLOB_STORAGE_SECRET_NAME" envDefault:"blob-storage-secret"`
}

type CiConfig struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/pipeline/CiService.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,12 @@ func (impl *CiServiceImpl) buildWfRequestForCiPipeline(pipeline *pipelineConfig.
ImageRetryCount: impl.config.ImageRetryCount,
ImageRetryInterval: impl.config.ImageRetryInterval,
WorkflowExecutor: impl.config.GetWorkflowExecutorType(),
ExtBlobStorageSecretName: impl.config.ExtBlobStorageSecretName,
ExtBlobStorageCmName: impl.config.ExtBlobStorageCmName,
Type: bean2.CI_WORKFLOW_PIPELINE_TYPE,
CiArtifactLastFetch: trigger.CiArtifactLastFetch,
}

if dockerRegistry != nil {

workflowRequest.DockerRegistryId = dockerRegistry.Id
Expand Down
12 changes: 7 additions & 5 deletions pkg/pipeline/WorkflowDagExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,13 @@ func (impl *WorkflowDagExecutorImpl) buildWFRequest(runner *pipelineConfig.CdWor
DataSource: artifact.DataSource,
WorkflowId: artifact.WorkflowId,
},
OrchestratorHost: impl.config.OrchestratorHost,
OrchestratorToken: impl.config.OrchestratorToken,
CloudProvider: impl.config.CloudProvider,
WorkflowExecutor: workflowExecutor,
RefPlugins: refPluginsData,
OrchestratorHost: impl.config.OrchestratorHost,
OrchestratorToken: impl.config.OrchestratorToken,
CloudProvider: impl.config.CloudProvider,
WorkflowExecutor: workflowExecutor,
RefPlugins: refPluginsData,
ExtBlobStorageSecretName: impl.config.ExtBlobStorageSecretName,
ExtBlobStorageCmName: impl.config.ExtBlobStorageCmName,
}

extraEnvVariables := make(map[string]string)
Expand Down
18 changes: 18 additions & 0 deletions pkg/pipeline/WorkflowService.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,24 @@ func (impl *WorkflowServiceImpl) addExistingCmCsInWorkflow(workflowRequest *Work
workflowSecrets = append(workflowSecrets, *secret)
}
}
//internally inducing BlobStorageCmName and BlobStorageSecretName for getting logs, caches and artifacts from
//in-cluster configured blob storage, if USE_BLOB_STORAGE_CONFIG_IN_CD_WORKFLOW = false and isExt = true
if workflowRequest.UseExternalClusterBlob {
blobDetailsConfigMap := bean.ConfigSecretMap{
Name: impl.ciCdConfig.ExtBlobStorageCmName,
Type: "environment",
External: true,
}
workflowConfigMaps = append(workflowConfigMaps, blobDetailsConfigMap)

blobDetailsSecret := bean.ConfigSecretMap{
Name: impl.ciCdConfig.ExtBlobStorageSecretName,
Type: "environment",
External: true,
}
workflowSecrets = append(workflowSecrets, blobDetailsSecret)
}

prakash100198 marked this conversation as resolved.
Show resolved Hide resolved
return workflowConfigMaps, workflowSecrets, nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/pipeline/WorkflowUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ type WorkflowRequest struct {
WorkflowExecutor pipelineConfig.WorkflowExecutorType `json:"workflowExecutor"`
PrePostDeploySteps []*bean.StepObject `json:"prePostDeploySteps"`
CiArtifactLastFetch time.Time `json:"ciArtifactLastFetch"`
ExtBlobStorageCmName string `json:"extBlobStorageCmName"`
ExtBlobStorageSecretName string `json:"extBlobStorageSecretName"`
UseExternalClusterBlob bool `json:"useExternalClusterBlob"`
Type bean.WorkflowPipelineType
Pipeline *pipelineConfig.Pipeline
Env *repository2.Environment
Expand Down Expand Up @@ -437,6 +440,7 @@ func (workflowRequest *WorkflowRequest) GetBlobStorageLogsKey(config *CiCdConfig
func (workflowRequest *WorkflowRequest) GetWorkflowJson(config *CiCdConfig) ([]byte, error) {
workflowRequest.updateBlobStorageLogsKey(config)
workflowRequest.updateExternalRunMetadata()
workflowRequest.UseExternalClusterBlob = !workflowRequest.CheckBlobStorageConfig(config) && workflowRequest.IsExtRun
workflowJson, err := workflowRequest.getWorkflowJson()
if err != nil {
return nil, err
Expand Down Expand Up @@ -471,10 +475,6 @@ func (workflowRequest *WorkflowRequest) getContainerEnvVariables(config *CiCdCon
workflowRequest.Type == bean.JOB_WORKFLOW_PIPELINE_TYPE {
containerEnvVariables = []v12.EnvVar{{Name: "IMAGE_SCANNER_ENDPOINT", Value: config.ImageScannerEndpoint}}
}
if config.CloudProvider == BLOB_STORAGE_S3 && config.BlobStorageS3AccessKey != "" {
miniCred := []v12.EnvVar{{Name: "AWS_ACCESS_KEY_ID", Value: config.BlobStorageS3AccessKey}, {Name: "AWS_SECRET_ACCESS_KEY", Value: config.BlobStorageS3SecretKey}}
containerEnvVariables = append(containerEnvVariables, miniCred...)
}
prakash100198 marked this conversation as resolved.
Show resolved Hide resolved
eventEnv := v12.EnvVar{Name: "CI_CD_EVENT", Value: string(workflowJson)}
inAppLoggingEnv := v12.EnvVar{Name: "IN_APP_LOGGING", Value: strconv.FormatBool(workflowRequest.InAppLoggingEnabled)}
containerEnvVariables = append(containerEnvVariables, eventEnv, inAppLoggingEnv)
Expand Down
2 changes: 1 addition & 1 deletion wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading