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

Add status column to MiddlewareDomain #72

Closed
wants to merge 2 commits into from

Conversation

xeviknal
Copy link
Member

Related to issue #44

Adding status to MiddlewareDomain model.

@xeviknal
Copy link
Member Author

@josejulio could you please check this out? Happy to have a code review :)

Copy link
Contributor

@lpichler lpichler left a comment

Choose a reason for hiding this comment

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

Nice but we don't need to test structural changes because these things are tested in rails.

We need to test only when any data migration is happening.

so you can remove it and just leave only part of adding the column in migration.

thanks

@lpichler
Copy link
Contributor

@miq-bot assign @Fryguy

@abonas
Copy link
Member

abonas commented Sep 24, 2017

cc @agrare

@xeviknal
Copy link
Member Author

@lpichler good point. I'll remove it, I am testing a method which is already tested by rails.

Gotta say, that I wanted to check some of the tooling you have for testing migrations. My first time on a project with that :)

@miq-bot
Copy link
Member

miq-bot commented Sep 25, 2017

Checked commits xeviknal/manageiq-schema@8ae549f~...e32cc42 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 👍

@@ -0,0 +1,8 @@
class AddStatusToMiddlewareDomain < ActiveRecord::Migration[5.0]
class MiddlewareDomain < ActiveRecord::Base
end
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to disable STI here
self.inheritance_column = :_type_disabled # disable STI

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you please elaborate that a little bit?
I don't understand how the migration can change by disabling the STI

Copy link
Member

Choose a reason for hiding this comment

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

@Fryguy can correct me if I'm wrong but I believe it is so we don't end up loading the models during the migration if the record is subclassed with STI

Copy link
Contributor

Choose a reason for hiding this comment

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

self.inheritance_column = :_type_disabled # disable STI
here is when the table has column type. For more details see:#4

Anyway, you don't need to define model here, as you are not using the model in migration either in spec.

@abonas
Copy link
Member

abonas commented Sep 26, 2017

@josejulio @israel-hdez I've seen a bit different handling/persisting of status in the middleware server case - isn't all status related info stored in a properties object and not in a separate field? (availability, state, etc) I just want to make sure we are not doing something inconsistent here, but if there is indeed some difference that is ok - then we can leave this as is.

@josejulio
Copy link
Member

Deployments have their status as a separate field.
Not sure about Servers, but could not see any separate field.

@israel-hdez
Copy link
Member

Servers don't have status in its own column. The status and the availability are both stored in the properties column/hash.

Note that MiddlewareDomain is storing the following data in the properties hash:

Suspend State: 
Running Mode: NORMAL
Home Directory: "/opt/jboss/wildfly"
Version: 10.1.0.Final
Server State: 
Product Name: WildFly Full
Host State: running
Is Domain Controller: 'true'
UUID: 2dc495bf-5c2c-4074-8487-023ca7427fae
Name: master

Note that there is a Host State property. Is this what you want?

Also, be warned that the Host State most likely is reported by inventory and may not be the current status. Usually, you'll want to check the availability metric of the domain host (like the case of the servers).

@xeviknal
Copy link
Member Author

thanks for that @israel-hdez and @josejulio.

Regarding your question, I don't exactly know which attribute of the hash is the one that says the availability of the domain. I guess it is, yes, the Host State. Could you please confirm that?

Regarding to the last sentence, I guess you mean that I should add logic to AvailabilityUpdates parser/collector in order to have current domain availability. My approach, thanks to @josejulio, here
Is that what you meant?

@xeviknal
Copy link
Member Author

@josejulio don't you thing that properties for each domain are already stored before (MiddlewareManager#fetch_domains_with_servers), thus, the availability is already stored.
Here the stacktrace:
MiddlewareManager#L14: fetch domains with servers.
MiddlewareManager#L62: parsing middleware domain.
MiddlewareManager#L312: mapping hawkular item to inventory_object
MiddlewareManager#L359: map :ems_ref, :nativeid, :feed, :properties.

Then, probably the lines you sent, are not needed in this case. Anything to say @israel-hdez ?

@josejulio
Copy link
Member

@josejulio don't you thing that properties for each domain are already stored before (MiddlewareManager#fetch_domains_with_servers), thus, the availability is already stored.
Here the stacktrace:
MiddlewareManager#L14: fetch domains with servers.
MiddlewareManager#L62: parsing middleware domain.
MiddlewareManager#L312: mapping hawkular item to inventory_object
MiddlewareManager#L359: map :ems_ref, :nativeid, :feed, :properties.

IIRC that fetches the data/properties from the Inventory. As @israel-hdez pointed out Host State is reported on a given refresher and could be outdated.
We fetch the availability metric for the given resource (server or deployment) and would need to do the same for the domain.

I have checked the default configuration, and I don't see any avail metric for the domain itself(only for the domain servers). I suppose we might need to add one.

@israel-hdez, Can you please correct me if I'm wrong?

@israel-hdez
Copy link
Member

@josejulio @xeviknal Yes, Host State is reported by inventory and usually is not updated when the domain goes down.
Hmm... Yes, there is no avail metric in the config for the domain. Perhaps you could try querying Hawkular to see if, by any chances, it's there?

BTW, I checked the changes in @xeviknal branch. The availability_changes parser/collector/persister are there for use in the event catcher. So, you are missing some changes here: https://github.com/ManageIQ/manageiq-providers-hawkular/blob/master/app/models/manageiq/providers/hawkular/middleware_manager/event_catcher/stream.rb#L49

And also, the changes that @josejulio said are also required so that availabilities are collected when a refresh is done.

@abonas
Copy link
Member

abonas commented Oct 2, 2017

@miq-bot add_label providers/middleware

@xeviknal
Copy link
Member Author

xeviknal commented Oct 4, 2017

Okay, I am closing this PR since there is no need to add a new column to domain. Availability is going to be stored on MiddlewareDomain#properties.

@xeviknal xeviknal closed this Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants