Skip to content

Commit

Permalink
use OrgID and not account when dispatching hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
thearifismail committed Feb 8, 2024
1 parent 5187258 commit c789ee5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// Host represents a system record from the Inventory application.
type Host struct {
ID string `json:"id"`
Account string `json:"account"`
// Account string `json:"account"`
OrgID string `json:"org_id"`
DisplayName string `json:"display_name"`
Reporter string `json:"reporter"`
Expand Down Expand Up @@ -55,7 +55,7 @@ func ApplyProfile(ctx context.Context, profile *db.Profile, hosts []Host, fn fun
logger.Debug().Str("client_id", host.SystemProfile.RHCID).Msg("creating run for host")
run := dispatcher.RunInput{
Recipient: host.SystemProfile.RHCID,
Account: db.JSONNullStringSafeValue(profile.AccountID),
OrgID: db.JSONNullStringSafeValue(profile.OrgID),

Check failure on line 58 in internal/host.go

View workflow job for this annotation

GitHub Actions / Build (1.17)

unknown field 'OrgID' in struct literal of type dispatcher.RunInput
Url: config.DefaultConfig.PlaybookHost.String() + fmt.Sprintf(config.DefaultConfig.PlaybookPath, profile.ID),
Labels: &dispatcher.RunInput_Labels{
AdditionalProperties: map[string]string{
Expand Down Expand Up @@ -89,10 +89,10 @@ func ApplyProfile(ctx context.Context, profile *db.Profile, hosts []Host, fn fun
// rhc-worker-playbook RPM, enabling the host to receive and execute playbooks
// sent through playbook-dispatcher.
func SetupHost(ctx context.Context, host Host) (string, error) {
logger := log.With().Str("account_id", host.Account).Str("subscription_manager_id", host.SubscriptionManagerID).Logger()
logger := log.With().Str("org_id", host.OrgID).Str("subscription_manager_id", host.SubscriptionManagerID).Logger()

if host.Account == "" {
return "", fmt.Errorf("cannot setup host: missing value for 'account' field")
if host.OrgID == "" {
return "", fmt.Errorf("cannot setup host: missing value for 'OrgID' field")
}

if host.SubscriptionManagerID == "" {
Expand All @@ -113,7 +113,7 @@ func SetupHost(ctx context.Context, host Host) (string, error) {
return "", fmt.Errorf("cannot get connected status after %v, aborting", time.Since(started))
}

status, dispatchers, err = client.GetConnectionStatus(ctx, host.Account, host.SubscriptionManagerID)
status, dispatchers, err = client.GetConnectionStatus(ctx, host.OrgID, host.SubscriptionManagerID)
if err != nil {
logger.Error().Err(err).Msg("cannot get connection status from cloud-connector")
return "", err
Expand Down Expand Up @@ -152,7 +152,7 @@ func SetupHost(ctx context.Context, host Host) (string, error) {
return "", fmt.Errorf("cannot marshal payload: %v", err)
}

messageID, err := client.SendMessage(ctx, host.Account, "package-manager", data, nil, host.SubscriptionManagerID)
messageID, err := client.SendMessage(ctx, host.OrgID, "package-manager", data, nil, host.SubscriptionManagerID)
if err != nil {
logger.Error().Err(err).Msg("cannot send message to host")
return "", err
Expand All @@ -164,7 +164,7 @@ func SetupHost(ctx context.Context, host Host) (string, error) {
if time.Now().After(started.Add(180 * time.Second)) {
return "", fmt.Errorf("unable to detect rhc-worker-playbook after %v, aborting", time.Since(started))
}
status, dispatchers, err := client.GetConnectionStatus(ctx, host.Account, host.SubscriptionManagerID)
status, dispatchers, err := client.GetConnectionStatus(ctx, host.OrgID, host.SubscriptionManagerID)
if err != nil {
logger.Error().Err(err).Msg("cannot get connection status from cloud-connector")
return "", err
Expand Down

0 comments on commit c789ee5

Please sign in to comment.