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

CR-14985-flag #608

Merged
merged 8 commits into from
Oct 26, 2022
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
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;
yaroslav-codefresh marked this conversation as resolved.
Show resolved Hide resolved

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"
yaroslav-codefresh marked this conversation as resolved.
Show resolved Hide resolved
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