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

Bug 1777137: add observation of idp config and validation of its cm/secrets #222

Merged
merged 8 commits into from Jun 19, 2020

Conversation

stlaz
Copy link
Member

@stlaz stlaz commented Nov 28, 2019

currently probably quite fragile, many FIXMEs and TODOs

The previous resource sync for the resources from the oauth config was replaces by syncing it from the configobserver and it seems to work, just as well as does the slightly reworked logic about how mounts are placed in the pods

  • add observation for whatever we need from the consoles
  • add observation for whatever we need from the infrastructures object
  • make the deployment use the observed config
  • ?
  • profit

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 28, 2019
@stlaz stlaz force-pushed the observe_config branch 6 times, most recently from 0313a34 to 3eb0494 Compare December 2, 2019 15:17
@stlaz
Copy link
Member Author

stlaz commented Dec 3, 2019

/retest

1 similar comment
@stlaz
Copy link
Member Author

stlaz commented Dec 4, 2019

/retest

@stlaz stlaz force-pushed the observe_config branch 3 times, most recently from 6e43291 to dbe3514 Compare December 6, 2019 08:50
@stlaz stlaz changed the title [WIP] [ugly commits] add config observation [WIP] add config observation Dec 6, 2019
@stlaz
Copy link
Member Author

stlaz commented Dec 6, 2019

did some very wild rebasing to make this reviewable

@stlaz stlaz mentioned this pull request Dec 10, 2019
Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

Not too serious a review as befits my lack of experience with the operator and the WIP nature of the PR. I'm surprised so many jobs passed, I guess that's an indication of a lack of test coverage?

Given the amount of repetition between the observers, maybe there's room for generic helpers that can simplify reading and writing unstructured data? I'm thinking most observers could be driven by data rather than code:

// Accepts lister and returns a mapping of canonical field names and their current values
func currentConfigFunc(configobservation.Listers) (map[string]interface{}, error)

// Example result
currentConfig := map[string]interface{}{
  // . separated field names
  "my.value": 0,
}

Given a function that can marshal data from a static type from the API to unstructured, maybe it's possible for generic helpers to be used to read/write from unstructured?

pkg/operator2/configobservation/apiserver/observe_cors.go Outdated Show resolved Hide resolved
pkg/operator2/configobservation/apiserver/observe_cors.go Outdated Show resolved Hide resolved
pkg/operator2/configobservation/apiserver/observe_cors.go Outdated Show resolved Hide resolved
pkg/operator2/configobservation/apiserver/observe_cors.go Outdated Show resolved Hide resolved
pkg/operator2/configobservation/apiserver/observe_cors.go Outdated Show resolved Hide resolved
"github.com/openshift/cluster-authentication-operator/pkg/operator2/configobservation"
)

const defaultAccessTokenMaxAgeSeconds = float64(86400) // a day
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that the golant struct fields are int32 and the value in seconds is fixed point, is it desirable to use a floating point type?

Copy link
Member Author

Choose a reason for hiding this comment

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

glad you asked, this was such a PITA to get right.

The config is really a json that gets deserialized into golang nested interfaces.

When we make this int32 and store as such, the information about it being int is obviously stored.

Eventually, the configObserver, which lives in library-go, compares the config it got originally with the one that it got as observed config.

This is where all the fun happens. because the json parser actually likes to think of numbers as of floats prior to them being integers. That means that if we make this integer, same jsons will actually be considered different in their go interpretation even if our comparison here tells you the numbers are equal. That results in hotloop trying to update the observedConfig field on same values.

I tried many things, played with the json parser flags, use json.Number as the default representation for numbers found in the jsons we have here but nothing except this really worked.

I did a terrible job with code comments about this, I see.

Copy link
Member Author

@stlaz stlaz left a comment

Choose a reason for hiding this comment

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

First bunch of answers, for some reason github defaults to comments using their review system. Meh.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 14, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 14, 2020
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 24, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 21, 2020
@stlaz stlaz force-pushed the observe_config branch 3 times, most recently from 21e87ef to 7e12e9a Compare June 16, 2020 12:42
@stlaz
Copy link
Member Author

stlaz commented Jun 16, 2020

addressed the comments, during which I noticed default authz token max age, which is not actually being dynamically set, was missing, fixed that

@stlaz
Copy link
Member Author

stlaz commented Jun 16, 2020

/retest

expected: map[string]interface{}{
"oauthConfig": map[string]interface{}{
"tokenConfig": map[string]interface{}{
"accessTokenMaxAgeSeconds": float64(86400),
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Maybe this is just my ignorance of accepted practice for cluster operators, but I find it strange to see magic numbers rather than constants.

errors: []error{},
},
{
name: "inactivity 0 means disabled",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused - how is this different from "max age 0 still means default max age"?

@marun
Copy link
Contributor

marun commented Jun 17, 2020

@stlaz Thank you for cleanup! Other than the seemingly duplicated test, lgtm. Please squash for merge.

@openshift-ci-robot
Copy link
Contributor

@stlaz: This pull request references Bugzilla bug 1777137, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1777137: add observation of idp config and validation of its cm/secrets

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.

1 similar comment
@openshift-ci-robot
Copy link
Contributor

@stlaz: This pull request references Bugzilla bug 1777137, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1777137: add observation of idp config and validation of its cm/secrets

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.

@marun
Copy link
Contributor

marun commented Jun 18, 2020

/lgtm
/retest

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marun, stlaz

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

@stlaz
Copy link
Member Author

stlaz commented Jun 19, 2020

/retest

1 similar comment
@stlaz
Copy link
Member Author

stlaz commented Jun 19, 2020

/retest

@stlaz
Copy link
Member Author

stlaz commented Jun 19, 2020

/retest
unrelated failures

@openshift-merge-robot openshift-merge-robot merged commit 852cd73 into openshift:master Jun 19, 2020
@openshift-ci-robot
Copy link
Contributor

@stlaz: All pull requests linked via external trackers have merged: openshift/cluster-authentication-operator#222. Bugzilla bug 1777137 has been moved to the MODIFIED state.

In response to this:

Bug 1777137: add observation of idp config and validation of its cm/secrets

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.

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. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged. 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.

None yet

4 participants