Skip to content

Conversation

@rcarrillocruz
Copy link
Contributor

This allows must-gather tool to give information about CNO objects
for free.

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 14, 2019
related := []configv1.ObjectReference{
{
Resource: "namespaces",
Name: "openshift-sdn",
Copy link
Contributor

Choose a reason for hiding this comment

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

(Aside: is "namespaces" correct? I would have expected it to want the singular.)

This should be computed dynamically based on the actual Namespaces we created. The same way that ReconcileOperConfig figures out the set of active DaemonSets and Deployments and then tells the StatusManager about them, it should do the same with Namespaces. (Except it should add the controller's namespace to the list too.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Plural is correct, because this is a Resource, not a Kind. However, dan is right, this should be computed automatically.

log.Printf("Failed to get ClusterOperator %q: %v", status.name, err)
return
}
co.Status.RelatedObjects = objects
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just modifying the copy that you just fetched, which will be GC'ed as soon as this function returns.

You can just store the objects in a field on status here, and then set them on the object in Set

@rcarrillocruz rcarrillocruz force-pushed the add_namespaces_to_related_objects branch from f5678bd to 6d0e4bb Compare July 2, 2019 13:44
@danwinship
Copy link
Contributor

@rcarrillocruz good except now you're never copying status.relatedObjects over to co.Status.RelatedObjects.

Also, please squash your commits rather than doing fixups. It's generally easier to deal with if the PR is always in a ready-to-be-merged form.

@rcarrillocruz rcarrillocruz force-pushed the add_namespaces_to_related_objects branch from 6d0e4bb to ef1141d Compare July 10, 2019 17:32
@rcarrillocruz
Copy link
Contributor Author

/retest

@danwinship
Copy link
Contributor

Doh. Sorry, I guess I wasn't clear. SetRelatedObjects should just set a field on the StatusManager object, like in the previous version, and then Set should copy that into the object being updated, like in the original version except with the dynamically-generated list (co.Status.RelatedObjects = status.relatedObjects)

@rcarrillocruz rcarrillocruz force-pushed the add_namespaces_to_related_objects branch from ef1141d to 16dd37f Compare July 11, 2019 16:10
}
relatedObjects = append(relatedObjects, configv1.ObjectReference{
Group: obj.GetObjectKind().GroupVersionKind().Group,
Resource: obj.GetKind(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't right - the object kind is "Namespace", whereas the API resource is "namespaces". You need to actually look up the conversion between the Kind and the Resource using the the RESTMapper.

It's a bit awkward, yes. It looks like a few other operators do it. See if they hard-code the mapping or do something cleverer.

@rcarrillocruz rcarrillocruz force-pushed the add_namespaces_to_related_objects branch from 16dd37f to e306aa9 Compare July 12, 2019 10:38
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 12, 2019
@rcarrillocruz
Copy link
Contributor Author

/retest

}
objs = append([]*uns.Unstructured{app}, objs...)

config, err := rest.InClusterConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to create your own RestMapper - just get it from the manager.

}
restMapping, err := mapper.RESTMapping(obj.GroupVersionKind().GroupKind())
if err != nil {
log.Printf("Failed to get REST mapping:%v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

needs a continue here, and maybe a bit more useful error message.

@squeed
Copy link
Contributor

squeed commented Jul 12, 2019

Two small comments, then this should be good to go.

@rcarrillocruz rcarrillocruz force-pushed the add_namespaces_to_related_objects branch 2 times, most recently from 1af0bae to efa160e Compare July 12, 2019 15:24
@squeed
Copy link
Contributor

squeed commented Jul 15, 2019

/approve

This adds all objects to the Related field. I think that's fine - thoughts, @danwinship?

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2019
This allows must-gather tool to give information about CNO objects
for free.
@rcarrillocruz rcarrillocruz force-pushed the add_namespaces_to_related_objects branch from efa160e to 79ee4fc Compare July 16, 2019 07:57
@danwinship
Copy link
Contributor

This adds all objects to the Related field. I think that's fine - thoughts, @danwinship?

That was the plan, wasn't it? Then we can use that to figure out what we need to clean up?

The API documentation is not detailed enough to either confirm or deny that this is OK.

@squeed
Copy link
Contributor

squeed commented Jul 16, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rcarrillocruz, squeed

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit f86fe2f into openshift:master Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants