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

Cannot unmarshal string into Go struct field Config.JobCleanupDuration of type time.Duration #857

Closed
adriananeci opened this issue Feb 25, 2021 · 4 comments · Fixed by #884
Assignees
Labels
bug Something isn't working

Comments

@adriananeci
Copy link
Contributor

adriananeci commented Feb 25, 2021

Describe the bug

Kuberhealthy cannot parse the configmap when jobCleanupDuration option is defined because it cannot unmarshal string into Go struct field Config.JobCleanupDuration of type time.Duration

time="2021-02-25T05:12:29Z" level=info msg="WARNING: Failed to read configuration file from disk: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field Config.JobCleanupDuration of type time.Duration"

Steps To Reproduce

  • Start kuberhealthy with the following associated configmap
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: kuberhealthy
  namespace: test
data:
  kuberhealthy.yaml: |-
    listenAddress: ":8080" # The port for kuberhealthy to listen on for web requests
    enableForceMaster: false # Set to true to enable local testing, forced master mode
    logLevel: "debug" # Log level to be used
    listenNamespace: "test" # Kuberhealthy will only monitor khcheck resources from this namespace
    jobCleanupDuration: 3m # The maximum age of khjobs before being reaped
    maxCheckPods: 1 # The maximum number of check pods in Completed state before being reaped
  • Check the logs and you'll see a warning like
time="2021-02-25T05:12:29Z" level=info msg="WARNING: Failed to read configuration file from disk: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field Config.JobCleanupDuration of type time.Duration"
  • Try to adjust jobCleanupDuration value in configmap
  • Check kuberhealthy logs and you'll see
time="2021-02-25T10:07:35Z" level=debug msg="configReloader: configuration file hash has changed to: 1807f3c6108d085b5b5b6b2a87294b16"
time="2021-02-25T10:07:41Z" level=error msg="configReloader: Error reloading config: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field Config.JobCleanupDuration of type time.Duration"

Expected behavior
No warnings/errors during starting or configmap changes

Versions

  • Cluster OS: Flatcar
  • Kubernetes Version: 1.18.14
  • Kuberhealthy Release: v2.4.0
@adriananeci adriananeci added the bug Something isn't working label Feb 25, 2021
@integrii
Copy link
Collaborator

integrii commented Mar 3, 2021

This is really strange considering that the helm chart defaults to 15m in the values.yaml... We will need to reproduce this one and figure out what the difference is

@joshulyne
Copy link
Collaborator

Fixed in #862! Use image: kuberhealthy/kuberhealthy:v2.4.1!

@integrii
Copy link
Collaborator

integrii commented Apr 30, 2021

@joshulyne and I looked into this and it looks like the root cause of the failed time.Duration parsing is due to the package used here. I am going to open a new PR for this one here soon. Reopening.

@integrii integrii reopened this Apr 30, 2021
@integrii
Copy link
Collaborator

Looks like I can piggyback this change into #884

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants