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 condition helpers to Multi-Network API. #526

Closed
wants to merge 1 commit into from

Conversation

mskrocki
Copy link
Contributor

No description provided.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 28, 2023
@k8s-ci-robot k8s-ci-robot requested review from aojea and bowei April 28, 2023 23:03
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 28, 2023
@mskrocki mskrocki changed the title Add condition helpers to Network object. Add condition helpers to Multi-Network API. Apr 30, 2023
@mskrocki mskrocki force-pushed the addIsReady branch 2 times, most recently from e4551bd to e80dc36 Compare April 30, 2023 18:37
@mskrocki
Copy link
Contributor Author

mskrocki commented May 1, 2023

/cc @mrthinger

@k8s-ci-robot
Copy link
Contributor

@mskrocki: GitHub didn't allow me to request PR reviews from the following users: mrthinger.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @mrthinger

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@mrthinger mrthinger left a comment

Choose a reason for hiding this comment

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

Could this be a method on the structs instead?

I don't think branching on type is a great way of implementing this, but this obviously works fine.

@aojea
Copy link
Member

aojea commented May 2, 2023

Could this be a method on the structs instead?

I just was inclined to avoid that #526 (comment), adding methods to the struct will add a dependency on the object that is versioned, and the function is agnostic of that, per example, you can use this function with existing version, but in order to use the method you have to update your dependency first

@aojea
Copy link
Member

aojea commented May 2, 2023

LGTM

I do not know if you prefer to use generics, cast interfaces or one function per object, but I have doubts on the method per object approach per #526 (comment), but I may be wrong too

@k8s-ci-robot
Copy link
Contributor

@mskrocki: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cloud-provider-gcp-scenario-kops-simple d4a33f9 link false /test pull-cloud-provider-gcp-scenario-kops-simple

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Contributor

@mrthinger mrthinger left a comment

Choose a reason for hiding this comment

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

LGTM. The conditions function will be scoped to the network package anyway, so discoverability and maintainability shouldn't be an issue.

Copy link
Member

@MrHohn MrHohn left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 2, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MrHohn, mrthinger, mskrocki

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


// GetCondition returns the "condType" condition from the obj. Only Network and
// GKENetworkParamSet types are supported. Returns nil when not found.
func GetCondition(obj interface{}, condType string) (*metav1.Condition, error) {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion

create a struct that wraps metav1.Condition that implements the specific CRUD for conditions that we care about. Might be cleaner for users than one-off functions.

func NewConditionCRUD(c*metav1.Condition) ...
type ConditionCRUD struct { ... }


crud := NewConditionCRUD(obj.Status.Conditions)
if crud.Ready() { ...
}

crud.SetReady(false, "it's not ready")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I were looking into this I found https://github.com/kubernetes/apimachinery/blob/master/pkg/api/meta/conditions.go which has all the required functions, will close this PR.

@mskrocki
Copy link
Contributor Author

mskrocki commented May 2, 2023

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 2, 2023
@mskrocki
Copy link
Contributor Author

mskrocki commented May 3, 2023

@mskrocki mskrocki closed this May 3, 2023
@mskrocki mskrocki deleted the addIsReady branch October 24, 2023 20:45
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants