Skip to content

Remove deprecated CV/LCE params from ActivationKey and HostGroup - #1419

Merged
sambible merged 3 commits into
SatelliteQE:masterfrom
jeremylenz:remove-deprecated-cv-lce-params
Jun 9, 2026
Merged

sambible merged 3 commits into
SatelliteQE:masterfrom
jeremylenz:remove-deprecated-cv-lce-params

Conversation

@jeremylenz

@jeremylenz jeremylenz commented May 21, 2026 •

Copy link
Copy Markdown
Contributor
Description of changes

Remove the deprecated separate content_view and environment fields from ActivationKey, replacing them with content_view_environment_ids to match the Katello 4.21+ API changes (Fixes #39330).

ActivationKey:

  • Remove content_view (OneToOneField) and environment (OneToOneField) from _fields
  • Add content_view_environment_ids (ListField) for create/update payloads
  • Override read() to populate content_view_environments from the API response
  • Add backward-compat @property for content_view and environment (read-only, extracts from first content view environment)

HostGroup:

  • Add content_view_environment_id (IntegerField) to _fields
  • Update create_payload() and update_payload() to strip legacy content_view_id/lifecycle_environment_id when content_view_environment_id is present
Upstream API documentation, plugin, or feature links

Katello PR: Katello/katello#11753 (branch sat-38100-remove-deprecated-cv-lce-params)
Robottelo PR: SatelliteQE/robottelo#21644

Functional demonstration

Callers update from:

ak = ActivationKey(content_view=cv, environment=lce, organization=org).create()

to:

ak = ActivationKey(content_view_environment_ids=[cvenv_id], organization=org).create()

Read-side backward compat is preserved:

ak = ActivationKey(id=123).read()
ak.content_view.id      # still works via @property
ak.environment.id        # still works via @property
ak.content_view_environments  # new: list of dicts with full CV/LCE data
Additional Information

Companion Robottelo PR will follow with test updates.

🤖 Generated with Claude Code

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In ActivationKey.read, you're mutating the ignore set passed in by the caller (ignore.add(...)); consider creating a new set (e.g., ignore = set(ignore or []) | {'content_view_environment_ids'}) to avoid surprising side effects when callers reuse the same set.
  • The content_view and environment properties assume the nested dicts always contain an 'id' key; it might be safer to use .get('id') and return None when it's missing to avoid a KeyError on malformed or partial API responses.
  • For HostGroup.create_payload/update_payload, you might want to check for a non-None content_view_environment_id rather than just key presence (e.g., if payload.get('content_view_environment_id') is not None:) so that you only strip the legacy IDs when a new CVE value is actually being sent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `ActivationKey.read`, you're mutating the `ignore` set passed in by the caller (`ignore.add(...)`); consider creating a new set (e.g., `ignore = set(ignore or []) | {'content_view_environment_ids'}`) to avoid surprising side effects when callers reuse the same set.
- The `content_view` and `environment` properties assume the nested dicts always contain an `'id'` key; it might be safer to use `.get('id')` and return `None` when it's missing to avoid a `KeyError` on malformed or partial API responses.
- For `HostGroup.create_payload`/`update_payload`, you might want to check for a non-`None` `content_view_environment_id` rather than just key presence (e.g., `if payload.get('content_view_environment_id') is not None:`) so that you only strip the legacy IDs when a new CVE value is actually being sent.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Katello-facing entity models for the newer content view environment API shape, replacing deprecated separate content view / lifecycle environment parameters where applicable.

Changes:

  • Replaces ActivationKey create/update input with content_view_environment_ids.
  • Adds read-side ActivationKey compatibility helpers for content_view and environment.
  • Adds HostGroup content_view_environment_id payload support and removes legacy CV/LCE IDs when it is present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nailgun/entities.py
Comment thread nailgun/entities.py
Comment on lines +4099 to +4101
if 'content_view_environment_id' in payload:
payload.pop('content_view_id', None)
payload.pop('lifecycle_environment_id', None)

@LadislavVasina1 LadislavVasina1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look good to me, but I would like someone with more nailgun "skills" :D to also review.
Also I would merge only after we are close to delivering the Katello changes to the downstream snap.

@LadislavVasina1
LadislavVasina1 requested review from a team and vsedmik May 28, 2026 08:11
@jeremylenz

Copy link
Copy Markdown
Contributor Author

Katello change is merged now.

@vsedmik vsedmik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. The CI-CQ failure seems unrelated (raised #1421 to fix it).

Maybe we could add some unit test(s) for the new properties, just to satisfy the requirements.

synkd
synkd previously approved these changes Jun 2, 2026
@synkd

synkd commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@jeremylenz This looks good, but could you change the instances of cves to cvenvs?

vsedmik
vsedmik previously approved these changes Jun 2, 2026

@vsedmik vsedmik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thank you for the update @jeremylenz!

@jeremylenz
jeremylenz force-pushed the remove-deprecated-cv-lce-params branch from c928319 to dd22844 Compare June 2, 2026 16:57
@sambible
sambible force-pushed the remove-deprecated-cv-lce-params branch from 6b0f708 to 77b11ab Compare June 2, 2026 19:38
sambible
sambible previously approved these changes Jun 2, 2026

@sambible sambible left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK pending fixes for the failing unit tests.

@jeremylenz
jeremylenz force-pushed the remove-deprecated-cv-lce-params branch from 77b11ab to afaf8d6 Compare June 2, 2026 19:42
jeremylenz and others added 2 commits June 2, 2026 15:42
ActivationKey: Replace content_view/environment fields with
content_view_environment_ids for create/update. Add read() override
to populate content_view_environments from the API response, and
backward-compat properties for content_view/environment.

HostGroup: Add content_view_environment_id field. Strip legacy
content_view_id/lifecycle_environment_id from payloads when the
new field is present.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeremylenz

Copy link
Copy Markdown
Contributor Author

latest commit is to fix Robottelo PRT failures.

@jeremylenz
jeremylenz force-pushed the remove-deprecated-cv-lce-params branch 2 times, most recently from 1d2d922 to affbb03 Compare June 2, 2026 19:46
This field is write-only — the API response does not include it,
so read() must skip it to avoid a KeyError.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@jnagare-redhat jnagare-redhat left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@sambible
sambible merged commit 5e3e401 into SatelliteQE:master Jun 9, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No-CherryPick PR doesnt need CherryPick to previous branches PRT-Passed Stream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants