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

RHINENG-9355 RHCID should be used when calling GetConnectionStatus #157

Merged
merged 1 commit into from
Apr 10, 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
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
Loading