Skip to content

Commit

Permalink
CR-14985-flag (#608)
Browse files Browse the repository at this point in the history
* add internalRouterApplied flag + adjust internal router ingress

* bump version

* fixes

* fixes

* fixes

* fixes

* fixes
  • Loading branch information
yaroslav-codefresh authored Oct 26, 2022
1 parent 22f2774 commit d1c2bf5
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.0.548
VERSION=v0.0.549

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
11 changes: 4 additions & 7 deletions cmd/commands/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,20 +897,17 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
}
}

handleCliStep(reporter.UpgradeStepInstallNewComponents, "Install new components", err, false, false)

needsInternalRouter := curRt.Spec.Version.LessThan(semver.MustParse("v0.0.543"))
hasLatestInternalRouter := !curRt.Spec.Version.LessThan(semver.MustParse("v0.0.549"))
isIngress := curRt.Spec.AccessMode == platmodel.AccessModeIngress
isNotAlb := curRt.Spec.IngressController != string(routingutil.IngressControllerALB)

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

err = migrateInternalRouter(ctx, opts, newRt)
if err != nil {
return fmt.Errorf("failed to migrate internal router: %w", err)
}

handleCliStep(reporter.UpgradeStepMigrateInternalRouter, "Migrate internal router", err, false, false)
}

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

if err := util.Retry(ctx, &util.RetryOptions{
Func: func() error {
return CreateInternalRouterIngress(ctx, createOpts, newRt)
return CreateInternalRouterIngress(ctx, createOpts, newRt, true)
},
}); err != nil {
return fmt.Errorf("failed to patch Internal Router ingress: %w", err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/commands/runtime_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ func installComponents(ctx context.Context, opts *RuntimeInstallOptions, rt *run

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

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

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

if internalIngressEnabled {
if !onlyWebhooks && internalIngressEnabled {
routeOpts := routingutil.CreateRouteOpts{
RuntimeName: rt.Name,
Namespace: rt.Namespace,
Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cf version

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

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

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

# move the binary to your $PATH
mv ./cf-darwin-amd64 /usr/local/bin/cf
Expand Down
1 change: 1 addition & 0 deletions manifests/internal-router/internal-router.cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
chunked_transfer_encoding off;
proxy_pass http://cap-app-proxy:3017;
}
Expand Down
5 changes: 4 additions & 1 deletion manifests/internal-router/internal-router.deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ spec:
spec:
containers:
- name: nginx
image: nginx:1.23-alpine
# do not upgrade to 1.23 until it's really critical
# 1.23 removed support for "Transfer-Encoding: identity" header value
# and it will break SSE from app-proxy
image: nginx:1.22-alpine
ports:
- containerPort: 80
volumeMounts:
Expand Down
4 changes: 2 additions & 2 deletions manifests/runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: "{{ name }}"
namespace: "{{ namespace }}"
spec:
defVersion: 2.1.0
version: 0.0.548
defVersion: 2.1.1
version: 0.0.549
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
components:
- name: events
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
buildDate = ""
gitCommit = ""
SegmentWriteKey = ""
maxDefVersion = "2.1.0"
maxDefVersion = "2.1.1"
RuntimeDefURL = "manifests/runtime.yaml"
AddClusterDefURL = "https://github.com/codefresh-io/csdp-official/add-cluster/kustomize"
FallbackAddClusterDefURL = "https://github.com/codefresh-io/cli-v2/manifests/add-cluster/kustomize"
Expand Down
18 changes: 12 additions & 6 deletions pkg/util/routing/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func CreateInternalRouterInternalRoute(opts *CreateRouteOpts, useGatewayAPI bool
return routeName, route
}

func CreateInternalRouterRoute(opts *CreateRouteOpts, useGatewayAPI bool, includeInternalRoutes bool) (string, interface{}) {
func CreateInternalRouterRoute(opts *CreateRouteOpts, useGatewayAPI bool, includeInternalRoutes bool, onlyWebhooks bool) (string, interface{}) {
var route interface{}
var routeName string

Expand All @@ -109,20 +109,26 @@ func CreateInternalRouterRoute(opts *CreateRouteOpts, useGatewayAPI bool, includ
serviceName: store.Get().InternalRouterServiceName,
servicePort: store.Get().InternalRouterServicePort,
},
{
},
Annotations: opts.Annotations,
IngressController: opts.IngressController,
}

// on upgrade, we do not want collisions with existing ingresses
if !onlyWebhooks {
createRouteOpts.Paths = append(createRouteOpts.Paths,
RoutePath{
pathType: PrefixPath,
path: store.Get().ArgoWfIngressPath,
serviceName: store.Get().InternalRouterServiceName,
servicePort: store.Get().InternalRouterServicePort,
},
},
Annotations: opts.Annotations,
IngressController: opts.IngressController,
)
}

// when using internal ingress -- we need to extract app-proxy
// to a separate ingress (with its own host and annotations)
if includeInternalRoutes {
if !onlyWebhooks && includeInternalRoutes {
createRouteOpts.Paths = append(createRouteOpts.Paths,
RoutePath{
pathType: PrefixPath,
Expand Down

0 comments on commit d1c2bf5

Please sign in to comment.