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

ansible: pull watches into own package #1523

Merged
merged 6 commits into from
Jul 9, 2019

Conversation

djzager
Copy link
Contributor

@djzager djzager commented Jun 5, 2019

In the same way that Helm has a watches package responsible for loading
the watches file, Ansible should be structured similiarly to separate
concerns, primarily, loading and validating the watches and creating
runners.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 5, 2019
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 5, 2019
@djzager djzager force-pushed the runner-refactor branch 3 times, most recently from 9745fe2 to 3c9491d Compare June 5, 2019 17:53
@djzager djzager force-pushed the runner-refactor branch 2 times, most recently from 29c3afe to 3ccaa62 Compare June 13, 2019 18:55
@djzager djzager changed the title wip: ansible: pull watches into own package ansible: pull watches into own package Jun 13, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 13, 2019
return err
}

// TODO: Failing on invalid ReconcilePeriod is (I believe) new behavior
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a change in behavior.

Copy link
Member

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

LGTM

@djzager
Copy link
Contributor Author

djzager commented Jul 1, 2019

@jmrodri could you take a look at this?

// Run - A blocking function which starts a controller-runtime manager
// It starts an Operator by reading in the values in `./watches.yaml`, adds a controller
// to the manager, and finally running the manager.
func Run(done chan error, mgr manager.Manager, f *flags.AnsibleOperatorFlags, cMap *controllermap.ControllerMap) {
watches, err := runner.NewFromWatches(f.WatchesFile)
watchesSlice, err := watches.Load(f.WatchesFile)
Copy link
Member

Choose a reason for hiding this comment

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

@lilic was looking into adding support in the ansible operator for kube-state-metrics, which would require access to the GVKs from watches.yaml in pkg/ansible/run.go. The helm operator does the watch file parsing in pkg/helm/run.go and passes the necessary pieces into the controller and metrics registration functions.

Is something like that do-able for the ansible-operator case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know enough about the impact of that sort of change so I'll just ping @shawn-hurley on that.

I do think that we could agree that the changes mentioned would be outside the scope of this PR? I would be happy to implement that move...and I would be happy to see this PR merged 😎

Copy link
Member

Choose a reason for hiding this comment

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

yes I am happy if it's done in a separate PR, but it is something that needs to be done for the custom resource metrics to be enabled.

@djzager
Copy link
Contributor Author

djzager commented Jul 8, 2019

@joelanford you think that you could have a look at this PR?

Copy link
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

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

The refactoring is great. I have a few nits but I'm not going to hold this PR up for them. They're just things I would have done differently but doesn't really change the functionality of the PR.

pkg/ansible/operator/operator.go Show resolved Hide resolved
pkg/ansible/operator/operator.go Outdated Show resolved Hide resolved
pkg/ansible/operator/operator_test.go Show resolved Hide resolved
Copy link
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 8, 2019
In the same way that Helm has a watches package responsible for loading
the watches file, Ansible should be structured similiarly to separate
concerns, primarily, loading and validating the watches and creating
runners.
- Move the runner struct next to the functions that accept it (back to
where it was before)
- Remove fields from runner that aren't needed anymore
  since we load the watches first, we can put manageStatus,
  reconcilePeriod, watchDependentResources, watchClusterScopedResources
  on the controller
It is valid for a watch to have a finalizer with no role/playbook so
long as it specifies vars to be run with the playbook/role specified on
the watch.
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 8, 2019
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@jmrodri jmrodri merged commit 8631041 into operator-framework:master Jul 9, 2019
@djzager djzager deleted the runner-refactor branch August 20, 2019 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants