source-controller icon indicating copy to clipboard operation
source-controller copied to clipboard

Source Controller artifact status remains unchanged when spec changes

Open nab-gha opened this issue 3 years ago • 2 comments

Testing my code that used a GitRepository custom resource and retrieves artifacts from the source controller I changed the GitRepository spec to a nonexistent branch. However the status.artifact did not change...

    "spec": {
        "interval": "1m0s",
        "ref": {
            "branch": "not-present"
        },
        "secretRef": {
            "name": "kraan-http"
        },
        "url": "https://github.com/fidelity/kraan.git"
    },
    "status": {
        "artifact": {
            "checksum": "5285096c6386caeaaedb8cffc6f85d8f2f44e2ae",
            "lastUpdateTime": "2020-11-10T12:27:03Z",
            "path": "gitrepository/gotk-system/addons-config/88c34877fa35ccd9534dfb9b901711ecece213c5.tar.gz",
            "revision": "gh-pages/88c34877fa35ccd9534dfb9b901711ecece213c5",
            "url": "http://source-controller.gotk-system/gitrepository/gotk-system/addons-config/88c34877fa35ccd9534dfb9b901711ecece213c5.tar.gz"
        },
        "conditions": [
            {
                "lastTransitionTime": "2020-11-10T12:32:03Z",
                "message": "unable to clone 'https://github.com/fidelity/kraan.git', error: couldn't find remote ref \"refs/heads/not-present\"",
                "reason": "GitOperationFailed",
                "status": "False",
                "type": "Ready"
            }
        ],
        "observedGeneration": 4
    }

Following the guidelines at https://toolkit.fluxcd.io/dev-guides/source-watcher/ I am watching for changes to GitRepositories and my watch function is being called but per the example it is only looking at status.artifact.revision and not detecting that the git fetch has failed.

Should the source-controller be clearing the artifact sub element when the spec changes or should my code be checking the condition? If latter the dev guide should be updated?

nab-gha avatar Nov 10 '20 13:11 nab-gha

Should the source-controller be clearing the artifact sub element when the spec changes or should my code be checking the condition? If latter the dev guide should be updated?

When a git operation fails, source-controller emits an event that can trigger an alert and sets the Ready condition to false. The other controllers should keep doing their job and reconcile the last known state. If you want to bail out the reconciliation, you can check if the Ready condition is set to false and error out.

stefanprodan avatar Nov 10 '20 14:11 stefanprodan

We are looking at this issue from Bug Scrub and we suspect it will be addressed through the refactor adding more detailed status conditions to observe the in-between states between Not Ready and Ready.

  • https://github.com/fluxcd/flux2/issues/1602

kingdonb avatar Oct 06 '21 12:10 kingdonb