Skip to content

Commit

Permalink
RHINENG-9355 RHCID should be used when calling GetConnectionStatus (#157
Browse files Browse the repository at this point in the history
)
  • Loading branch information
r14chandra authored Apr 10, 2024
1 parent d7beac5 commit 33bfc4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/inventoryconsumer/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func handler(ctx context.Context, msg kafka.Message) {
return
}

status, dispatchers, err := client.GetConnectionStatus(ctx, event.Host.OrgID, event.Host.SubscriptionManagerID)
status, dispatchers, err := client.GetConnectionStatus(ctx, event.Host.OrgID, event.Host.SystemProfile.RHCID)
if err != nil {
logger.Error().Err(err).Msg("cannot get connection status from cloud-connector")
return
Expand Down
14 changes: 7 additions & 7 deletions internal/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ 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("org_id", host.OrgID).Str("subscription_manager_id", host.SubscriptionManagerID).Logger()
logger := log.With().Str("org_id", host.OrgID).Str("subscription_manager_id", host.SubscriptionManagerID).Str("rhc_client_id", host.SystemProfile.RHCID).Logger()

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

if host.SubscriptionManagerID == "" {
return "", fmt.Errorf("cannot setup host: missing value for 'subscription_manager_id' field")
if host.SystemProfile.RHCID == "" {
return "", fmt.Errorf("cannot setup host: missing value for 'rhc_client_id' field")
}

client, err := cloudconnector.NewCloudConnectorClient()
Expand All @@ -117,7 +117,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.OrgID, host.SubscriptionManagerID)
status, dispatchers, err = client.GetConnectionStatus(ctx, host.OrgID, host.SystemProfile.RHCID)
if err != nil {
logger.Error().Err(err).Msg("cannot get connection status from cloud-connector")
return "", err
Expand All @@ -136,7 +136,7 @@ func SetupHost(ctx context.Context, host Host) (string, error) {
}

if _, has := dispatchers["package-manager"]; !has {
return "", fmt.Errorf("host %v missing required directive 'package-manager'", host.SubscriptionManagerID)
return "", fmt.Errorf("host %v missing required directive 'package-manager'", host.SystemProfile.RHCID)
}

if _, has := dispatchers["rhc-worker-playbook"]; has {
Expand All @@ -156,7 +156,7 @@ func SetupHost(ctx context.Context, host Host) (string, error) {
return "", fmt.Errorf("cannot marshal payload: %v", err)
}

messageID, err := client.SendMessage(ctx, host.OrgID, "package-manager", data, nil, host.SubscriptionManagerID)
messageID, err := client.SendMessage(ctx, host.OrgID, "package-manager", data, nil, host.SystemProfile.RHCID)
if err != nil {
logger.Error().Err(err).Msg("cannot send message to host")
return "", err
Expand All @@ -168,7 +168,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.OrgID, host.SubscriptionManagerID)
status, dispatchers, err := client.GetConnectionStatus(ctx, host.OrgID, host.SystemProfile.RHCID)
if err != nil {
logger.Error().Err(err).Msg("cannot get connection status from cloud-connector")
return "", err
Expand Down

0 comments on commit 33bfc4d

Please sign in to comment.