Skip to content

Commit d1c2bf5

Browse files
CR-14985-flag (#608)
* add internalRouterApplied flag + adjust internal router ingress * bump version * fixes * fixes * fixes * fixes * fixes
1 parent 22f2774 commit d1c2bf5

File tree

9 files changed

+32
-25
lines changed

9 files changed

+32
-25
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.548
1+
VERSION=v0.0.549
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/runtime.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -897,20 +897,17 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
897897
}
898898
}
899899

900-
handleCliStep(reporter.UpgradeStepInstallNewComponents, "Install new components", err, false, false)
901-
902-
needsInternalRouter := curRt.Spec.Version.LessThan(semver.MustParse("v0.0.543"))
900+
hasLatestInternalRouter := !curRt.Spec.Version.LessThan(semver.MustParse("v0.0.549"))
903901
isIngress := curRt.Spec.AccessMode == platmodel.AccessModeIngress
904-
isNotAlb := curRt.Spec.IngressController != string(routingutil.IngressControllerALB)
905902

906-
if !opts.SkipIngress && needsInternalRouter && isIngress && isNotAlb {
903+
handleCliStep(reporter.UpgradeStepInstallNewComponents, "Install new components", err, false, false)
904+
if !opts.SkipIngress && !hasLatestInternalRouter && isIngress {
907905
log.G(ctx).Info("Migrating to Internal Router ")
908906

909907
err = migrateInternalRouter(ctx, opts, newRt)
910908
if err != nil {
911909
return fmt.Errorf("failed to migrate internal router: %w", err)
912910
}
913-
914911
handleCliStep(reporter.UpgradeStepMigrateInternalRouter, "Migrate internal router", err, false, false)
915912
}
916913

@@ -979,7 +976,7 @@ func migrateInternalRouter(ctx context.Context, opts *RuntimeUpgradeOptions, new
979976

980977
if err := util.Retry(ctx, &util.RetryOptions{
981978
Func: func() error {
982-
return CreateInternalRouterIngress(ctx, createOpts, newRt)
979+
return CreateInternalRouterIngress(ctx, createOpts, newRt, true)
983980
},
984981
}); err != nil {
985982
return fmt.Errorf("failed to patch Internal Router ingress: %w", err)

cmd/commands/runtime_install.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ func installComponents(ctx context.Context, opts *RuntimeInstallOptions, rt *run
10321032

10331033
// bitbucket cloud take more time to push a commit
10341034
// the perpuse of all retries is to avoid issues of cloning before pervious commit was pushed
1035-
if opts.shouldInstallIngress() && rt.Spec.IngressController != string(routingutil.IngressControllerALB) {
1035+
if opts.shouldInstallIngress() {
10361036
if err = util.Retry(ctx, &util.RetryOptions{
10371037
Func: func() error {
10381038
return CreateInternalRouterIngress(ctx, &CreateIngressOptions{
@@ -1048,7 +1048,7 @@ func installComponents(ctx context.Context, opts *RuntimeInstallOptions, rt *run
10481048
InternalIngressAnnotation: opts.InternalIngressAnnotation,
10491049
ExternalIngressAnnotation: opts.ExternalIngressAnnotation,
10501050
useGatewayAPI: opts.useGatewayAPI,
1051-
}, rt)
1051+
}, rt, false)
10521052
},
10531053
}); err != nil {
10541054
return fmt.Errorf("failed to patch Internal Router ingress: %w", err)
@@ -1397,7 +1397,7 @@ func persistRuntime(ctx context.Context, cloneOpts *apgit.CloneOptions, rt *runt
13971397
return apu.PushWithMessage(ctx, r, "Persisted runtime data")
13981398
}
13991399

1400-
func CreateInternalRouterIngress(ctx context.Context, opts *CreateIngressOptions, rt *runtime.Runtime) error {
1400+
func CreateInternalRouterIngress(ctx context.Context, opts *CreateIngressOptions, rt *runtime.Runtime, onlyWebhooks bool) error {
14011401
r, fs, err := opts.InsCloneOpts.GetRepo(ctx)
14021402
if err != nil {
14031403
return err
@@ -1416,7 +1416,7 @@ func CreateInternalRouterIngress(ctx context.Context, opts *CreateIngressOptions
14161416
GatewayName: opts.GatewayName,
14171417
GatewayNamespace: opts.GatewayNamespace,
14181418
}
1419-
routeName, route := routingutil.CreateInternalRouterRoute(&routeOpts, opts.useGatewayAPI, !internalIngressEnabled)
1419+
routeName, route := routingutil.CreateInternalRouterRoute(&routeOpts, opts.useGatewayAPI, !internalIngressEnabled, onlyWebhooks)
14201420
routeFileName := fmt.Sprintf("%s.yaml", routeName)
14211421

14221422
if err := writeObjectToYaml(fs, fs.Join(overlaysDir, routeFileName), &route, cleanUpFieldsIngress); err != nil {
@@ -1432,7 +1432,7 @@ func CreateInternalRouterIngress(ctx context.Context, opts *CreateIngressOptions
14321432
kust.Resources = append(kust.Resources, routeFileName)
14331433
}
14341434

1435-
if internalIngressEnabled {
1435+
if !onlyWebhooks && internalIngressEnabled {
14361436
routeOpts := routingutil.CreateRouteOpts{
14371437
RuntimeName: rt.Name,
14381438
Namespace: rt.Namespace,

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.548/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.549/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.548/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.549/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/internal-router/internal-router.cm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ data:
1616
proxy_http_version 1.1;
1717
proxy_set_header Upgrade $http_upgrade;
1818
proxy_set_header Connection "upgrade";
19+
chunked_transfer_encoding off;
1920
2021
proxy_pass http://cap-app-proxy:3017;
2122
}

manifests/internal-router/internal-router.deploy.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ spec:
1414
spec:
1515
containers:
1616
- name: nginx
17-
image: nginx:1.23-alpine
17+
# do not upgrade to 1.23 until it's really critical
18+
# 1.23 removed support for "Transfer-Encoding: identity" header value
19+
# and it will break SSE from app-proxy
20+
image: nginx:1.22-alpine
1821
ports:
1922
- containerPort: 80
2023
volumeMounts:

manifests/runtime.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ metadata:
44
name: "{{ name }}"
55
namespace: "{{ namespace }}"
66
spec:
7-
defVersion: 2.1.0
8-
version: 0.0.548
7+
defVersion: 2.1.1
8+
version: 0.0.549
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

pkg/store/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030
buildDate = ""
3131
gitCommit = ""
3232
SegmentWriteKey = ""
33-
maxDefVersion = "2.1.0"
33+
maxDefVersion = "2.1.1"
3434
RuntimeDefURL = "manifests/runtime.yaml"
3535
AddClusterDefURL = "https://github.com/codefresh-io/csdp-official/add-cluster/kustomize"
3636
FallbackAddClusterDefURL = "https://github.com/codefresh-io/cli-v2/manifests/add-cluster/kustomize"

pkg/util/routing/common.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func CreateInternalRouterInternalRoute(opts *CreateRouteOpts, useGatewayAPI bool
9090
return routeName, route
9191
}
9292

93-
func CreateInternalRouterRoute(opts *CreateRouteOpts, useGatewayAPI bool, includeInternalRoutes bool) (string, interface{}) {
93+
func CreateInternalRouterRoute(opts *CreateRouteOpts, useGatewayAPI bool, includeInternalRoutes bool, onlyWebhooks bool) (string, interface{}) {
9494
var route interface{}
9595
var routeName string
9696

@@ -109,20 +109,26 @@ func CreateInternalRouterRoute(opts *CreateRouteOpts, useGatewayAPI bool, includ
109109
serviceName: store.Get().InternalRouterServiceName,
110110
servicePort: store.Get().InternalRouterServicePort,
111111
},
112-
{
112+
},
113+
Annotations: opts.Annotations,
114+
IngressController: opts.IngressController,
115+
}
116+
117+
// on upgrade, we do not want collisions with existing ingresses
118+
if !onlyWebhooks {
119+
createRouteOpts.Paths = append(createRouteOpts.Paths,
120+
RoutePath{
113121
pathType: PrefixPath,
114122
path: store.Get().ArgoWfIngressPath,
115123
serviceName: store.Get().InternalRouterServiceName,
116124
servicePort: store.Get().InternalRouterServicePort,
117125
},
118-
},
119-
Annotations: opts.Annotations,
120-
IngressController: opts.IngressController,
126+
)
121127
}
122128

123129
// when using internal ingress -- we need to extract app-proxy
124130
// to a separate ingress (with its own host and annotations)
125-
if includeInternalRoutes {
131+
if !onlyWebhooks && includeInternalRoutes {
126132
createRouteOpts.Paths = append(createRouteOpts.Paths,
127133
RoutePath{
128134
pathType: PrefixPath,

0 commit comments

Comments
 (0)