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

COMPOSER-2096: Add blueprint support to cloudapi & local access to cloudapi service #3757

Merged
merged 4 commits into from
Jan 15, 2024

Conversation

bcl
Copy link
Contributor

@bcl bcl commented Oct 24, 2023

The basic idea here is to start by adding blueprint support to cloudapi, the discussion for this can be found here.

This is a really rough poc, but it does actually work, you can submit compose requests to a local socket and it will use the "blueprint" to create it. I only implemented the customizations schema that were the same as a starting point.

Some things to answer:

  • Should blueprint and cloudapi customizations be exclusive and return an error if both are present?
  • If not, how to handle merging them. eg. handling duplicate entries like both trying to setup the same user.
  • Should the cloudapi schema be changed to match the blueprint customization schema?

Schema notes:
Things the same:

  • Kernel
  • SSHKey
  • Timezone
  • Locale
  • Services
  • FDO
  • Ignition
  • Directory

Almost the same (name difference):

  • group vs. groups
  • repositories vs. custom_repositories

Field differences:

  • Users
  • Firewall
  • Filesystem
  • OpenSCAP
  • Files

NOTE: This has no new tests, and CI will most certainly fail. But you can build it with make scratch and submit a sample compose request.

curl -k --unix-socket /run/cloudapi/api.socket --header 'Content-Type: application/json' --data @request-bcl.json  http://localhost/api/image-builder-composer/v2/compose | jq

request-bcl.json:

{
  "blueprint":
{
  "name": "bcl",
  "description": "testing cloudapi",
  "version": "1.0.14",
  "distro": "fedora-39",
  "customizations": {
    "hostname": "minecraft.lan",
    "sshkey": [
      {
        "user": "root",
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoxHT9SxuP8HpESuWZ3jiBK1o3igUVbfskc17/Nq62Iy9mSbPGbPneJI2Z1vtDP6Yo8QFnMXO8HW/f/sOQt9tgQyF0x9Js+fYlNatNsGIGVcWEAncrimYPsciTitPoUzclK7IRIwHQ0cf2MhVyGB+FAZ+28SOcn9p5FAuPEMHgaSVDGXGoT773OofPze0pj+61oXckzNT531QQLfSCmzNITFzZ31cFC+n+uT5mlIZ6VS253BQ0pj1ULFGrP6h1lMTaOffdFmCMwu+lnOSDJoeT/OXloqWF0lqedyVngWICxzG4lEeoXixM4FxWUus9m0vYVG1v+VP8KxpDYKvmEZ3bQ== bcl@lister.home"
      }
    ],
    "timezone": {
      "timezone": "PST8PDT",
      "ntpservers": [
        "time.brianlane.com"
      ]
    }
  },
  "packages": [
    {
      "name": "tmux",
      "version": "*"
    },
    {
      "name": "vim-enhanced"
    }
  ]
},
  "customizations": {
    "filesystem": [{
      "mountpoint": "/opt",
      "min_size": 10485760
    }]
  },
  "distribution": "fedora-39",
  "image_requests": [
    {
      "architecture": "x86_64",
      "image_type": "guest-image",
      "upload_options": {
        "local_save": true
      },
      "repositories":
[
  {
    "name": "fedora",
    "metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-39&arch=x86_64",
    "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGLykg8BEADURjKtgQpQNoluifXia+U3FuqGCTQ1w7iTqx1UvNhLX6tb9Qjy\nl/vjl1iXxucrd2JBnrT/21BdtaABhu2hPy7bpcGEkG8MDinAMZBzcyzHcS/JiGHZ\nd/YmMWQUgbDlApbxFSGWiXMgT0Js5QdcywHI5oiCmV0lkZ+khZ4PkVWmk6uZgYWf\nJOG5wp5TDPnoYXlA4CLb6hu2691aDm9b99XYqEjhbeIzS9bFQrdrQzRMKyzLr8NW\ns8Pq2tgyzu8txlWdBXJyAMKldTPstqtygLL9UUdo7CIQQzWqeDbAnv+WdOmiI/hR\netbbwNV+thkLJz0WD90C2L3JEeUJX5Qa4oPvfNLDeCKmJFEFUTCEdm0AYoQDjLJQ\n3d3q9M09thXO/jYM0cSnJDclssLNsNWfjJAerLadLwNnYRuralw7f74QSLYdJAJU\nSFShBlctWKnlhQ7ehockqtgXtWckkqPZZjGiMXwHde9b9Yyi+VqtUQWxSWny+9g9\n6tcoa3AdnmpqSTHQxYajD0EGXJ0z0NXfqxkI0lo8Uxz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check_gpg": true
  },
  {
    "name": "updates",
    "metalink": "https://mirrors.fedoraproject.org/metalink?repo=updates-released-f39&arch=x86_64",
    "metadata_expire": "6h",
    "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGLykg8BEADURjKtgQpQNoluifXia+U3FuqGCTQ1w7iTqx1UvNhLX6tb9Qjy\nl/vjl1iXxucrd2JBnrT/21BdtaABhu2hPy7bpcGEkG8MDinAMZBzcyzHcS/JiGHZ\nd/YmMWQUgbDlApbxFSGWiXMgT0Js5QdcywHI5oiCmV0lkZ+khZ4PkVWmk6uZgYWf\nJOG5wp5TDPnoYXlA4CLb6hu2691aDm9b99XYqEjhbeIzS9bFQrdrQzRMKyzLr8NW\ns8Pq2tgyzu8txlWdBXJyAMKldTPstqtygLL9UUdo7CIQQzWqeDbAnv+WdOmiI/hR\netbbwNV+thkLJz0WD90C2L3JEeUJX5Qa4oPvfNLDeCKmJFEFUTCEdm0AYoQDjLJQ\n3d3q9M09thXO/jYM0cSnJDclssLNsNWfjJAerLadLwNnYRuralw7f74QSLYdJAJU\nSFShBlctWKnlhQ7ehockqtgXtWckkqPZZjGiMXwHde9b9Yyi+VqtUQWxSWny+9g9\n6tcoa3AdnmpqSTHQxYajD0EGXJ0z0NXfqxkI0lo8UxzypEBy4sARZ4XhTU73Zwk0\nLGhEUHlfyxXgRs6RRvM2UIoo+gou2M9rn/RWkhuHJNSfgrM0BmIBCjhjwGiS33Qh\nysLDWJMdch8lsu1fTmLEFQrOB93oieOJQ0Ysi5gQY8TOT+oZvVi9pSMJuwARAQAB\ntDFGZWRvcmEgKDM5KSA8ZmVkb3JhLTM5LXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQJOBBMBCAA4FiEE6PI5lvIyGGQMtEy+dc9axBi450wFAmLykg8CGw8FCwkI\nBwIGFQoJCAsCBBYCAwECHgECF4AACgkQdc9axBi450yd4w//ZtghbZX5KFstOdBS\nrcbBfCK9zmRvzeejzGl6lPKfqwx7OOHYxFlRa9MYLl8QG7Aq6yRRWzzEHiSb0wJw\nWXz5tbkAmV/fpS4wnb3FDArD44u317UAnaU+UlhgK1g62lwI2dGpvTSvohMBMeBY\nB5aBd+sLi3UtiSRM2XhxvxaWwr/oFLjKDukgrPQzeV3F/XdxGhSz/GZUVFVprcrB\nh/dIo4k0Za7YVRhlVM0coOIcKbcjxAK9CCZ8+jtdIh3/BN5zJ0RFMgqSsrWYWeft\nBI3KWLbyMfRwEtp7xSi17WXbRfsSoqwIVgP+RCSaAdVuiYs/GCRsT3ydYcDvutuJ\nYZoE53yczemM/1HZZFI04zI7KBsKm9NFH0o4K2nBWuowBm59iFvWHFpX6em54cq4\n45NwY01FkSQUqntfqCWFSowwFHAZM4gblOikq2B5zHoIntCiJlPGuaJiVSw9ZpEc\n+IEQfmXJjKGSkMbU9tmNfLR9skVQJizMTtoUQ12DWC+14anxnnR2hxnhUDAabV6y\nJ5dGeb/ArmxQj3IMrajdNwjuk9GMeMSSS2EMY8ryOuYwRbFhBOLhGAnmM5OOSUxv\nA4ipWraXDW0bK/wXI7yHMkc6WYrdV3SIXEqJBTp7npimv3JC+exWEbTLcgvV70FP\nX55M9nDtzUSayJuEcfFP2c9KQCE=\n=J4qZ\n-----END PGP PUBLIC KEY BLOCK-----",
    "check_gpg": true
  },
  {
    "name": "fedora-modular",
    "metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-modular-39&arch=x86_64",
    "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGLykg8BEADURjKtgQpQNoluifXia+U3FuqGCTQ1w7iTqx1UvNhLX6tb9Qjy\nl/vjl1iXxucrd2JBnrT/21BdtaABhu2hPy7bpcGEkG8MDinAMZBzcyzHcS/JiGHZ\nd/YmMWQUgbDlApbxFSGWiXMgT0Js5QdcywHI5oiCmV0lkZ+khZ4PkVWmk6uZgYWf\nJOG5wp5TDPnoYXlA4CLb6hu2691aDm9b99XYqEjhbeIzS9bFQrdrQzRMKyzLr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SowwFHAZM4gblOikq2B5zHoIntCiJlPGuaJiVSw9ZpEc\n+IEQfmXJjKGSkMbU9tmNfLR9skVQJizMTtoUQ12DWC+14anxnnR2hxnhUDAabV6y\nJ5dGeb/ArmxQj3IMrajdNwjuk9GMeMSSS2EMY8ryOuYwRbFhBOLhGAnmM5OOSUxv\nA4ipWraXDW0bK/wXI7yHMkc6WYrdV3SIXEqJBTp7npimv3JC+exWEbTLcgvV70FP\nX55M9nDtzUSayJuEcfFP2c9KQCE=\n=J4qZ\n-----END PGP PUBLIC KEY BLOCK-----",
    "check_gpg": true
  },
  {
    "name": "updates-modular",
    "metalink": "https://mirrors.fedoraproject.org/metalink?repo=updates-released-modular-f39&arch=x86_64",
    "metadata_expire": "6h",
    "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGLykg8BEADURjKtgQpQNoluifXia+U3FuqGCTQ1w7iTqx1UvNhLX6tb9Qjy\nl/vjl1iXxucrd2JBnrT/21BdtaABhu2hPy7bpcGEkG8MDinAMZBzcyzHcS/JiGHZ\nd/YmMWQUgbDlApbxFSGWiXMgT0Js5QdcywHI5oiCmV0lkZ+khZ4PkVWmk6uZgYWf\nJOG5wp5TDPnoYXlA4CLb6hu2691aDm9b99XYqEjhbeIzS9bFQrdrQzRMKyzLr8NW\ns8Pq2tgyzu8txlWdBXJyAMKldTPstqtygLL9UUdo7CIQQzWqeDbAnv+WdOmiI/hR\netbbwNV+thkLJz0WD90C2L3JEeUJX5Qa4oPvfNLDeCKmJFEFUTCEdm0AYoQDjLJQ\n3d3q9M09thXO/jYM0cSnJDclssLNsNWfjJAerLadLwNnYRuralw7f74QSLYdJAJU\nSFShBlctWKnlhQ7ehockqtgXtWckkqPZZjGiMXwHde9b9Yyi+VqtUQWxSWny+9g9\n6tcoa3AdnmpqSTHQxYajD0EGXJ0z0NXfqxkI0lo8UxzypEBy4sARZ4XhTU73Zwk0\nLGhEUHlfyxXgRs6RRvM2UIoo+gou2M9rn/RWkhuHJNSfgrM0BmIBCjhjwGiS33Qh\nysLDWJMdch8lsu1fTmLEFQrOB93oieOJQ0Ysi5gQY8TOT+oZvVi9pSMJuwARAQAB\ntDFGZWRvcmEgKDM5KSA8ZmVkb3JhLTM5LXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQJOBBMBCAA4FiEE6PI5lvIyGGQMtEy+dc9axBi450wFAmLykg8CGw8FCwkI\nBwIGFQoJCAsCBBYCAwECHgECF4AACgkQdc9axBi450yd4w//ZtghbZX5KFstOdBS\nrcbBfCK9zmRvzeejzGl6lPKfqwx7OOHYxFlRa9MYLl8QG7Aq6yRRWzzEHiSb0wJw\nWXz5tbkAmV/fpS4wnb3FDArD44u317UAnaU+UlhgK1g62lwI2dGpvTSvohMBMeBY\nB5aBd+sLi3UtiSRM2XhxvxaWwr/oFLjKDukgrPQzeV3F/XdxGhSz/GZUVFVprcrB\nh/dIo4k0Za7YVRhlVM0coOIcKbcjxAK9CCZ8+jtdIh3/BN5zJ0RFMgqSsrWYWeft\nBI3KWLbyMfRwEtp7xSi17WXbRfsSoqwIVgP+RCSaAdVuiYs/GCRsT3ydYcDvutuJ\nYZoE53yczemM/1HZZFI04zI7KBsKm9NFH0o4K2nBWuowBm59iFvWHFpX6em54cq4\n45NwY01FkSQUqntfqCWFSowwFHAZM4gblOikq2B5zHoIntCiJlPGuaJiVSw9ZpEc\n+IEQfmXJjKGSkMbU9tmNfLR9skVQJizMTtoUQ12DWC+14anxnnR2hxnhUDAabV6y\nJ5dGeb/ArmxQj3IMrajdNwjuk9GMeMSSS2EMY8ryOuYwRbFhBOLhGAnmM5OOSUxv\nA4ipWraXDW0bK/wXI7yHMkc6WYrdV3SIXEqJBTp7npimv3JC+exWEbTLcgvV70FP\nX55M9nDtzUSayJuEcfFP2c9KQCE=\n=J4qZ\n-----END PGP PUBLIC KEY BLOCK-----",
    "check_gpg": true
  }
]
    }]
}

@bcl bcl added the WIP Work in progress. Don't run Gitlab CI. label Oct 24, 2023
@ondrejbudai
Copy link
Member

When discussing this with @supakeen and @achilleas-k, I've also had the idea of making the conversion a separate route. The flow would be basically:

weldr-client calls POST /blueprints/convert with the weldr blueprint in the request, and gets the cloud API compose request as a response
weldr-clients create a new compose using the request it got in the previous call

I guess that a small advantage is that the main compose route doesn't get more cluttered, and we don't have to think what has a precedence (one of your comments in the current PR) - if the new blueprint structure, or the old stuff.

cc @croissanne

@ondrejbudai
Copy link
Member

Forgot to mention: I'm excited to see this being worked on! Thanks, Brian! 🎆

@achilleas-k achilleas-k self-requested a review October 24, 2023 17:43
@bcl
Copy link
Contributor Author

bcl commented Oct 24, 2023

I've also had the idea of making the conversion a separate route.

That's certainly a possibility, but I think it makes things harder. I really don't see any reason for an extra round-trip of the data, which may also grow considerably in size if we start adding files. If you've sent the data, and it has been consumed by the service, it may as well take action and start the compose.

Another alternative is to add another compose endpoint that only takes the full blueprint, and none of the current customizations. I'd prefer that to a 'convert' stage. Especially since, as you can see, on the inside it really is using a blueprint.
But one drawback to that is it will mean more changes to image-builder. With the current layout of this poc the image-builder created customizations don't need to be changed, and a blueprint can be easily added to it as long as things don't conflict. Or we could just return an error if both exist.

@supakeen
Copy link
Member

I've also had the idea of making the conversion a separate route.

That's certainly a possibility, but I think it makes things harder. I really don't see any reason for an extra round-trip of the data, which may also grow considerably in size if we start adding files. If you've sent the data, and it has been consumed by the service, it may as well take action and start the compose.

Another alternative is to add another compose endpoint that only takes the full blueprint, and none of the current customizations. I'd prefer that to a 'convert' stage. Especially since, as you can see, on the inside it really is using a blueprint. But one drawback to that is it will mean more changes to image-builder. With the current layout of this poc the image-builder created customizations don't need to be changed, and a blueprint can be easily added to it as long as things don't conflict. Or we could just return an error if both exist.

We've spoken about this a bit in the discussion as well but a separate route adds more benefits as it can also be used as a separate linting/checking route and allows (some) shell scripts to get the composerequest separately, store it, and send it out later (something we do in Koji) though they could also 'just submit the blueprint' of course.

The files discussion is indeed another can of worms that's going to greatly increase round-trip times.

@croissanne
Copy link
Member

Rebased to prevent OCI private key leaking. Apologies :(

@bcl bcl removed the WIP Work in progress. Don't run Gitlab CI. label Nov 28, 2023
@bcl bcl changed the title A draft proof-of-concept for converging cloudapi and weldr api Add blueprint support to cloudapi & local access to cloudapi service Nov 28, 2023
@bcl bcl marked this pull request as ready for review November 28, 2023 22:33
@bcl
Copy link
Contributor Author

bcl commented Nov 28, 2023

I went ahead and made the customizations and blueprints sections mutually exclusive. It will return an error if you try to use both. I think that we should deprecate customizations and move to using the blueprint section for future features. I've also turned on the local listener for cloudapi under /run/cloudapi/api.socket, which doesn't require the hassle of key setup and is protected by the usual filesystem permissions in the same way that the weldr socket is (you have to be a member of the weldr group).

As I see it the goals are to converge on one API, and to maintain support for existing and future blueprints, which this accomplishes. It should be straightforward to add support for this to composer-cli, either with new commands or by detecting support for it by checking for the socket. The biggest change will likely be image-builder, but even that shouldn't be too bad -- customizations is similar enough to the blueprint that it is almost a 1:1 translation.

@ochosi ochosi changed the title Add blueprint support to cloudapi & local access to cloudapi service COMPOSER-2096: Add blueprint support to cloudapi & local access to cloudapi service Dec 7, 2023
@croissanne croissanne self-requested a review December 7, 2023 15:41
Copy link
Member

@croissanne croissanne left a comment

Choose a reason for hiding this comment

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

I'm really sorry for the late review.

Added 2 comments, but in general I wonder if we can't repurpose the current objects as much as possible in the new blueprint. Even if they require slight tweaks (listening to both "item: []" and "items: []", i think the singular/plural field for arrays is a common difference).

internal/cloudapi/v2/openapi.v2.yml Show resolved Hide resolved
internal/cloudapi/v2/openapi.v2.yml Show resolved Hide resolved
@bcl
Copy link
Contributor Author

bcl commented Dec 18, 2023

We could do those things, but then we'd lose strict checking of the blueprint in OpenAPI. I think it's better to keep it matching the actual blueprint schema so that we have easy validation of the json as soon as possible.

@achilleas-k
Copy link
Member

We could do those things, but then we'd lose strict checking of the blueprint in OpenAPI. I think it's better to keep it matching the actual blueprint schema so that we have easy validation of the json as soon as possible.

I'd generally agree with this but I can imagine it being frustrating for users of the API to have objects with slightly different keys but are otherwise identical. Maybe this is fine for the API in composer since only our own projects talk to it realistically though.

@bcl
Copy link
Contributor Author

bcl commented Jan 10, 2024

I can imagine it being frustrating for users of the API to have objects with slightly different keys

True, but the goal is to eventually get rid of the others and have a single API so there should eventually be no confusion :)

Add a local socket for communicating with the cloudapi. It is started by
osbuild-composer.socket and is located at /run/cloudapi/api.socket

cloudapi requests can be passed to it using curl like this:

curl -k --unix-socket /run/cloudapi/api.socket --header 'Content-Type: application/json' \
--data request.json http://localhost/api/image-builder-composer/v2/compose

A simple request.json looks like this:

{
  "distribution": "fedora-38",
  "image_request":
    {
      "architecture": "x86_64",
      "image_type": "guest-image",
      "upload_options": {},
      "repositories": [
          {
            "name": "fedora",
            "metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-38&arch=x86_64",
            "check_gpg": false
          },
          {
            "name": "updates",
            "metalink": "https://mirrors.fedoraproject.org/metalink?repo=updates-released-f38&arch=x86_64",
            "check_gpg": false
          }
      ]
    }
}
This adds a 'blueprint' section to the compose request. It also
restricts it so that only 'blueprint' or 'customizations' can be
included, but not both. The goal is to move to using 'blueprint' for all
customizations so that there is a single consistent interface for the
clients.

Where the openapi schemas are the same between the two they have been
shared, but a few are different. They are created with 'Blueprint*' as
their name.

This also re-adds the SSHKey schema removed by commit
bfad6d5, it is used by the Blueprint
Customization.
If the request includes a blueprint (and not customizations) it uses
that blueprint for the compose.
This tests to make sure the blueprint produced by the customizations
data and the blueprint data are identical.
Copy link
Member

@croissanne croissanne left a comment

Choose a reason for hiding this comment

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

Ok let's keep them separate for now. We can always merge objects later where possible, and there's always v3.

@croissanne croissanne merged commit e287138 into osbuild:main Jan 15, 2024
69 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants