Skip to content

Conversation

@Miciah
Copy link
Contributor

@Miciah Miciah commented Mar 11, 2020

Add helpers for deployment unit tests

  • pkg/operator/controller/ingress/deployment_test.go (checkDeploymentHasEnvVar, checkDeploymentHasContainer): New helpers.
    (TestDesiredRouterDeployment): Use the new helpers.

Bump openshift/api for logging API

Bump to github.com/openshift/api@8cfd79130f9c03777ae5db16e2c55e1039f977aa to get the logging API.

  • go.mod: Bump.
  • hack/update-generated-crd.sh:
  • hack/verify-generated-crd.sh: Update path to the vendored ingresscontroller CRD file.
  • go.sum:
  • manifests/00-custom-resource-definition.yaml:
  • pkg/manifests/bindata.go:
  • vendor/github.com/openshift/api/*:
  • vendor/modules.txt: Regenerate.

Implement logging API

This commit resolves NE-285.

  • pkg/operator/controller/ingress/deployment.go (RouterLogLevelEnvName, RouterSyslogAddressEnvName, RouterSyslogFormatEnvName, RouterSyslogFacilityEnvName): New constants.
    (desiredRouterDeployment): Check whether spec.logging.access is specified on the ingresscontroller, and configure logging accordingly.
  • pkg/operator/controller/ingress/deployment_test.go (TestDesiredRouterDeployment): Verify that the unsupported-logging annotation overrides spec.logging.access. Verify that spec.logging.access has the desired effect.
    (TestInferTLSProfileSpecFromDeployment): Use "logs" as the name of the syslog sidecar container in order to be consistent with the logging API.
  • test/e2e/operator_test.go (TestSyslog): New test. Create a pod that runs an rsyslog instance and an ingresscontroller that logs to that rsyslog instance and verify that the rsyslog instance logs an HTTP request.

@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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 11, 2020
@Miciah Miciah force-pushed the NE-285-implement-logging-API branch 4 times, most recently from 116d38e to 830d2c7 Compare March 25, 2020 21:59
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 1, 2020
@Miciah Miciah force-pushed the NE-285-implement-logging-API branch from 830d2c7 to 46c688e Compare April 14, 2020 17:44
* pkg/operator/controller/ingress/deployment_test.go
(checkDeploymentHasEnvVar, checkDeploymentHasContainer): New helpers.
(TestDesiredRouterDeployment): Use the new helpers.
@Miciah
Copy link
Contributor Author

Miciah commented Apr 14, 2020

Rebased.

@Miciah Miciah force-pushed the NE-285-implement-logging-API branch from 46c688e to 6ab76aa Compare April 14, 2020 17:52
@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 14, 2020
@Miciah Miciah force-pushed the NE-285-implement-logging-API branch from 6ab76aa to c13edae Compare April 14, 2020 18:30
@Miciah
Copy link
Contributor Author

Miciah commented Apr 15, 2020

/retest

3 similar comments
@Miciah
Copy link
Contributor Author

Miciah commented Apr 15, 2020

/retest

@Miciah
Copy link
Contributor Author

Miciah commented Apr 15, 2020

/retest

@Miciah
Copy link
Contributor Author

Miciah commented Apr 15, 2020

/retest

@Miciah
Copy link
Contributor Author

Miciah commented Apr 16, 2020

/test e2e-aws

@Miciah
Copy link
Contributor Author

Miciah commented Apr 16, 2020

/retest

Bump to github.com/openshift/api@8cfd79130f9c03777ae5db16e2c55e1039f977aa
to get the logging API.

* go.mod: Bump.
* hack/update-generated-crd.sh:
* hack/verify-generated-crd.sh: Update path to the vendored
ingresscontroller CRD file.
* go.sum:
* manifests/00-custom-resource-definition.yaml:
* pkg/manifests/bindata.go:
* vendor/github.com/openshift/api/*:
* vendor/modules.txt: Regenerate.
@Miciah Miciah force-pushed the NE-285-implement-logging-API branch from c13edae to 9edc970 Compare April 16, 2020 22:33
@Miciah Miciah changed the title WIP: Implement logging API Implement logging API Apr 16, 2020
@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 Apr 16, 2020
@Miciah Miciah force-pushed the NE-285-implement-logging-API branch from 9edc970 to c7c60a7 Compare April 16, 2020 22:37
}
}

func checkRollingUpdateParams(t *testing.T, deployment *appsv1.Deployment, maxUnavailable intstr.IntOrString, maxSurge intstr.IntOrString) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice little refactor here, thanks — one more thing it made me think of (not required, just a sidebar discussion) is you can now express your expectations with a struct and make a table test out of the env assertions, like

{
  env{name: WildcardRouteAdmissionPolicy, equals: "false"},
  env{name: "ROUTER_USE_PROXY_PROTOCOL", equals: nil},
}

And feed them into your assertion function. Likewise with container checks. And then keep adding sugar until we reinvent Ginkgo 😁

Copy link
Contributor

@ironcladlou ironcladlou left a comment

Choose a reason for hiding this comment

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

First quick pass

@Miciah Miciah force-pushed the NE-285-implement-logging-API branch 2 times, most recently from e365ca3 to 6704902 Compare April 17, 2020 00:23
This commit resolves NE-285.

https://issues.redhat.com/browse/NE-285

* pkg/operator/controller/ingress/deployment.go (RouterLogLevelEnvName)
(RouterSyslogAddressEnvName, RouterSyslogFormatEnvName)
(RouterSyslogFacilityEnvName): New constants.
(desiredRouterDeployment): Delete logic for the unsupported-logging
annotation.  Using the new accessLoggingForIngressController function,
check whether spec.logging.access is specified on the ingresscontroller,
and configure logging accordingly.
(accessLoggingForIngressController): New function.  Return the access
logging parameters for the given ingresscontroller if it enables access
logging.
* pkg/operator/controller/ingress/deployment_test.go
(TestDesiredRouterDeployment): Verify that the unsupported-logging
annotation overrides spec.logging.access.  Verify that spec.logging.access
has the desired effect.
(TestInferTLSProfileSpecFromDeployment): Use "logs" as the name of the
syslog sidecar container in order to be consistent with the logging API.
* pkg/operator/controller/ingress/rsyslog_configmap.go
(EnableLoggingAnnotation, haproxyLogLevels): Delete definitions.
(ExtraLoggingEnabled): Delete function.
(desiredRsyslogConfigMap): Use accessLoggingForIngressController to
determine whether a configmap is needed.
* test/e2e/operator_test.go (TestSyslogLogging): New test.  Create a pod
that runs an rsyslog instance and an ingresscontroller that logs to that
rsyslog instance and verify that the rsyslog instance logs an HTTP request.
* test/e2e/operator_test.go (TestContainerLogging): New test.  Create an
ingresscontroller that logs to a sidecar container and verify that it
becomes available.
@Miciah Miciah force-pushed the NE-285-implement-logging-API branch from 6704902 to 1da14ee Compare April 17, 2020 01:38
@ironcladlou
Copy link
Contributor

lgtm, will let @danehans do the honors after he gets a chance to look through it

return deployment, nil
}

// accessLoggingForIngressController returns an AccessLogging value for the
Copy link
Contributor

Choose a reason for hiding this comment

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

@Miciah accessLoggingForIngressController returns a pointer not a value, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it's a pointer. We can fix the comment in a follow-up.

@danehans
Copy link
Contributor

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danehans, Miciah

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

The pull request process is described here

Details 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

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants