Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Link helm-created resources to FluxHelmReleases #1134

Merged
merged 4 commits into from
Jun 19, 2018

Conversation

squaremo
Copy link
Member

This does two things:

  • it records the "release status" of a Helm release that corresponds to a FluxHelmRelease, in the FluxHelmRelease

  • it marks each resource that's created as a consequence of a FluxHelmRelease as linked to that FHR. This is then included in the ListControllers response in the API, as the field Antecedent, in the form of a stringified resource ID.

For example,

[
  {
    "ID": "default:deployment/default-mariadb-mariadb",
    "Containers": [
      {
        "Name": "mariadb",
        "Current": {
          "ID": "bitnami/mariadb:_"
        },
        "LatestFiltered": {
          "ID": ""
        }
      }
    ],
    "ReadOnly": "NotInRepo",
    "Status": "ready",
    "Antecedent": "default:fluxhelmrelease/mariadb",
    "Labels": {
      "app": "default-mariadb-mariadb",
      "chart": "mariadb-2.1.3",
      "heritage": "Tiller",
      "release": "default-mariadb"
    },
    "Automated": false,
    "Locked": false,
    "Ignore": false,
    "Policies": {}
  },
  {
    "ID": "default:fluxhelmrelease/mariadb",
    "Containers": [
      {
        "Name": "chart-image",
        "Current": {
          "ID": "bitnami/mariadb:_"
        },
        "LatestFiltered": {
          "ID": ""
        }
      }
    ],
    "ReadOnly": "",
    "Status": "DEPLOYED",
    "Antecedent": "",
    "Labels": {
      "chart": "mariadb"
    },
    "Automated": true,
    "Locked": false,
    "Ignore": false,
    "Policies": {
      "automated": "true"
    }
  }
]

@squaremo squaremo added the helm label Jun 11, 2018
@squaremo
Copy link
Member Author

squaremo commented Jun 12, 2018

Fixes #1109 and fixes #1110.

@squaremo squaremo requested a review from aaron7 June 13, 2018 09:30

// Get the corresponding HelmRelease status
// Annotate/Status things
// (will probably need to keep a worklist)

This comment was marked as abuse.

This comment was marked as abuse.

for {
select {
case <-stop:
break bail

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

default:
}

if err := a.rateLimiter.Wait(ctx); err != nil {

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@squaremo
Copy link
Member Author

@aaron7 Wanna check the fixups? Then I'll squash them and meeerge.

Copy link
Contributor

@aaron7 aaron7 left a comment

Choose a reason for hiding this comment

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

lgtm

Some cosmetic changes to smooth the way.

 - remove dead wood
 - remove redundant allocations
 - dedup getting release
 - use return type *T rather than derefing *T
This introduces a loop which checks each FluxHelmRelease and updates
its status depending on the status of its corresponding Helm
release. This is so that you (or the Flux API) can see from just the
FHR what is happening.
We want to be able to identify the resources created, indirectly, by a
FluxHelmRelease.

We don't get access to the creation process, since that's managed by
Helm; but we do get to see, afterwards, which resources were involved,
in a big YAML string.

The simplest way to get the annotation done is to hand the big YAML
string directly to `kubectl annotate`.
To present the annotation in the flux API, I've added a field to the
API response.

 - rename the annotation to `antecedent` (meaning something that
   logically precedes), since we already use "cause" elsewhere, albeit
   not as an annotation
 - minorly refactor the way controllers (workloads) from the cluster
   are converted into cluster.Controller values
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants