Skip to content

Get gophercloud system wide client#284

Merged
stuggi merged 1 commit intoopenstack-k8s-operators:mainfrom
fmount:scope
Jun 13, 2023
Merged

Get gophercloud system wide client#284
stuggi merged 1 commit intoopenstack-k8s-operators:mainfrom
fmount:scope

Conversation

@fmount
Copy link
Copy Markdown
Contributor

@fmount fmount commented Jun 10, 2023

The NewOpenStack function is only used by keystone to get a an admin, system wide token that can be used by other operators through keystone service to register the associated resources. However, without scope:system Glance is not able to register the global limits defined in its main CR and it will fail configuring limits [1].
This patch ensures we have a system wide admin client that is able to act globally against the existing ctlplane.

[1] https://docs.openstack.org/glance/latest/admin/quotas.html#configuring-glance-for-per-tenant-quotas

@fmount fmount requested a review from konan-abhi June 10, 2023 11:57
fmount added a commit to fmount/glance-operator that referenced this pull request Jun 10, 2023
This patch exposes a boolean that can be used to enforce per-tenant
quotas in the GlanceAPI.
If true, the related glance-api section is enabled and templateParameters
are populated.
This patch assumes the quota resources are already registered in
keystone.

Depends-On: openstack-k8s-operators/lib-common/pull/262
Depends-On: gophercloud/gophercloud/pull/2616
Depends-On: openstack-k8s-operators/lib-common/pull/284

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
fmount added a commit to fmount/glance-operator that referenced this pull request Jun 10, 2023
This patch exposes the data structure and implement the related logic
that can be used to enforce per-tenant quotas in the GlanceAPI. When
limits are defined, the related glance-api config section is enabled and
templateParameters are populated.

Depends-On: openstack-k8s-operators/lib-common/pull/262
Depends-On: gophercloud/gophercloud/pull/2616
Depends-On: openstack-k8s-operators/lib-common/pull/284

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
TenantName: cfg.TenantName,
DomainName: cfg.DomainName,
Scope: &gophercloud.AuthScope{
System: true,
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.

Shouldn't this be based on some condition or do we always want this client with system scope?

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.

Something like this;
if os.Getenv("OS_SYSTEM_SCOPE") != "all"
System: false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure, maybe it's a good idea putting the Scope under a condition: I added it like this for two reasons:

  1. if we add a condition we then need to patch keystone-operator to get the OpenStack cli passing the scope;
  2. we only use gophercloud to create resources from the operators (endpoints, services, etc) against the ControlPlane being deployed: any other client can rely on the resulting clouds.yaml produced by keystone in a ConfigMap and get the appropriate client.

So you have strong opinions on it, or, do we have examples where having System: true can cause troubles?
I'm not against having it as a variable, it makes sense in lib-common, but I suspect we need to patch keystone-operator accordingly.
@stuggi any thoughts on this?

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.

As you said, I am not sure if we need it, but you could add a Scope pointer to the above AuthOpts and if it is not nil you can set it in NewOpenStack. with this there would be no need to the keystone-operator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, thanks @stuggi, I'll follow up on this!

@fmount fmount requested a review from stuggi June 12, 2023 07:42
fmount added a commit to fmount/glance-operator that referenced this pull request Jun 12, 2023
This patch exposes the data structure and implement the related logic
that can be used to enforce per-tenant quotas in the GlanceAPI. When
limits are defined, the related glance-api config section is enabled and
templateParameters are populated.

Depends-On: openstack-k8s-operators/lib-common/pull/262
Depends-On: gophercloud/gophercloud/pull/2616
Depends-On: openstack-k8s-operators/lib-common/pull/284

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
fmount added a commit to fmount/glance-operator that referenced this pull request Jun 12, 2023
This patch exposes the data structure and implement the related logic
that can be used to enforce per-tenant quotas in the GlanceAPI. When
limits are defined, the related glance-api config section is enabled and
templateParameters are populated.

Depends-On: openstack-k8s-operators/lib-common/pull/262
Depends-On: gophercloud/gophercloud/pull/2616
Depends-On: openstack-k8s-operators/lib-common/pull/284

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
fmount added a commit to fmount/glance-operator that referenced this pull request Jun 12, 2023
This patch exposes the data structure and implement the related logic
that can be used to enforce per-tenant quotas in the GlanceAPI. When
limits are defined, the related glance-api config section is enabled and
templateParameters are populated.

Depends-On: openstack-k8s-operators/lib-common/pull/262
Depends-On: gophercloud/gophercloud/pull/2616
Depends-On: openstack-k8s-operators/lib-common/pull/284

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
fmount added a commit to fmount/glance-operator that referenced this pull request Jun 12, 2023
This patch exposes the data structure and implement the related logic
that can be used to enforce per-tenant quotas in the GlanceAPI. When
limits are defined, the related glance-api config section is enabled and
templateParameters are populated.

Depends-On: openstack-k8s-operators/lib-common/pull/262
Depends-On: gophercloud/gophercloud/pull/2616
Depends-On: openstack-k8s-operators/lib-common/pull/284

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
The 'NewOpenStack' function is used to get a an admin, token that can be
used by operators through keystone service to register the associated
resources. However, without "scope:system" Glance is not able to register
the keystone global limits defined in its main CR and it will fail. This
patch ensures we have a system wide admin client that is able to act
globally against the existing ctlplane.

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
Copy link
Copy Markdown
Contributor

@konan-abhi konan-abhi left a comment

Choose a reason for hiding this comment

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

Looks good, Thank you!

fmount added a commit to fmount/glance-operator that referenced this pull request Jun 12, 2023
When the "quotas" struct is passed to the main Glance CR, the operator
needs a system scoped token to make sure the request is run
successfully. This change allows the glance-operator to not rely on the
keystone operator and build the required OSClient based on the new
AuthOps "System" parameter.

Depends-On: openstack-k8s-operators/lib-common#284

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
Copy link
Copy Markdown
Contributor

@stuggi stuggi left a comment

Choose a reason for hiding this comment

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

/lgtm

@stuggi stuggi merged commit d886a78 into openstack-k8s-operators:main Jun 13, 2023
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.

3 participants