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

add debug logging for the kotsadm startup process #5019

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions pkg/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
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/logger"
"github.com/replicatedhq/kots/pkg/operator"
operatorclient "github.com/replicatedhq/kots/pkg/operator/client"
"github.com/replicatedhq/kots/pkg/persistence"
Expand Down Expand Up @@ -49,36 +50,45 @@ func Start(params *APIServerParams) {
panic(err)
}
cancel()
logger.Debug("store is ready")

// check if we need to migrate from postgres before doing anything else
if err := persistence.MigrateFromPostgresToRqlite(); err != nil {
log.Println("error migrating from postgres to rqlite")
panic(err)
}
logger.Debug("postgres is migrated to rqlite or the migration was not required")

if err := bootstrap(BootstrapParams{
AutoCreateClusterToken: params.AutocreateClusterToken,
}); err != nil {
log.Println("error bootstrapping")
panic(err)
}
logger.Debug("bootstrap completed")

store.GetStore().RunMigrations()
logger.Debug("store migrations completed")

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

if err := binaries.InitKubectl(); err != nil {
log.Println("error initializing kubectl binaries package")
panic(err)
}
logger.Debug("kubectl binaries are initialized")

if err := binaries.InitKustomize(); err != nil {
log.Println("error initializing kustomize binaries package")
panic(err)
}
logger.Debug("kustomize binaries are initialized")

kotsStore := store.GetStore()
logger.Debug("kotsstore is initialized")

operatorClient := &operatorclient.Client{
TargetNamespace: util.AppNamespace(),
Expand All @@ -90,12 +100,15 @@ func Start(params *APIServerParams) {
log.Println("error getting k8s clientset")
panic(err)
}
logger.Debug("k8s clientset is initialized")

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()
logger.Debug("operator is initialized")

if params.SharedPassword != "" {
// TODO: this won't override the password in the database
Expand All @@ -110,31 +123,40 @@ func Start(params *APIServerParams) {
if err := k8sutil.InitHelmCapabilities(); err != nil {
panic(err)
}
logger.Debug("helm capabilities are initialized")

if err := update.InitAvailableUpdatesDir(); err != nil {
panic(err)
}
logger.Debug("available updates dir is initialized")

if err := reporting.Init(); err != nil {
log.Println("failed to initialize reporting:", err)
}
logger.Debug("reporting is initialized")

supportbundle.StartServer()
logger.Debug("support bundle server is started")

if err := informers.Start(); err != nil {
log.Println("Failed to start informers:", err)
}
logger.Debug("informers are started")

if err := updatechecker.Start(); err != nil {
log.Println("Failed to start update checker:", err)
}
logger.Debug("update checker is started")

if err := snapshotscheduler.Start(); err != nil {
log.Println("Failed to start snapshot scheduler:", err)
}
logger.Debug("snapshot scheduler is started")

if err := session.StartSessionPurgeCronJob(); err != nil {
log.Println("Failed to start session purge cron job:", err)
}
logger.Debug("session purge cron job is started")

waitForAirgap, err := automation.NeedToWaitForAirgapApp()
if err != nil {
Expand All @@ -145,6 +167,7 @@ func Start(params *APIServerParams) {
log.Println("Failed to run automated installs:", err)
}
}
logger.Debug("automated airgap installs are completed")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would be confused if i saw this in an online install

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Debug("automated airgap installs are completed")
logger.Debug("automated airgap installs are completed if requested")


r := mux.NewRouter()

Expand Down
3 changes: 2 additions & 1 deletion pkg/filestore/s3_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *S3Store) WaitForReady(ctx context.Context) error {

period := 1 * time.Second // TOOD: backoff
for {
_, err := s3Client.HeadBucket(&s3.HeadBucketInput{
_, err := s3Client.HeadBucketWithContext(ctx, &s3.HeadBucketInput{
Bucket: aws.String(os.Getenv("S3_BUCKET_NAME")),
})
if err == nil {
Expand All @@ -95,6 +95,7 @@ func (s *S3Store) WaitForReady(ctx context.Context) error {

select {
case <-time.After(period):
logger.Debug("waiting for object store to be ready")
continue
case <-ctx.Done():
return errors.Errorf("failed to find valid object store: %s, last error: %s", ctx.Err(), err)
Expand Down
1 change: 1 addition & 0 deletions pkg/store/kotsstore/kots_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func waitForRqlite(ctx context.Context) error {

select {
case <-time.After(period):
logger.Debug("waiting for database to be ready")
continue
case <-ctx.Done():
if rows.Err != nil {
Expand Down
Loading