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

start publishing tags based on supported os/arch #153

Merged
merged 1 commit into from
Aug 12, 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 command/harness/delegate/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *delegateCommand) run(*kingpin.ParseContext) error {
c.stageOwnerStore = database.NewStageOwnerStore(db)
c.poolManager = drivers.New(ctx, instanceStore, c.env.Settings.LiteEnginePath, c.env.Runner.Name)

err = harness.SetupPool(ctx, &c.env, c.poolManager, c.poolFile)
_, err = harness.SetupPool(ctx, &c.env, c.poolManager, c.poolFile)
if err != nil {
return err
}
Expand Down
16 changes: 13 additions & 3 deletions command/harness/dlite/dlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ func RegisterDlite(app *kingpin.Application) {
StringVar(&c.poolFile)
}

// Iterate over the list of pools and register the tags for the pools it supports
func parseTags(pf *config.PoolFile) []string {
tags := []string{}
for i := range pf.Instances {
t := pf.Instances[i].Platform.OS + "-" + pf.Instances[i].Platform.Arch
Copy link
Contributor

Choose a reason for hiding this comment

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

os is used as darwin instead of macos

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let's keep it for now. We can check with brad whether darwin is a better alternative than mac and update accordingly

Copy link
Contributor

Choose a reason for hiding this comment

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

we can review it when mac os support is added back

tags = append(tags, t)
}
return tags
}

func (c *dliteCommand) startPoller(ctx context.Context, tags []string) error {
r := router.NewRouter(routeMap(c))
// Client to interact with the harness server
Expand Down Expand Up @@ -97,18 +107,18 @@ func (c *dliteCommand) run(*kingpin.ParseContext) error {
c.stageOwnerStore = database.NewStageOwnerStore(db)
c.poolManager = drivers.New(ctx, instanceStore, c.env.Settings.LiteEnginePath, c.env.Runner.Name)

err = harness.SetupPool(ctx, &c.env, c.poolManager, c.poolFile)
poolConfig, err := harness.SetupPool(ctx, &c.env, c.poolManager, c.poolFile)
if err != nil {
return err
}
tags := parseTags(poolConfig)

hook := loghistory.New()
logrus.AddHook(hook)

var g errgroup.Group
g.Go(func() error {
// TODO (Vistaar): Add support for tags based on available pools
err = c.startPoller(ctx, []string{})
err = c.startPoller(ctx, tags)
if err != nil {
logrus.WithError(err).Error("could not start poller")
return err
Expand Down
14 changes: 7 additions & 7 deletions command/harness/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/sirupsen/logrus"
)

func SetupPool(ctx context.Context, env *config.EnvConfig, poolManager *drivers.Manager, poolFile string) error {
func SetupPool(ctx context.Context, env *config.EnvConfig, poolManager *drivers.Manager, poolFile string) (*config.PoolFile, error) {
configPool, confErr := poolfile.ConfigPoolFile(poolFile, env)
if confErr != nil {
logrus.WithError(confErr).Fatalln("Unable to load pool file, or use an in memory pool")
Expand All @@ -19,20 +19,20 @@ func SetupPool(ctx context.Context, env *config.EnvConfig, poolManager *drivers.
pools, err := poolfile.ProcessPool(configPool, env.Runner.Name)
if err != nil {
logrus.WithError(err).Errorln("unable to process pool file")
return err
return configPool, err
}

err = poolManager.Add(pools...)
if err != nil {
logrus.WithError(err).Errorln("unable to add pools")
return err
return configPool, err
}

err = poolManager.PingDriver(ctx)
if err != nil {
logrus.WithError(err).
Errorln("unable to ping driver")
return err
return configPool, err
}

// setup lifetimes of instances
Expand All @@ -42,7 +42,7 @@ func SetupPool(ctx context.Context, env *config.EnvConfig, poolManager *drivers.
if err != nil {
logrus.WithError(err).
Errorln("failed to start instance purger")
return err
return configPool, err
}

// lets remove any old instances.
Expand All @@ -60,10 +60,10 @@ func SetupPool(ctx context.Context, env *config.EnvConfig, poolManager *drivers.
if buildPoolErr != nil {
logrus.WithError(buildPoolErr).
Errorln("unable to build pool")
return buildPoolErr
return configPool, buildPoolErr
}
logrus.Infoln("pool created")
return nil
return configPool, nil
}

func Cleanup(ctx context.Context, env *config.EnvConfig, poolManager *drivers.Manager) error {
Expand Down