-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add Support for ULN Remote in Pulp RPM #486
Conversation
ab9f01f
to
a8c354d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add tests for this?
Also, we need a changelog snippet (can point to this PR instead of an issue). |
cc3cf09
to
44851c5
Compare
pulpcore/cli/rpm/context.py
Outdated
ENTITIES = _("uln remotes") | ||
HREF = "rpm_uln_remote_href" | ||
ID_PREFIX = "remotes_rpm_uln" | ||
NULLABLES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to extend the set of the base class here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extended the RPm Remote base class and fixed Nullables as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sorry i didn't express this properly. We can still safely inherit from PulpRemoteContext
, while we would define NULLABLES = PulpRemoteContext.NULLABLES + {"uln_server-base_url"}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the question is, can we have nullable "uln_server-base_url"
? In settings we set to default value and although its not a required field but we cannot set it to Null. Or am I understanding Nullables
wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that i don't know. NULLABLES
is basically to translate the empty string provided if you specify --opt ""
to None
for submitting to the api.
Whether uln_server_base_url
can be "unset" is a question for someone else. If it is not, i'd say maybe you don't need to redefine NULLABLES
at all...
Also think about the update command. Maybe you need to provide a version of that option without default, or it will unintentionally be overwritten.
0f2df16
to
4b9c60c
Compare
0026107
to
943cdf7
Compare
943cdf7
to
abf0139
Compare
You still need to spec |
@ggainey can i kindly ask you to review this work for rpm-ness? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! If we can get the requested changes to the test, I think we're good to go.
1a2e128
to
c245bf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found one issue while trying to locally test these changes, which is that the --remote
option will not accept a ULN remote for either syncing an RPM repo, or for associating a RPM repo with a ULN remote. My test workflow goes as follows:
ENTITIES_NAME='test'
REMOTE_OPTIONS='--url=uln://ovm2_2.1.1_i386_patch --username=redacted --password=redacted'
pulp rpm remote --type=uln create --name=${ENTITIES_NAME} ${REMOTE_OPTIONS}
pulp rpm repository create --name=${ENTITIES_NAME} --remote=${ENTITIES_NAME}
or
pulp rpm repository create --name=${ENTITIES_NAME}
pulp rpm repository sync --name=${ENTITIES_NAME} --remote=${ENTITIES_NAME}
Both these workflows result in the following error:
Error: Could not find rpm remote with {'name': 'test'}.
Another less serious issue, is if we should provide some help text, for the various --url
options used by the subcommands of ULN remote? Right now it is:
$ pulp rpm remote --type=uln create --help
Usage: pulp rpm remote create [OPTIONS]
Create a uln remote.
Options:
--name TEXT [required]
--url TEXT [required]
But since for ULN remotes --url
requires the ULN channel name e.g.: uln://ovm2_2.1.1_i386_patch
(which is not very intuitive) some help text like the following would be great:
--url TEXT [required] Use the ULN channel name starting with uln:// here.
Alternatively (perhaps even better), the CLI might check that any user supplied --url
parameters start with uln://
for ULN remotes.
I think, what you need to use is
I'd say, let's go for both document and validate. |
c245bf7
to
21dbead
Compare
pulpcore/cli/rpm/remote.py
Outdated
allowed_with_contexts=(PulpUlnRemoteContext,), | ||
), | ||
pulp_option( | ||
"--url", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the check for uln url
as well as help_text. The only problem here now is we have two url
options/fields in --help
of uln remote. Is there a way to remove the base class url option?
Options:
--name TEXT [required]
--url TEXT [required]
--ca-cert TEXT a PEM encoded CA certificate or @file
containing same
.
.
.
--policy [immediate|on_demand|streamed]
--uln-server-base-url TEXT ULN Server base URL, default is
'https://linux-update.oracle.com/'
--url TEXT Use the ULN channel name starting with
uln:// here. [required]
--help Show this message and exit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the other --url
option comes via the common_remote_{create,update}_options
which are plain lists.
So maybe we can create a filtered copy of these [option for option in ... if option.name != "url"]
, and then add one --url
option for the RpmRemoteContext
and one for the UlnRemoteContext
.
@gerrod3 may know whether they turn up correctly in the corresponding help outputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The common_remote_{create,update}_options
are lists of decorators that come from click
so they don't have argument name
or at least callable arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then maybe it it impossible to use that shortcut here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So where do you suggest to add this condition? Adding it to the base class doesn't look like a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's not so much a condition. I think we need to specify the used parameters explicitly here. Not particularly happy about this, but probably the only way to get this forward now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean to remove generic common_remote_{create/update}_options
options and define them explicitly in remote.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the way forward i can see today. And i know it's bad for consistency.
pulpcore/cli/rpm/remote.py
Outdated
allowed_with_contexts=(PulpUlnRemoteContext,), | ||
), | ||
pulp_option( | ||
"--url", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the other --url
option comes via the common_remote_{create,update}_options
which are plain lists.
So maybe we can create a filtered copy of these [option for option in ... if option.name != "url"]
, and then add one --url
option for the RpmRemoteContext
and one for the UlnRemoteContext
.
@gerrod3 may know whether they turn up correctly in the corresponding help outputs.
pulpcore/cli/rpm/remote.py
Outdated
|
||
translation = get_translation(__name__) | ||
_ = translation.gettext | ||
|
||
def _url_callback(ctx: click.Context, param: click.Parameter, value: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be named _uln_channel_callback
or _uln_url_callback
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest _uln_url_callback
as the callback is for url
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed name from _url_callback
to _uln_url_callback
.
21dbead
to
5205520
Compare
5205520
to
4fb0fe6
Compare
pulpcore/cli/rpm/remote.py
Outdated
click.option("--sock-read-timeout", type=float), | ||
click.option("--tls-validation", type=bool), | ||
click.option("--total-timeout", type=float), | ||
click.option("--username"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you can merge the rpm_remote_options
into these two lists with the proper values of required
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options list will be repetitive. I can instead create list of unique
remote_create_options
, remote_update_options
, and another list which have common options for create/update
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the options list.
4fb0fe6
to
27038b7
Compare
pulpcore/cli/rpm/remote.py
Outdated
pulp_option( | ||
"--uln-server-base-url", | ||
default="https://linux-update.oracle.com/", | ||
help=_("ULN Server base URL, default is 'https://linux-update.oracle.com/'"), | ||
allowed_with_contexts=(PulpUlnRemoteContext,), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, this needs to be split for create and update, because providing a default with update will always set this value, and you don't want that in the update call on an existing customized remote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the changes.
27038b7
to
a535caf
Compare
a535caf
to
b7a4b09
Compare
Fixed the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was now able to fully verify the functionality (using this branch rebased to the latest pulp-cli main branch) using the following workflow:
Requires adding "sha1" to the allowed checksums in /etc/pulp/settings.py:
ALLOWED_CONTENT_CHECKSUMS = ["sha224", "sha256", "sha384", "sha512", "sha1"]
pstop
pulpcore-manager handle-artifact-checksums
pstart
ENTITIES_NAME='test'
REMOTE_OPTIONS='--url=uln://ovm2_2.1.1_i386_patch --username=redacted --password=redacted'
pulp rpm remote --type=uln create --name=${ENTITIES_NAME} ${REMOTE_OPTIONS}
pulp rpm repository create --name=${ENTITIES_NAME} --remote=uln:${ENTITIES_NAME}
pulp rpm repository sync --name=${ENTITIES_NAME}
RPM_PUBLICATION_HREF=$(pulp rpm publication create --repository=${ENTITIES_NAME} | jq -r '.pulp_href')
pulp rpm distribution create --name=${ENTITIES_NAME} --base-path=${ENTITIES_NAME} --publication=${RPM_PUBLICATION_HREF}
I also checked that the CLI now throws an error if the --url
parameter does not start with uln://
.
The --help
option now also contains more explanations, thanks!
From a usage point of view this looks good to go to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great - thanks for all the work Manisha!
No description provided.