Skip to content

Commit

Permalink
Merge branch 'main' into upload-playwright-report-on-failure
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh authored Apr 26, 2024
2 parents 9c3e349 + 8c3cd3a commit 394ce64
Show file tree
Hide file tree
Showing 78 changed files with 542 additions and 5,459 deletions.
11 changes: 0 additions & 11 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ make e2e \
KOTSADM_IMAGE_TAG=24h
```

To run a helm-managed mode test:

*Note the admin console helm chart is maintained in a [separate repo](https://github.com/replicatedhq/kots-helm)*

```bash
make e2e \
FOCUS="Helm Managed"
KOTS_HELM_CHART_URL=oci://ttl.sh/$USER/admin-console
KOTS_HELM_CHART_VERSION=$VERSION
```

To run using a specific testim branch:
```bash
make e2e \
Expand Down
16 changes: 2 additions & 14 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package e2e
import (
"context"
"flag"
"fmt"
"os"
"testing"
"time"
Expand Down Expand Up @@ -178,18 +177,8 @@ var _ = Describe("E2E", func() {
prometheus.Install(helmCLI, c.GetKubeconfig())
}

var adminConsolePort string
if test.IsHelmManaged {
GinkgoWriter.Println("Installing KOTS Helm chart")
session, err := helmCLI.Install(c.GetKubeconfig(), "-n", test.Namespace, "admin-console", kotsHelmChartURL, "--set", fmt.Sprintf("password=%s", inventory.HelmPassword), "--version", kotsHelmChartVersion, "--create-namespace", "--wait")
Expect(err).WithOffset(1).Should(Succeed(), "helm install")
Eventually(session).WithOffset(1).WithTimeout(time.Minute).Should(gexec.Exit(0), "helm install failed with non-zero exit code")

adminConsolePort = kotsInstaller.AdminConsolePortForward(c.GetKubeconfig(), test, kotsadmForwardPort)
} else {
GinkgoWriter.Println("Installing KOTS")
adminConsolePort = kotsInstaller.Install(c.GetKubeconfig(), test, kotsadmForwardPort)
}
GinkgoWriter.Println("Installing KOTS")
adminConsolePort := kotsInstaller.Install(c.GetKubeconfig(), test, kotsadmForwardPort)

GinkgoWriter.Println("Running E2E tests")

Expand Down Expand Up @@ -223,7 +212,6 @@ var _ = Describe("E2E", func() {
Entry(nil, inventory.NewNoRequiredConfig()),
Entry(nil, inventory.NewVersionHistoryPagination()),
Entry(nil, inventory.NewChangeLicense()),
Entry(nil, inventory.NewHelmManagedMode()),
Entry(nil, inventory.NewMinKotsVersion()),
Entry(nil, inventory.NewTargetKotsVersion()),
Entry(nil, inventory.NewRangeKotsVersion()),
Expand Down
18 changes: 0 additions & 18 deletions e2e/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,6 @@ func NewChangeLicense() Test {
}
}

func NewHelmManagedMode() Test {
return Test{
Name: "Helm Managed",
TestimSuite: "helm-managed",
Namespace: "helm-managed",
UpstreamURI: "helm-managed/automated",
IsHelmManaged: true,
Setup: SetupHelmManagedMode,
}
}

func NewMultiAppBackupAndRestoreTest() Test {
return Test{
Name: "multi-app-backup-and-restore",
Expand Down Expand Up @@ -197,10 +186,3 @@ func SetupRegressionTest(kubectlCLI *kubectl.CLI) TestimParams {
Eventually(session).WithOffset(1).WithTimeout(30*time.Minute).Should(gexec.Exit(0), "Create registry-creds secret failed with non-zero exit code")
return nil
}

func SetupHelmManagedMode(kubectlCLI *kubectl.CLI) TestimParams {
return TestimParams{
"kotsadmPassword": HelmPassword,
"kotsadmNamespace": "helm-managed",
}
}
1 change: 0 additions & 1 deletion e2e/inventory/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ type Test struct {
NeedsSnapshots bool
NeedsMonitoring bool
NeedsRegistry bool
IsHelmManaged bool
Setup func(kubectlCLI *kubectl.CLI) TestimParams
}
10 changes: 0 additions & 10 deletions pkg/api/handlers/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ type ListAppsResponse struct {
Apps []ResponseApp `json:"apps"`
}

type ListAppsHelmResponse struct {
Apps []HelmResponseApp `json:"apps"`
}

type AppStatusResponse struct {
AppStatus *appstatetypes.AppStatus `json:"appstatus"`
}
Expand Down Expand Up @@ -58,12 +54,6 @@ type Credentials struct {
Password string `json:"password"`
}

type HelmResponseApp struct {
ResponseApp
ChartPath string `json:"chartPath,omitempty"`
Credentials Credentials `json:"credentials"`
}

type ResponseDownstream struct {
Name string `json:"name"`
Links []versiontypes.RealizedLink `json:"links"`
Expand Down
13 changes: 5 additions & 8 deletions pkg/apiserver/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/replicatedhq/kots/pkg/crypto"
"github.com/replicatedhq/kots/pkg/kotsutil"
"github.com/replicatedhq/kots/pkg/store"
"github.com/replicatedhq/kots/pkg/util"
)

type BootstrapParams struct {
Expand All @@ -21,13 +20,11 @@ func bootstrap(params BootstrapParams) error {
return errors.Wrap(err, "failed to init store")
}

if !util.IsHelmManaged() {
if err := bootstrapClusterToken(params.AutoCreateClusterToken); err != nil {
return errors.Wrap(err, "failed to bootstrap cluster token")
}
if err := loadEncryptionKeys(); err != nil {
return errors.Wrap(err, "failed to load encryption keys")
}
if err := bootstrapClusterToken(params.AutoCreateClusterToken); err != nil {
return errors.Wrap(err, "failed to bootstrap cluster token")
}
if err := loadEncryptionKeys(); err != nil {
return errors.Wrap(err, "failed to load encryption keys")
}

return nil
Expand Down
96 changes: 39 additions & 57 deletions pkg/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ import (
"github.com/replicatedhq/kots/pkg/binaries"
"github.com/replicatedhq/kots/pkg/embeddedcluster"
"github.com/replicatedhq/kots/pkg/handlers"
"github.com/replicatedhq/kots/pkg/helm"
identitymigrate "github.com/replicatedhq/kots/pkg/identity/migrate"
"github.com/replicatedhq/kots/pkg/informers"
"github.com/replicatedhq/kots/pkg/k8sutil"
"github.com/replicatedhq/kots/pkg/operator"
"github.com/replicatedhq/kots/pkg/operator/client"
operatorclient "github.com/replicatedhq/kots/pkg/operator/client"
"github.com/replicatedhq/kots/pkg/persistence"
"github.com/replicatedhq/kots/pkg/policy"
"github.com/replicatedhq/kots/pkg/rbac"
Expand All @@ -44,24 +43,20 @@ type APIServerParams struct {
func Start(params *APIServerParams) {
log.Printf("kotsadm version %s\n", params.Version)

if !util.IsHelmManaged() {
// set some persistence variables
persistence.InitDB(params.RqliteURI)
// set some persistence variables
persistence.InitDB(params.RqliteURI)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
if err := store.GetStore().WaitForReady(ctx); err != nil {
log.Println("error waiting for ready")
panic(err)
}
cancel()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
if err := store.GetStore().WaitForReady(ctx); err != nil {
log.Println("error waiting for ready")
panic(err)
}
cancel()

// check if we need to migrate from postgres before doing anything else
if !util.IsHelmManaged() {
if err := persistence.MigrateFromPostgresToRqlite(); err != nil {
log.Println("error migrating from postgres to rqlite")
panic(err)
}
if err := persistence.MigrateFromPostgresToRqlite(); err != nil {
log.Println("error migrating from postgres to rqlite")
panic(err)
}

if err := bootstrap(BootstrapParams{
Expand All @@ -71,11 +66,9 @@ func Start(params *APIServerParams) {
panic(err)
}

if !util.IsHelmManaged() {
store.GetStore().RunMigrations()
if err := identitymigrate.RunMigrations(context.TODO(), util.PodNamespace); err != nil {
log.Println("Failed to run identity migrations: ", err)
}
store.GetStore().RunMigrations()
if err := identitymigrate.RunMigrations(context.TODO(), util.PodNamespace); err != nil {
log.Println("Failed to run identity migrations: ", err)
}

if err := binaries.InitKubectl(); err != nil {
Expand All @@ -88,28 +81,27 @@ func Start(params *APIServerParams) {
panic(err)
}

if !util.IsHelmManaged() {
client := &client.Client{
TargetNamespace: util.AppNamespace(),
ExistingHookInformers: map[string]bool{},
HookStopChans: []chan struct{}{},
}
store := store.GetStore()
k8sClientset, err := k8sutil.GetClientset()
if err != nil {
log.Println("error getting k8s clientset")
panic(err)
}
op := operator.Init(client, store, params.AutocreateClusterToken, k8sClientset)
if err := op.Start(); err != nil {
log.Println("error starting the operator")
panic(err)
}
defer op.Shutdown()
kotsStore := store.GetStore()

if err := embeddedcluster.InitClusterState(context.TODO(), k8sClientset, store); err != nil {
log.Println("Failed to initialize cluster state:", err)
}
operatorClient := &operatorclient.Client{
TargetNamespace: util.AppNamespace(),
ExistingHookInformers: map[string]bool{},
HookStopChans: []chan struct{}{},
}
k8sClientset, err := k8sutil.GetClientset()
if err != nil {
log.Println("error getting k8s clientset")
panic(err)
}
op := operator.Init(operatorClient, kotsStore, params.AutocreateClusterToken, k8sClientset)
if err := op.Start(); err != nil {
log.Println("error starting the operator")
panic(err)
}
defer op.Shutdown()

if err := embeddedcluster.InitClusterState(context.TODO(), k8sClientset, kotsStore); err != nil {
log.Println("Failed to initialize cluster state:", err)
}

if params.SharedPassword != "" {
Expand All @@ -136,13 +128,11 @@ func Start(params *APIServerParams) {
log.Println("Failed to start informers:", err)
}

if !util.IsHelmManaged() {
if err := updatechecker.Start(); err != nil {
log.Println("Failed to start update checker:", err)
}
if err := snapshotscheduler.Start(); err != nil {
log.Println("Failed to start snapshot scheduler:", err)
}
if err := updatechecker.Start(); err != nil {
log.Println("Failed to start update checker:", err)
}
if err := snapshotscheduler.Start(); err != nil {
log.Println("Failed to start snapshot scheduler:", err)
}

if err := session.StartSessionPurgeCronJob(); err != nil {
Expand All @@ -159,12 +149,6 @@ func Start(params *APIServerParams) {
}
}

if util.IsHelmManaged() {
if err := helm.Init(context.TODO()); err != nil {
log.Println("Failed to initialize helm data: ", err)
}
}

r := mux.NewRouter()

r.Use(handlers.CorsMiddleware)
Expand All @@ -178,8 +162,6 @@ func Start(params *APIServerParams) {

handler := &handlers.Handler{}

kotsStore := store.GetStore()

/**********************************************************************
* Unauthenticated routes
**********************************************************************/
Expand Down
42 changes: 0 additions & 42 deletions pkg/app/types/helm_app.go

This file was deleted.

8 changes: 0 additions & 8 deletions pkg/app/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@ const (
AutoDeploySemverMajorMinorPatch AutoDeploy = "semver-major-minor-patch"
AutoDeploySequence AutoDeploy = "sequence"
)

type AppType interface {
GetID() string
GetSlug() string
GetCurrentSequence() int64
GetIsAirgap() bool
GetNamespace() string
}
11 changes: 0 additions & 11 deletions pkg/filestore/blob_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/util"
)

var (
Expand All @@ -20,16 +19,6 @@ type BlobStore struct {
}

func (s *BlobStore) Init() error {
if util.IsHelmManaged() {
// Helm managed mode does not have any persisten storage.
dir, err := ioutil.TempDir("", "kotsadmdata-archives-")
if err != nil {
return errors.Wrapf(err, "failed to create ephemeral archives directory")
}
ArchivesDir = dir
return nil
}

err := os.MkdirAll(ArchivesDir, 0755)
if err != nil {
return errors.Wrapf(err, "failed to create archives directory")
Expand Down
Loading

0 comments on commit 394ce64

Please sign in to comment.