Skip to content

chore: http transport service refactoring #6592

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

Merged
merged 6 commits into from
May 23, 2025
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ require (

replace (
github.com/argoproj/argo-workflows/v3 v3.5.13 => github.com/devtron-labs/argo-workflows/v3 v3.5.13
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250522103151-bbd74bc17b49
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250522103151-bbd74bc17b49
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250522104903-ba0d761f14a3
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250522104903-ba0d761f14a3
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5
k8s.io/api => k8s.io/api v0.29.7
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpSN5Rp/8mfQORh8SmU=
github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250522103151-bbd74bc17b49 h1:OrLZfLXifIHOewjANdNsiwGAU38L26aTEbR6RJ0yr1c=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250522103151-bbd74bc17b49/go.mod h1:FfaLDXN1ZXxyRpnskBqVIYkpkWDCzBmDgIO9xqLnxdQ=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250522103151-bbd74bc17b49 h1:75n5bnZURneI2ileon0/PN2gQNorhUIzhQ7Jz7qgHTM=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250522103151-bbd74bc17b49/go.mod h1:CXQGEo+kZc7JPX5hn4jJf1msal9q/ExSdAYGkHNPnQw=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250522104903-ba0d761f14a3 h1:YJDD0cAB88y8NaTf1L10lrWavjRz9wTUVVBLk3dZeHI=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250522104903-ba0d761f14a3/go.mod h1:FfaLDXN1ZXxyRpnskBqVIYkpkWDCzBmDgIO9xqLnxdQ=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250522104903-ba0d761f14a3 h1:Tms2vTi1npEHJtHf0RtqD9xBQNkCP3J0xMNXGzKSIOA=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250522104903-ba0d761f14a3/go.mod h1:HQVUnQI7WHwVq89Bib/18xJqM89S1+xI0O7REctMMrA=
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
github.com/devtron-labs/protos v0.0.3-0.20250323220609-ecf8a0f7305e h1:U6UdYbW8a7xn5IzFPd8cywjVVPfutGJCudjePAfL/Hs=
Expand Down
26 changes: 14 additions & 12 deletions pkg/pipeline/CiCdPipelineOrchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,20 @@ func (impl CiCdPipelineOrchestratorImpl) DeleteApp(appId int, userId int32) erro
}
// Rollback tx on error.
defer tx.Rollback()
// deleting deployment config first as it is dependent on app
appDeploymentConfig, err := impl.deploymentConfigService.GetAndMigrateConfigIfAbsentForDevtronApps(appId, 0)
if err != nil && !errors.Is(err, pg.ErrNoRows) {
impl.logger.Errorw("error in fetching environment deployment config by appId and envId", "appId", appId, "err", err)
return err
} else if err == nil && appDeploymentConfig != nil {
appDeploymentConfig.Active = false
appDeploymentConfig, err = impl.deploymentConfigService.CreateOrUpdateConfig(tx, appDeploymentConfig, userId)
if err != nil {
impl.logger.Errorw("error in deleting deployment config for pipeline", "appId", appId, "err", err)
return err
}
}
// deleting app
app.Active = false
app.UpdatedOn = time.Now()
app.UpdatedBy = userId
Expand All @@ -1383,18 +1397,6 @@ func (impl CiCdPipelineOrchestratorImpl) DeleteApp(appId int, userId int32) erro
impl.logger.Errorw("error in deleting auth roles", "err", err)
return err
}
appDeploymentConfig, err := impl.deploymentConfigService.GetAndMigrateConfigIfAbsentForDevtronApps(appId, 0)
if err != nil && !errors.Is(err, pg.ErrNoRows) {
impl.logger.Errorw("error in fetching environment deployment config by appId and envId", "appId", appId, "err", err)
return err
} else if err == nil && appDeploymentConfig != nil {
appDeploymentConfig.Active = false
appDeploymentConfig, err = impl.deploymentConfigService.CreateOrUpdateConfig(tx, appDeploymentConfig, userId)
if err != nil {
impl.logger.Errorw("error in deleting deployment config for pipeline", "appId", appId, "err", err)
return err
}
}
err = tx.Commit()
if err != nil {
return err
Expand Down
11 changes: 3 additions & 8 deletions pkg/terminal/terminalSesion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package terminal

import (
Expand Down Expand Up @@ -566,23 +567,17 @@ func (impl *TerminalSessionHandlerImpl) getClientSetAndRestConfigForTerminalConn
}

clusterConfig = clusterBean.GetClusterConfig()
restConfig, err = impl.k8sUtil.GetRestConfigByCluster(clusterConfig)
restConfig, err = impl.k8sUtil.GetRestConfigByCluster(clusterConfig, k8s.WithDefaultHttpTransport())
if err != nil {
impl.logger.Errorw("error in getting rest config by cluster", "err", err, "clusterName", clusterConfig.ClusterName)
return nil, nil, err
}

_, clientSet, err := impl.k8sUtil.GetK8sConfigAndClientsByRestConfig(restConfig)
_, clientSet, err := impl.k8sUtil.GetK8sConfigAndClientsByRestConfig(restConfig, k8s.WithDefaultHttpTransport())
if err != nil {
impl.logger.Errorw("error in clientSet", "err", err)
return nil, nil, err
}

// we have to get the clientSet before setting the custom transport to nil
// we need re populate the tls config in the restConfig.
// rest config with custom transport will break spdy client
clusterConfig.PopulateTlsConfigurationsInto(restConfig)
restConfig.Transport = nil
return restConfig, clientSet, nil
}
}
Expand Down
129 changes: 129 additions & 0 deletions vendor/github.com/devtron-labs/common-lib/utils/k8s/HttpTansport.go

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

Loading