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

Onboarding wizard enhancements #1318

Merged
merged 3 commits into from
Jan 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ function KubernetesAccountDetails({
hasError={isValidationError}
errorMessage={errorMessage}
/>
<LabelledInput
type="text"
id="opencost-base-url"
name="opencostBaseUrl"
value={cloudAccountData?.name}
label="Opencost Base URL"
placeholder="localhost:9003"
/>
</div>
{hasError && (
<div className="text-sm text-red-500">
Expand Down
14 changes: 13 additions & 1 deletion handlers/accounts_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"fmt"
"net/http"
"os"
"time"

"github.com/BurntSushi/toml"
"github.com/gin-gonic/gin"
"github.com/go-co-op/gocron"
log "github.com/sirupsen/logrus"
"github.com/tailwarden/komiser/models"
"github.com/tailwarden/komiser/utils"
Expand Down Expand Up @@ -112,7 +114,17 @@ func (handler *ApiHandler) NewCloudAccountHandler(c *gin.Context) {

accountId, _ := result.LastInsertId()
account.Id = accountId
go fetchResourcesForAccount(c, account, handler.db, []string{})

cron := gocron.NewScheduler(time.UTC)
_, err = cron.Every(1).Hours().Do(func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this be another cron that keeps on running. Lets say a new acc was added and before that the main core cron was already running now with the addition of new clou acc this cron starts too every other hour for same acc. Wont this be redundant

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

main cron doesn't have the acc covered by this one

Copy link
Collaborator

Choose a reason for hiding this comment

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

In case of multiple addition of cloud acc there will be multiple crons running

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's true, for now

Copy link
Collaborator

Choose a reason for hiding this comment

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

sure for time being we can use it but definately we can improve this a lot

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed

log.Info("Fetching resources workflow has started")

fetchResourcesForAccount(c, account, handler.db, []string{})
})
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
}

if handler.telemetry {
Expand Down
2 changes: 1 addition & 1 deletion handlers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func makeClientFromAccount(account models.Account) (*providers.ProviderClient, e

client := providers.K8sClient{
Client: k8sClient,
OpencostBaseUrl: account.Credentials["opencostbaseurl"],
OpencostBaseUrl: account.Credentials["opencostBaseUrl"],
}

return &providers.ProviderClient{
Expand Down
Loading