-
Notifications
You must be signed in to change notification settings - Fork 898
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
Instantiate Container Template #10737
Conversation
@simon3z @zeari @moolitayer Please review |
3bdb4ee
to
9299c15
Compare
|
||
ext_management_system.with_provider_connection do |client| | ||
kubeclient = Marshal.load(Marshal.dump(client)) | ||
kubeclient.api_endpoint.path = "/api" |
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 is somewhat hacky since it has assumptions on kubeclient internal state.
you can use the ext_management_system method that does not use a block to get two clients and do the clean up yourself.
also see this
In the future it would be helpful if we could provide a forwarding client, just like the oc client lets us create objects in OpenShift and k8s alike cc @abonas @simon3z.
Looks good overall , container_template.rb needs some attention |
temp[:metadata][:name] = name | ||
temp[:metadata][:namespace] = container_project.name | ||
temp[:objects] = objects | ||
temp[:parameters] = params |
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.
container_template_parameters?
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.
we would like to allow the user to edit the template parameters and not just use them as they are (to be added later on)
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.
its up to you but this might be nicer as:
{
:metadata => {
:name => name
:namespace => container_project.name
}
:objects => object
:parameters => params
}
9299c15
to
cb708fd
Compare
@moolitayer thanks, I've made the changes please take another look |
begin | ||
kubeclient.send("create_#{obj[:kind].underscore}", obj) | ||
rescue KubeException => e | ||
$log.error("Unexpected Exception during creating object: #{e}") |
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.
s/during/while/g
- It doesn't bother me a lot but I wonder if the code here could be smarter:
- Can we know beforehand if the template should be processed through openshift or kubernetes clients?
- Should we try the other client if the
KubeException
is something like a connection timeout?
@miq-bot assign zakiva |
478d908
to
b483b2d
Compare
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
941daba
to
ed67fcb
Compare
obj = obj.symbolize_keys | ||
obj[:metadata][:namespace] = project | ||
create_entity = "create_#{obj[:kind].underscore}" | ||
client = openshift_client.respond_to?(create_entity) ? openshift_client : kubeclient |
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.
if you are creating objects from different api groups you would have to create a new kubeclient for that group.
Knowing what your target group is available through the apiVersion of the object:
apiVersion: batch/v1
kind: Job
3a9cfde
to
6e317ab
Compare
e5f44e5
to
5d15fb6
Compare
@moolitayer please review |
@zakiva I think the build-in rollback implementation (choice No. 1) is fine. |
@bzwei Please see my comments in the code.
Please note that not all created objects will necessarily be saved in VMDB because we don't collect all kinds of objects. |
@@ -12,4 +12,55 @@ class ContainerTemplate < ApplicationRecord | |||
serialize :objects, Array | |||
|
|||
acts_as_miq_taggable | |||
|
|||
def instantiate(params, project = nil) |
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.
@bzwei project
is the container project name in which the template will be instantiated. This container project is saved in the VMDB as you mentioed, here we just need to use its name. I can change this var name to project_name
, it would probably be more accurate.
@@ -23,4 +23,10 @@ def self.event_monitor_class | |||
def supported_auth_attributes | |||
%w(userid password auth_key) | |||
end | |||
|
|||
def create_project(project) |
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.
@bzwei project
here is a hash that represents the project to be created in openshift and then collected and saved in VMDB table container_projects
.
@zeari we tested that together last time: oc process -n openshift -v HAWKULAR_METRICS_HOSTNAME=example.com \
metrics-deployer-template | jq -C .items[].metadata {
"generateName": "metrics-deployer-",
"labels": {
"component": "deployer",
"metrics-infra": "deployer",
"provider": "openshift"
}
} Out of the process command we see the defined |
@simon3z @zeari that's correct of course, but we do have the actual |
e110b86
to
2130627
Compare
@@ -12,4 +12,69 @@ class ContainerTemplate < ApplicationRecord | |||
serialize :objects, Array | |||
|
|||
acts_as_miq_taggable | |||
|
|||
MIQ_ENTITY_MAPPING = { |
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.
@simon3z I added this mapping (only for objects we collect & can instantiate) so the automation side will be able to know in which table to look for the objects.
We may consider adding a more general mapping to reuse it later on in different places.
cc @moolitayer
@@ -23,4 +23,10 @@ def self.event_monitor_class | |||
def supported_auth_attributes | |||
%w(userid password auth_key) | |||
end | |||
|
|||
def create_project(project) | |||
connect.create_project_request project |
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.
prefer connect.create_project_request(project)
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.
done
With current implementation it should provide sufficient information to start the automate provisioning design/implementation 👍 |
2130627
to
475ab1c
Compare
475ab1c
to
37e6ece
Compare
Checked commit zakiva@37e6ece with ruby 2.2.6, rubocop 0.46.0, and haml-lint 0.19.0 |
@zakiva is there a BZ for this? If not, please create one. Thanks! |
@bzwei @gmcculloug @zakiva my impression is that we don't need this in euwe. Is that right? (So we don't need to create a BZ as asked by @simaishi and we can drop the euwe label). |
@zakiva please send another PR adding a comment to |
This PR is built on #10159 - Persist Container Templates.
Changes included: