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

Refactor get_suse_container_urls using data structure for each distri #13141

Merged
merged 3 commits into from
Sep 15, 2021

Conversation

b10n1k
Copy link
Contributor

@b10n1k b10n1k commented Aug 27, 2021

$dotversion = "${dotversion}.0" if $dotversion !~ /\./; # 15 -> 15.0
my $version = shift // get_required_var('VERSION');
my $arch = shift // get_required_var('ARCH');
my $distri = shift // get_required_var('DISTRI');

my @untested_images = ();
Copy link
Member

Choose a reason for hiding this comment

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

Please also rename to totest so it's consistent.

Copy link
Contributor Author

@b10n1k b10n1k Aug 31, 2021

Choose a reason for hiding this comment

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

untested_images as well as released_images came from a previous team agreement. i dont want to interfere and change them. i think it is messy to change the names frequently. in the other side i think the variable names in the structure are quite good and they do not mess with the already implementation.

Copy link
Member

Choose a reason for hiding this comment

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

I like your totest_ and released_ prefixes. But I'd like to use the same prefixes everywhere.

Maybe another point: I'd rename %registries to %images and released_registry to released_image and totest_registry to totest_image.

Copy link
Member

Choose a reason for hiding this comment

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

@jlausuch @Vogtinator can you help here so we agree on same convention and use it everywhere?

Copy link
Member

@pdostal pdostal Sep 3, 2021

Choose a reason for hiding this comment

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

Ping. I would still be for unifying those names. E.g. released_images and totest_images as in urls.pm.

Copy link
Member

Choose a reason for hiding this comment

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

Let's just not forget about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My objection is that arbitrary change of the variable names or unrelated request of the scope is bad practice. The reason is because usually you trigger side effects and it might cause a chain of reactions+additional checks,VR and etc. Second, you request to rename some variables, unrelated to the scope of this PR, which as for beginning they are not bad ones and the discussion should be in the case the PR have made changes on them. Which it doesnt and a very important reason of it is that there was a PR which reviewed and approved (requester was one of them) after a long talk on the rocket.chat if i remember. i just think is really bad to approve something and someone changed it without a good "reason". this causes more issues and inconsistency in the reviews and waste our time.

tespa. i would like to leave it as it is for the reasons i just mentioned. and you can decide later what its destiny will be :)

Copy link
Contributor Author

@b10n1k b10n1k Sep 9, 2021

Choose a reason for hiding this comment

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

I am in favor of renaming %registries to %images.

this is a definition think that i try to address here. the image name and the image registry is not exactly the same. The image registry is the uri of the image where is stored. When we execute podman run hello-world , the runtime will check the image-name in the registry and then at the docker registry from convention. in both cases it looks on localhost:5000/hello-world and docker.io/hello-world. this is the registry and the hash provides obviously the registry-name rather the image-name. i thought to force this convention as for me it is confusing when we do not use the same terminology.

this change is ready for review

Copy link
Contributor

@jlausuch jlausuch Sep 9, 2021

Choose a reason for hiding this comment

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

Just call it hash :D .
Sorry for the joke, but this is just another "tab or spaces" discussion.. I don't care about the name.

Copy link
Contributor

Choose a reason for hiding this comment

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

My objection is that arbitrary change of the variable names or unrelated request of the scope is bad practice. The reason is because usually you trigger side effects and it might cause a chain of reactions+additional checks,VR and etc. Second, you request to rename some variables, unrelated to the scope of this PR, which as for beginning they are not bad ones and the discussion should be in the case the PR have made changes on them. Which it doesnt and a very important reason of it is that there was a PR which reviewed and approved (requester was one of them) after a long talk on the rocket.chat if i remember. i just think is really bad to approve something and someone changed it without a good "reason". this causes more issues and inconsistency in the reviews and waste our time.

tespa. i would like to leave it as it is for the reasons i just mentioned. and you can decide later what its destiny will be :)

I agree with this, it's not something for this PR as I mentioned.

lib/containers/urls.pm Outdated Show resolved Hide resolved
@pdostal
Copy link
Member

pdostal commented Aug 27, 2021

This so far looks great to me!

@b10n1k b10n1k force-pushed the 97232_containers_urls branch 27 times, most recently from dcd2b30 to c65ae8f Compare August 30, 2021 21:02
Copy link
Member

@Vogtinator Vogtinator left a comment

Choose a reason for hiding this comment

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

"+202 -57", 145 more lines while also being less flexible :-/

Having a hash of subs means that it's not just plain data, but still code, IMO the shorter code was simpler, but that's just my view.

It's no longer possible to distinguish between "not available, skip" (e.g. 15.2 PowerPC) and "not known, abort" (none of the cases match).

The biggest issue IMO however is that it needs manual changes for every new version of SLE or Leap, while currently it handles later version of known distributions automatically.

@Vogtinator
Copy link
Member

It's no longer possible to distinguish between "not available, skip" (e.g. 15.2 PowerPC) and "not known, abort" (none of the cases match).

Actually, that is possible. push @foo, bar(); is a noop if bar doesn't return anything. push @foo, undef; however isn't. Perl is weird.

@jlausuch
Copy link
Contributor

jlausuch commented Sep 9, 2021

"+202 -57", 145 more lines while also being less flexible :-/

Having a hash of subs means that it's not just plain data, but still code, IMO the shorter code was simpler, but that's just my view.

Yes, it's more code but it's also more clear. I am in favor of this format. Maybe, in the future we could put it in json/yaml/xml format in data directory and just read it here, so we don't create so many lines of code with that big hash. Something similar to what we do for journal_check test. But it's fine if that is done later.

michaelgrifalconi and others added 2 commits September 9, 2021 21:07
I have approach this problem organizing the data into a hash. The data
structure can hold information explicitly, so it is more ease to handle.

Each <distri><version> hold three information
- released
- totest
- available_arch

I use anonumous functions for `registries` to provide flexibility. For instance
you can choose the different registry based on aarch. or it is possible to
modify the sub to return an array in the future.

I tried to group some of the versions as they provide commonalities but regular
hash accept scalar as a key.

Signed-off-by: Ioannis Bonatakis <ybonatakis@suse.com>
Copy link
Member

@Vogtinator Vogtinator left a comment

Choose a reason for hiding this comment

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

The biggest issue IMO however is that it needs manual changes for every new version of SLE or Leap, while currently it handles later version of known distributions automatically.

Is still valid

@b10n1k
Copy link
Contributor Author

b10n1k commented Sep 10, 2021

The biggest issue IMO however is that it needs manual changes for every new version of SLE or Leap, while currently it handles later version of known distributions automatically.

Is still valid

Sorry i thought that @jlausuch has answered on that and seems to be in favor of this structure. is this somehow different?

My opinion is that this is a more neat approach because you can "describe" what is your data. there is a trade off with the procedural logic. the writing/reading is getting harder because the decision made by mixing version, distri and arch. the task was to simplify this.

To avoid manual changes we could use this struct a little bit different.

our %registries = (
    sle => {
        '12' => {
            released => sub { 'registry.suse.com/suse/sles12sp3' },
            totest   => sub {
                'registry.suse.de/' . get_sle12($version);
            },
            available_arch => ['x86_64', 'ppc64le', 's390x']
        },
        15' => {
            released => sub { 'registry.suse.com/suse/sle15:15.0' },
            totest   => sub {
                'registry.suse.de/'' . get_sle15($version);
            },
            available_arch => ['x86_64', 'ppc64le', 's390x']
        },
    },
    opensuse => {
        Tumbleweed => {
            released => sub { 'registry.opensuse.org/opensuse/tumbleweed' },
            totest   => sub {
                'registry.opensuse.org/' . get_opensuse_registry_prefix . 'opensuse/tumbleweed';
            },
            available_arch => ['x86_64', 'aarch64', 'ppc64le', 's390x', 'arm']
        },
        'leap => {
            released => sub { 'registry.opensuse.org/opensuse/leap:15.0' },
            totest   => sub {
                'registry.opensuse.org/ . get_leap($version)';
            },
            available_arch => ['x86_64']
        }
       });

or something like that.
So for sure it will be nice to have it, it is possible on my point of view but i think there is time to figure this out.

lib/containers/urls.pm Outdated Show resolved Hide resolved
Copy link
Contributor

@ilausuch ilausuch left a comment

Choose a reason for hiding this comment

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

For me is good, only that I agree to change the registries variable name to images, more clear what contains

@jlausuch
Copy link
Contributor

The biggest issue IMO however is that it needs manual changes for every new version of SLE or Leap, while currently it handles later version of known distributions automatically.

Is still valid

Sorry i thought that @jlausuch has answered on that and seems to be in favor of this structure. is this somehow different?

Yes, I am in favor. If we need to add new releases it won't be a big deal, maybe once or twice a year? For new releases there are actually bigger changes we need to do, adding a few lines here is not that much of a problem.

The only thing against having this hash here is just that it takes too much lines in a .pm module, so I would be also in favor to transform this into json file and parse it here, but this can be done in another PR.

@b10n1k
Copy link
Contributor Author

b10n1k commented Sep 13, 2021

For me is good, only that I agree to change the registries variable name to images, more clear what contains

#13141 (comment). feel free to suggests something different. for instance %images_uri but i still think that registries describes it just fine.

@pdostal
Copy link
Member

pdostal commented Sep 14, 2021

For me is good, only that I agree to change the registries variable name to images, more clear what contains

#13141 (comment). feel free to suggests something different. for instance %images_uri but i still think that registries describes it just fine.

Either %images_uri or just %images work for me. Thx Yianni

@jlausuch
Copy link
Contributor

It seems this is being blocked because of the hash name. Let's just let people vote:
%registries or %images.

I vote for %images

@ilausuch
Copy link
Contributor

I vote for %images, %registries confuses for me

@b10n1k
Copy link
Contributor Author

b10n1k commented Sep 14, 2021

It seems this is being blocked because of the hash name. Let's just let people vote:
%registries or %images.

I vote for %images

are we going to vote for each review conflict? i even proposed another name... and i will add a few here in case you want to pick something from that which will define the hash uniquely

  • %images_uri
  • %images_struct
  • %registry_images
  • %suse_images

Again consider that the hash is not a private variable and it is worth to give a better name than %images

@jlausuch
Copy link
Contributor

* %images_uri
* %images_struct
* %registry_images
* %suse_images

%images_uri +1

`get_suse_container_urls` takes named params now as requested.
With this commit, apply this to the files that has explicit impact,
as they use positional one

Signed-off-by: Ioannis Bonatakis <ybonatakis@suse.com>
@b10n1k
Copy link
Contributor Author

b10n1k commented Sep 14, 2021

* %images_uri
* %images_struct
* %registry_images
* %suse_images

%images_uri +1

First comes First Served?? :) this change is ready for review

@pdostal
Copy link
Member

pdostal commented Sep 15, 2021

The biggest issue IMO however is that it needs manual changes for every new version of SLE or Leap, while currently it handles later version of known distributions automatically.

Is still valid

This is in my opinion out of scope of this PR and also quite complex problem as we test prerelease versions too.

@b10n1k b10n1k merged commit 27644d8 into os-autoinst:master Sep 15, 2021
@b10n1k
Copy link
Contributor Author

b10n1k commented Sep 15, 2021

follow up ticket to address manual changes to the hash https://progress.opensuse.org/issues/98658

@DimStar77
Copy link
Contributor

This seems responsible for the staging failures, like
https://openqa.opensuse.org/tests/1918468#step/podman_image/28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants